We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 08baab5 commit 3840fa2Copy full SHA for 3840fa2
termdoc/htdm.py
@@ -117,4 +117,6 @@ def df(self, term, prefix="", level=None):
117
def tf_idf(self, term, address, prefix=""):
118
if not address.startswith(prefix):
119
raise ValueError(f"address '{address}' must start with prefix '{prefix}'")
120
- return self.tf(term, address) * log10(1 / self.df(term, prefix, level=self.depth(address) - self.depth(prefix)))
+ return self.tf(term, address) * log10(
121
+ 1 / self.df(term, prefix, level=self.depth(address) - self.depth(prefix))
122
+ )
tests.py
@@ -456,14 +456,16 @@ def test_wikipedia(self):
456
457
c = termdoc.HTDM()
458
c.add("1", ["this", "is", "a", "a", "sample"])
459
- c.add("2", ["this", "is", "another", "another", "example", "example", "example"])
+ c.add(
460
+ "2", ["this", "is", "another", "another", "example", "example", "example"]
461
462
- self.assertEqual(c.tf("this", "1"), 1/5)
- self.assertEqual(c.tf("this", "2"), 1/7)
463
+ self.assertEqual(c.tf("this", "1"), 1 / 5)
464
+ self.assertEqual(c.tf("this", "2"), 1 / 7)
465
self.assertEqual(c.df("this"), 1)
466
self.assertEqual(c.tf("example", "1"), 0)
- self.assertEqual(c.tf("example", "2"), 3/7)
- self.assertEqual(c.df("example"), 1/2)
467
+ self.assertEqual(c.tf("example", "2"), 3 / 7)
468
+ self.assertEqual(c.df("example"), 1 / 2)
469
self.assertEqual(c.tf_idf("this", "1"), 0)
470
self.assertEqual(c.tf_idf("this", "2"), 0)
471
self.assertEqual(c.tf_idf("example", "1"), 0)
0 commit comments