Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patterns improvement #20

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions lmentry/scorers/homophone_scorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def get_exact_patterns(answer, query, distractor):
rf"{query} is a homophone of {answer}",
rf"{query} and {answer} are homophones( of each other)?",
rf"The homophone of {query} is {answer}",
rf"Both words have different sounds, but {answer} sounds more {like} {query}"
]

# swap answer and query
Expand Down
5 changes: 3 additions & 2 deletions lmentry/scorers/rhyming_word_scorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def get_exact_patterns(answer, query, distractor):
rf"{a} rhyme of {query} is {answer}( and not {distractor})?",
rf"{a} word rhyming with {query} is {answer}",
rf"{a} word that rhymes with {query} is {answer}",
rf"{query} and {answer}( both)? rhyme( with each other)?, {while_} {distractor} {doesnt} rhyme with either( word)?"
rf"{query} and {answer}( both)? rhyme( with each other)?, {while_} {distractor} {doesnt} rhyme with either( word)?",
rf"{query} and {answer} are a rhyme"
]

# swap answer and query
Expand All @@ -44,7 +45,7 @@ def negative_scorer(self, prediction, answer):
score, certainty = None, None

predictions_words = re.findall(r"\b[a-z]+\b", prediction)
if len(predictions_words) == 1 and predictions_words[0] != answer:
if answer not in predictions_words and not re.search("n't|not", prediction):
score = 0
certainty = 1

Expand Down