Skip to content

Commit

Permalink
Merge pull request #84 from huridocs/no-spaces-fix
Browse files Browse the repository at this point in the history
Fix selection of input without spaces
  • Loading branch information
gabriel-piles authored Aug 12, 2024
2 parents e5b00b9 + a342472 commit 58a45ea
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class InputWithoutSpaces(TextToTextMethod):

def train(self, extraction_data: ExtractionData):
pass
self.save_json("best_method.json", True)

@staticmethod
def trim_text(tag_texts: list[str]) -> str:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,24 @@ def test_predictions_two_samples(self):
self.assertEqual(extraction_id, suggestions[0].id)
self.assertEqual("entity_name", suggestions[0].entity_name)
self.assertEqual("one", suggestions[0].text)

def test_predictions_input_without_spaces(self):
sample = [
TrainingSample(
labeled_data=LabeledData(label_text="onetwothree", language_iso="en"), tags_texts=["one two", "three"]
)
]
extraction_data = ExtractionData(samples=sample * 3, extraction_identifier=extraction_identifier)

text_to_text_extractor = TextToTextExtractor(extraction_identifier=extraction_identifier)
text_to_text_extractor.create_model(extraction_data)

suggestions = text_to_text_extractor.get_suggestions(
[PredictionSample.from_text("one two three four", "entity_name")]
)

self.assertEqual(1, len(suggestions))
self.assertEqual(tenant, suggestions[0].tenant)
self.assertEqual(extraction_id, suggestions[0].id)
self.assertEqual("entity_name", suggestions[0].entity_name)
self.assertEqual("onetwothreefour", suggestions[0].text)

0 comments on commit 58a45ea

Please sign in to comment.