Skip to content

Commit 542285c

Browse files
committed
fix: Fix inconsistent results due to casing
1 parent 7406de5 commit 542285c

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

wordbook/base.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,9 @@ def get_definition(term: str, wn_instance: wn.Wordnet) -> dict[str, Any]:
161161
A dictionary with the processed definition data ('term', 'result').
162162
"""
163163
first_match: str | None = None
164-
exact_match_found: bool = False
165164
result_dict: dict[str, Any] = {pos: [] for pos in POS_MAP.values()}
166165

167-
synsets = wn_instance.synsets(term)
166+
synsets = wn_instance.synsets(term.lower())
168167

169168
if not synsets:
170169
clean_def = {"term": term, "result": None}
@@ -182,11 +181,8 @@ def get_definition(term: str, wn_instance: wn.Wordnet) -> dict[str, Any]:
182181
continue # Skip synsets with no lemmas
183182

184183
matched_lemma = _find_best_lemma_match(term, lemmas)
185-
has_exact_match = any(lemma.lower().replace("_", " ").strip() == term.lower().strip() for lemma in lemmas)
186-
if first_match is None or (has_exact_match and not exact_match_found):
184+
if first_match is None:
187185
first_match = matched_lemma
188-
if has_exact_match:
189-
exact_match_found = True
190186

191187
related_lemmas = _extract_related_lemmas(synset, matched_lemma)
192188

0 commit comments

Comments
 (0)