Skip to content

Commit

Permalink
fix(tests): templatic augmentation
Browse files Browse the repository at this point in the history
  • Loading branch information
JulesBelveze committed Jul 20, 2023
1 parent 7fd6c89 commit 34200c0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions langtest/datahandler/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def to_conll(
token = word.group()
match = sample.expected_results[word.group()]
label = match.entity if match is not None else "O"
text += f"{token} X X {label}\n"
text += f"{token} -X- -X- {label}\n"

if test_case and writing_mode != "ignore":
words = re.finditer(r"([^\s]+)", test_case)
Expand All @@ -208,9 +208,9 @@ def to_conll(
match = sample.actual_results[word.group()]
label = match.entity if match is not None else "O"
if writing_mode == "append":
text += f"{token} X X {label}\n"
text += f"{token} -X- -X- {label}\n"
elif writing_mode == "separate":
text_perturbed += f"{token} X X {label}\n"
text_perturbed += f"{token} -X- -X- {label}\n"

if writing_mode == "separate":
return text, text_perturbed
Expand Down
12 changes: 6 additions & 6 deletions tests/test_augmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,16 +221,16 @@ def test_fix(self):
"My -X- -X- O",
"name -X- -X- O",
"is -X- -X- O",
"Jean NN NN B-PER",
"- NN NN I-PER",
"Pierre NN NN I-PER",
"Jean -X- -X- B-PER",
"- -X- -X- I-PER",
"Pierre -X- -X- I-PER",
"and -X- -X- O",
"I -X- -X- O",
"am -X- -X- O",
"from -X- -X- O",
"New NN NN B-LOC",
"York NN NN I-LOC",
"City NN NN I-LOC",
"New -X- -X- B-LOC",
"York -X- -X- I-LOC",
"City -X- -X- I-LOC",
]
generator = TemplaticAugment(
templates=["My name is {PER} and I am from {LOC}"], task="ner"
Expand Down

0 comments on commit 34200c0

Please sign in to comment.