Skip to content

Commit

Permalink
add unit test with comma in entity (#274)
Browse files Browse the repository at this point in the history
  • Loading branch information
svlandeg authored Aug 31, 2023
1 parent 8e2fd0f commit d95fe5a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions spacy_llm/tests/tasks/test_ner.py
Original file line number Diff line number Diff line change
Expand Up @@ -949,3 +949,20 @@ def test_regression_span_task_response_parse(
doc = docs[0]
pred_ents = [(ent.text, ent.label_) for ent in doc.ents]
assert pred_ents == gold_ents


@pytest.mark.external
@pytest.mark.skipif(has_openai_key is False, reason="OpenAI API key not available")
def test_entity_with_comma(fewshot_cfg_string_v3_lds):
config = Config().from_str(fewshot_cfg_string_v3_lds)
nlp = spacy.util.load_model_from_config(config, auto_fill=True)
text = "Somebody with the name 'Louis, the XVIIth', and Bob both live in Ireland."
doc = nlp(text)
ents = doc.ents
assert len(ents) == 3
assert ents[0].text == "'Louis, the XVIIth'" or "Louis, the XVIIth"
assert ents[0].label_ == "PER"
assert ents[1].text == "Bob"
assert ents[1].label_ == "PER"
assert ents[2].text == "Ireland"
assert ents[2].label_ == "LOC"

0 comments on commit d95fe5a

Please sign in to comment.