pytext.data.data_structures package

Submodules

pytext.data.data_structures.annotation module

class pytext.data.data_structures.annotation.Annotation(annotation_string: str, utterance: str = '', brackets: str = '[]', combination_labels: bool = True, add_dict_feat: bool = False, accept_flat_intents_slots: bool = False)[source]

Bases: object

build_tree(accept_flat_intents_slots: bool = False)[source]
class pytext.data.data_structures.annotation.Intent(label)[source]

Bases: pytext.data.data_structures.annotation.Node

validate_node(*args)[source]
class pytext.data.data_structures.annotation.Node(label)[source]

Bases: object

children_flat_str_spans()[source]
flat_str()[source]
get_info()[source]
get_token_indices()[source]
get_token_span()[source]

0 indexed Like array slicing: For the first 3 tokens, returns 0, 3

list_ancestors()[source]
list_nonTerminals()[source]

Returns all Intent and Slot nodes subordinate to this node

list_terminals()[source]

Returns all Token nodes

list_tokens()[source]
validate_node(*args)[source]
class pytext.data.data_structures.annotation.Node_Info(node)[source]

Bases: object

This class extracts the essential information for a mode, for use in rules.

get_parent(node)[source]
get_same_span(node)[source]
class pytext.data.data_structures.annotation.Root[source]

Bases: pytext.data.data_structures.annotation.Node

validate_node(*args)[source]
class pytext.data.data_structures.annotation.Slot(label)[source]

Bases: pytext.data.data_structures.annotation.Node

validate_node(allow_empty_slots=True, *args)[source]
class pytext.data.data_structures.annotation.Token(label, index)[source]

Bases: pytext.data.data_structures.annotation.Node

remove()[source]

Removes this token from the tree

validate_node(*args)[source]
class pytext.data.data_structures.annotation.Token_Info(node)[source]

Bases: object

This class extracts the essential information for a token for use in rules.

get_parent(node)[source]
class pytext.data.data_structures.annotation.Tree(root: pytext.data.data_structures.annotation.Root, combination_labels: bool, utterance: str = '', validate_tree: bool = True)[source]

Bases: object

depth()[source]
flat_str()[source]
list_tokens()[source]
lotv_str()[source]

LOTV – Limited Output Token Vocabulary We map the terminal tokens in the input to a constant output (SEQLOGICAL_LOTV_TOKEN) to make the parsing task easier for models where the decoding is decoupled from the input (e.g. seq2seq). This way, the model can focus on learning to predict the parse tree, rather than waste effort learning to replicate terminal tokens.

print_tree()[source]
recursive_validation(node, *args)[source]
to_actions()[source]
validate_tree(allow_empty_slots=True)[source]

This is a method for checking that roots/intents/slots are nested correctly. Root( Intent( Slot( Intent( Slot, etc.) ) ) )

class pytext.data.data_structures.annotation.TreeBuilder(combination_labels: bool = True)[source]

Bases: object

finalize_tree(validate_tree=True)[source]
update_tree(action, label)[source]
pytext.data.data_structures.annotation.escape_brackets(string: str) → str[source]
pytext.data.data_structures.annotation.is_intent_nonterminal(node_label: str) → bool[source]
pytext.data.data_structures.annotation.is_slot_nonterminal(node_label: str) → bool[source]
pytext.data.data_structures.annotation.is_unsupported(node_label: str) → bool[source]
pytext.data.data_structures.annotation.is_valid_nonterminal(node_label: str) → bool[source]
pytext.data.data_structures.annotation.list_from_actions(tokens_str: List[str], actions_vocab: List[str], actions_indices: List[int])[source]

pytext.data.data_structures.node module

class pytext.data.data_structures.node.Node(label: str, span: pytext.data.data_structures.node.Span, children: Optional[AbstractSet[Node]] = None, text: str = None)[source]

Bases: object

Node in an intent-slot tree, representing either an intent or a slot.

label

Label of the node.

Type:str
span

Span of the node.

Type:Span
children

Children of the node.

Type:set of Node
children
get_depth() → int[source]
label
span
text
class pytext.data.data_structures.node.Span[source]

Bases: tuple

Span of a node in an intent-slot tree.

start

Start position of the node.

end

End position of the node (exclusive).

end

Alias for field number 1

start

Alias for field number 0

Module contents