text.wordshape
Determine wordshape features for each input string.
text.wordshape(
input_tensor, pattern, name=None
)
Used in the notebooks
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 |
<bool>[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.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-12-20 UTC.
[null,null,["Last updated 2024-12-20 UTC."],[],[]]