Skip to content

Commit

Permalink
Rename OkapiBM25Model to AttireBM25Model
Browse files Browse the repository at this point in the history
  • Loading branch information
Witiko committed Mar 31, 2022
1 parent 9ab6f52 commit 1a062d1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion gensim/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from .ldamodel import LdaModel # noqa:F401
from .lsimodel import LsiModel # noqa:F401
from .tfidfmodel import TfidfModel # noqa:F401
from .bm25model import OkapiBM25Model # noqa:F401
from .bm25model import AtireBM25Model # noqa:F401
from .rpmodel import RpModel # noqa:F401
from .logentropy_model import LogEntropyModel # noqa:F401
from .word2vec import Word2Vec, FAST_VERSION # noqa:F401
Expand Down
2 changes: 1 addition & 1 deletion gensim/models/bm25model.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def precompute_idfs(self, dfs, num_docs):
pass


class OkapiBM25Model(BM25ABC):
class AtireBM25Model(BM25ABC):
def __init__(self, corpus=None, dictionary=None, k1=1.5, b=0.75, epsilon=0.25):
self.k1, self.b, self.epsilon = k1, b, epsilon
super().__init__(corpus, dictionary)
Expand Down
10 changes: 5 additions & 5 deletions gensim/test/test_bm25model.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import unittest

from gensim.models.bm25model import BM25ABC
from gensim.models import OkapiBM25Model
from gensim.models import AtireBM25Model

from gensim.corpora import Dictionary

Expand Down Expand Up @@ -38,7 +38,7 @@ def test_avgdl_from_dictionary(self):
self.assertAlmostEqual(self.expected_avgdl, actual_avgdl)


class OkapiBM25ModelTest(unittest.TestCase):
class AtireBM25ModelTest(unittest.TestCase):
def setUp(self):
self.documents = [['cat', 'dog', 'mouse'], ['cat', 'lion'], ['cat', 'lion']]
self.dictionary = Dictionary(self.documents)
Expand All @@ -63,7 +63,7 @@ def get_idf(word):

def test_idfs_from_corpus(self):
corpus = list(map(self.dictionary.doc2bow, self.documents))
model = OkapiBM25Model(corpus=corpus, k1=self.k1, b=self.b, epsilon=self.epsilon)
model = AtireBM25Model(corpus=corpus, k1=self.k1, b=self.b, epsilon=self.epsilon)

actual_dog_idf = model.idfs[self.dictionary.token2id['dog']]
actual_cat_idf = model.idfs[self.dictionary.token2id['cat']]
Expand All @@ -76,7 +76,7 @@ def test_idfs_from_corpus(self):
self.assertAlmostEqual(self.expected_lion_idf, actual_lion_idf)

def test_idfs_from_dictionary(self):
model = OkapiBM25Model(dictionary=self.dictionary, k1=self.k1, b=self.b, epsilon=self.epsilon)
model = AtireBM25Model(dictionary=self.dictionary, k1=self.k1, b=self.b, epsilon=self.epsilon)

actual_dog_idf = model.idfs[self.dictionary.token2id['dog']]
actual_cat_idf = model.idfs[self.dictionary.token2id['cat']]
Expand All @@ -89,7 +89,7 @@ def test_idfs_from_dictionary(self):
self.assertAlmostEqual(self.expected_lion_idf, actual_lion_idf)

def test_score(self):
model = OkapiBM25Model(dictionary=self.dictionary, k1=self.k1, b=self.b, epsilon=self.epsilon)
model = AtireBM25Model(dictionary=self.dictionary, k1=self.k1, b=self.b, epsilon=self.epsilon)

first_document = self.documents[0]
first_bow = self.dictionary.doc2bow(first_document)
Expand Down

0 comments on commit 1a062d1

Please sign in to comment.