Skip to content
This repository was archived by the owner on Nov 22, 2022. It is now read-only.

Print out utterance for tree validation errors for RNNG #172

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pytext/data/compositional_data_handler.py
Original file line number Diff line number Diff line change
@@ -159,7 +159,7 @@ def preprocess_row(self, row_data: Dict[str, Any]) -> Dict[str, Any]:
actions = ""
# training time
if DFColumn.SEQLOGICAL in row_data:
annotation = Annotation(row_data[DFColumn.SEQLOGICAL])
annotation = Annotation(row_data[DFColumn.SEQLOGICAL], utterance)
actions = annotation.tree.to_actions()

# Seqlogical format is required for building the tree representation of
14 changes: 11 additions & 3 deletions pytext/data/data_structures/annotation.py
Original file line number Diff line number Diff line change
@@ -54,6 +54,7 @@ class Annotation:
def __init__(
self,
annotation_string: str,
utterance: str = "",
brackets: str = OPEN + CLOSE,
combination_labels: bool = True,
add_dict_feat: bool = False,
@@ -75,7 +76,9 @@ def __init__(
else:
raise ValueError("Cannot parse annotation_string")

self.tree = Tree(self.build_tree(accept_flat_intents_slots), combination_labels)
self.tree = Tree(
self.build_tree(accept_flat_intents_slots), combination_labels, utterance
)
self.root: Root = self.tree.root

def build_tree(self, accept_flat_intents_slots: bool = False):
@@ -479,13 +482,18 @@ def __str__(self):


class Tree:
def __init__(self, root: Root, combination_labels: bool) -> None:
def __init__(
self, root: Root, combination_labels: bool, utterance: str = ""
) -> None:
self.root = root
self.combination_labels = combination_labels
try:
self.validate_tree()
except ValueError as v:
raise ValueError("Tree validation failed: {}".format(v))
raise ValueError(
"Tree validation failed: {}. \n".format(v)
+ "Utterance is: {}".format(utterance)
)

def validate_tree(self):
"""