Skip to content

Commit

Permalink
Fix: unintended removal of radio vocabs from query
Browse files Browse the repository at this point in the history
  • Loading branch information
femelo committed Jun 19, 2024
1 parent 93b03bb commit ff1c70b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,22 @@ def search_pyradios(self, phrase: str, media_type: MediaType) -> Generator[dict,
else:
base_score -= 30

queries = []
for voc_filename in ["pyradios", "radio"]:
if self.voc_match(phrase, voc_filename):
base_score += 50 # explicit request
phrase = self.remove_voc(phrase, voc_filename).strip()
if phrase not in queries:
# Save queries with and without radio vocabulary
queries.append(phrase)

queries = []
# if "radio" still in phrase, also add the query without it
if "radio" in phrase:
phrase_without_radio = ' '.join(phrase.replace('radio', '').split())
phrase_without_radio = ' '.join(
phrase.replace('radio', '').split()
)
queries.append(phrase_without_radio)
queries.append(phrase)

for query in queries:
for ch in self.search(query=query):
score = base_score + int(DamerauLevenshtein.normalized_similarity(ch["name"], query) * 100)
Expand Down
2 changes: 1 addition & 1 deletion version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
VERSION_MAJOR = 0
VERSION_MINOR = 0
VERSION_BUILD = 0
VERSION_ALPHA = 4
VERSION_ALPHA = 5
# END_VERSION_BLOCK

0 comments on commit ff1c70b

Please sign in to comment.