diff --git a/ir_axioms/backend/pyterrier/__init__.py b/ir_axioms/backend/pyterrier/__init__.py index a5b2f21..de0ca9d 100644 --- a/ir_axioms/backend/pyterrier/__init__.py +++ b/ir_axioms/backend/pyterrier/__init__.py @@ -88,7 +88,9 @@ def _index(self) -> Index: ) def __str__(self): - return f'TerrierIndexContext({str(self.index_location).split("/")[-1].split(" ")[0]})' + ret = str(self.index_location) + ret = ret.split("/")[-1].split(" ")[0] + return f'TerrierIndexContext({ret})' @cached_property def _meta_index(self) -> MetaIndex: diff --git a/ir_axioms/modules/similarity.py b/ir_axioms/modules/similarity.py index 7779631..3f31f46 100644 --- a/ir_axioms/modules/similarity.py +++ b/ir_axioms/modules/similarity.py @@ -13,6 +13,9 @@ from ir_axioms import logger from ir_axioms.utils.nltk import download_nltk_dependencies +import os +DIR_PATH = os.path.dirname(os.path.realpath(__file__)) + @lru_cache(None) def synonym_set( @@ -199,5 +202,5 @@ 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 - embeddings_path: Final[str] = "/workspaces/ecir25-gpt-axioms/wiki-news-300d-1M.magnitude" + # 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" diff --git a/tests/unit/test_string_representations.py b/tests/unit/test_string_representations.py index 0d15f88..892dcc5 100644 --- a/tests/unit/test_string_representations.py +++ b/tests/unit/test_string_representations.py @@ -11,20 +11,23 @@ class TestStringRepresentations(unittest.TestCase): def test_string_representation_of_terrier_index_context_01(self): # Needed for caching expected = 'TerrierIndexContext(index_location)' - actual = str(TerrierIndexContext('index_location')) + index_location = 'index_location' + actual = str(TerrierIndexContext(index_location)) self.assertEqual(expected, actual) def test_string_representation_of_terrier_index_context_02(self): # Needed for caching expected = 'TerrierIndexContext(index_location)' - actual = str(TerrierIndexContext('ignore/absolute/path/index_location')) + index_location = 'ignore/absolute/path/index_location' + actual = str(TerrierIndexContext(index_location)) self.assertEqual(expected, actual) def test_string_representation_of_terrier_index_context_03(self): # Needed for caching expected = 'TerrierIndexContext(index_location)' - actual = str(TerrierIndexContext('ignore/absolute/path/index_location ignore suffix')) + index_location = 'ignore/absolute/path/index_location ignore suffix' + actual = str(TerrierIndexContext(index_location)) - self.assertEqual(expected, actual) \ No newline at end of file + self.assertEqual(expected, actual)