-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
40 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import pytest | ||
from src.utils.llm import llm_find_entities | ||
|
||
def test_llm_find_entities_basic(): | ||
text = "Tony Stark and Peter Parker walk through New York where Peter wants to show Tony the Broadway." | ||
expected_output = {'#person_1#': {'Tony Stark', 'Tony'}, '#person_2#': {'Peter Parker', 'Peter'}, '#place_1#': {'New York'}, '#place_2#': {'Broadway'}} | ||
result = llm_find_entities(text) | ||
assert result == expected_output | ||
assert result == expected_output | ||
|
||
def test_llm_find_entities_no_entities(): | ||
text = "This is a text without any names of persons or places." | ||
expected_output = {} | ||
result = llm_find_entities(text) | ||
assert result == expected_output | ||
|
||
def test_llm_find_entities_repeated_names(): | ||
text = "Alice and Bob went to Wonderland. Alice met Bob at the Wonderland park." | ||
expected_output = { | ||
"#person_1#": ["Alice"], | ||
"#person_2#": ["Bob"], | ||
"#place_1#": ["Wonderland"], | ||
'#place_2#': ['Wonderland park'] | ||
} | ||
result = llm_find_entities(text) | ||
|
||
def test_llm_find_entities_raw_output(): | ||
text = "Tony Stark and Peter Parker walk through New York where Peter wants to show Tony the Broadway." | ||
result = llm_find_entities(text, raw=True) | ||
print("result") | ||
print(result) | ||
assert isinstance(result, str) | ||
assert "Tony Stark" in result | ||
assert "Peter Parker" in result | ||
assert "New York" in result | ||
assert "Broadway" in result |