Skip to content

armgit / txtai

Public Imported from GitHub
0

💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows

Add scoring.count() #327

davidmezzetti48fa74d87a6e
diff --git a/src/python/txtai/scoring/base.py b/src/python/txtai/scoring/base.py
index 9a7d09d9..8a402541 100644
--- a/src/python/txtai/scoring/base.py
+++ b/src/python/txtai/scoring/base.py
@@ -241,6 +241,16 @@ class Scoring:
return topn
+ def count(self):
+ """
+ Returns the total number of documents indexed.
+
+ Returns:
+ total number of documents indexed
+ """
+
+ return self.total
+
def load(self, path):
"""
Loads a saved Scoring object from path.
diff --git a/test/python/testscoring.py b/test/python/testscoring.py
index 0636d7fe..a6555555 100644
--- a/test/python/testscoring.py
+++ b/test/python/testscoring.py
@@ -95,6 +95,9 @@ class TestScoring(unittest.TestCase):
keys = [k for k, v in sorted(model.idf.items(), key=lambda x: x[1])]
+ # Test count
+ self.assertEqual(model.count(), len(data))
+
# Win should be lowest score for all models
self.assertEqual(keys[0], "wins")