text/docs/api_docs/python/text/wordshape.md at master · tensorflow/text · GitHub
Skip to content

Latest commit

 

History

History
94 lines (77 loc) · 2.27 KB

File metadata and controls

94 lines (77 loc) · 2.27 KB

description: Determine wordshape features for each input string.

text.wordshape

View source

Determine wordshape features for each input string.

text.wordshape(
    input_tensor, pattern, name=None
)

In this example, we test for title case (the first character is upper or title case, and the remaining characters are lowercase). ```

input = [ ... u"abc", u"ABc", u"ABC", u"Abc", u"aBcd", u"\u01c8bc".encode("utf-8") ... ] wordshape(input, WordShape.HAS_TITLE_CASE) <tf.Tensor: shape=(6,), dtype=bool, numpy=array([False, False, False, True, False, True])>

Args

`input_tensor` string `Tensor` with any shape.
`pattern` A `tftext.WordShape` or a list of WordShapes.
`name` A name for the operation (optional).

Returns

`[input_tensor.shape + pattern.shape]`: A tensor where `result[i1...iN, j]` is true if `input_tensor[i1...iN]` has the wordshape specified by `pattern[j]`.

Raises

`ValueError` If `pattern` contains an unknown identifier.