Skip to content

Commit

Permalink
fix FastTextWikiNewsTermSimilarityMixin
Browse files Browse the repository at this point in the history
  • Loading branch information
mam10eks committed Dec 12, 2024
1 parent 3d68d4d commit 8c9ab92
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ir_axioms/modules/similarity.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from ir_axioms import logger
from ir_axioms.utils.nltk import download_nltk_dependencies
import wget

import os
DIR_PATH = os.path.dirname(os.path.realpath(__file__))
Expand Down Expand Up @@ -193,6 +194,10 @@ class MagnitudeTermSimilarityMixin(TermSimilarityMixin, ABC):

@cached_property
def _embeddings(self):
url = 'https://files.webis.de/data-in-production/data-research/ir-axioms/wiki-news-300d-1M.magnitude' # noqa: E501
if not os.path.isfile(self.embeddings_path) and self.embeddings_path.endswith('wiki-news-300d-1M.magnitude'):
wget.download(url, out=self.embeddings_path)

return Magnitude(self.embeddings_path)

@final
Expand All @@ -202,5 +207,9 @@ def similarity(self, term1: str, term2: str):


class FastTextWikiNewsTermSimilarityMixin(MagnitudeTermSimilarityMixin):
# wget via: https://files.webis.de/data-in-production/data-research/ir-axioms/wiki-news-300d-1M.magnitude # noqa: E501
embeddings_path: Final[str] = f"{DIR_PATH}/wiki-news-300d-1M.magnitude"

def __init__(self):
super().__init__()


1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ dependencies = [
"trectools~=0.0.44",
"typing-extensions~=4.0",
"xxhash~=3.0",
"wget",
]
dynamic = ["version"]

Expand Down

0 comments on commit 8c9ab92

Please sign in to comment.