Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
97fbb9c9
Commit
97fbb9c9
authored
May 18, 2002
by
Tim Peters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rearrange the Okapi reindexing tests to make it easier to figure out what
went wrong if they fail.
parent
466d0130
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
5 deletions
+15
-5
lib/python/Products/ZCTextIndex/tests/testZCTextIndex.py
lib/python/Products/ZCTextIndex/tests/testZCTextIndex.py
+15
-5
No files found.
lib/python/Products/ZCTextIndex/tests/testZCTextIndex.py
View file @
97fbb9c9
from
Products.ZCTextIndex.ZCTextIndex
import
ZCTextIndex
from
Products.ZCTextIndex.ZCTextIndex
import
ZCTextIndex
from
Products.ZCTextIndex.tests
\
from
Products.ZCTextIndex.tests
\
import
testIndex
,
testQueryEngine
,
testQueryParser
import
testIndex
,
testQueryEngine
,
testQueryParser
from
Products.ZCTextIndex.BaseIndex
import
scaled_int
,
SCALE_FACTOR
from
Products.ZCTextIndex.BaseIndex
import
\
scaled_int
,
SCALE_FACTOR
,
inverse_doc_frequency
from
Products.ZCTextIndex.CosineIndex
import
CosineIndex
from
Products.ZCTextIndex.CosineIndex
import
CosineIndex
from
Products.ZCTextIndex.OkapiIndex
import
OkapiIndex
from
Products.ZCTextIndex.OkapiIndex
import
OkapiIndex
from
Products.ZCTextIndex.Lexicon
import
Lexicon
,
Splitter
from
Products.ZCTextIndex.Lexicon
import
Lexicon
,
Splitter
...
@@ -282,19 +283,21 @@ class OkapiIndexTests(ZCIndexTestsBase, testIndex.OkapiIndexTest):
...
@@ -282,19 +283,21 @@ class OkapiIndexTests(ZCIndexTestsBase, testIndex.OkapiIndexTest):
# A white-box test.
# A white-box test.
def testAbsoluteScores(self):
def testAbsoluteScores(self):
from Products.ZCTextIndex.OkapiIndex import inverse_doc_frequency
docs = ["
one
",
docs = ["
one
",
"
one
two
",
"
one
two
",
"
one
two
three
"]
"
one
two
three
"]
for i in range(len(docs)):
for i in range(len(docs)):
self.zc_index.index_object(i + 1, Indexable(docs[i]))
self.zc_index.index_object(i + 1, Indexable(docs[i]))
# A brief digression to exercise re-indexing. This should leave
self._checkAbsoluteScores()
# things exactly as they were.
# Exercise re-indexing. This should leave things exactly as they were.
for variant in "
one
xyz
", "
xyz
two
three
", "
abc
def
", docs[-1]:
for variant in "
one
xyz
", "
xyz
two
three
", "
abc
def
", docs[-1]:
self.zc_index.index_object(len(docs), Indexable(variant))
self.zc_index.index_object(len(docs), Indexable(variant))
self._checkAbsoluteScores()
def _checkAbsoluteScores(self):
self.assertEqual(self.index._totaldoclen, 6)
self.assertEqual(self.index._totaldoclen, 6)
# So the mean doc length is 2. We use that later.
# So the mean doc length is 2. We use that later.
...
@@ -341,7 +344,14 @@ class OkapiIndexTests(ZCIndexTestsBase, testIndex.OkapiIndexTest):
...
@@ -341,7 +344,14 @@ class OkapiIndexTests(ZCIndexTestsBase, testIndex.OkapiIndexTest):
for i in range(1, 10):
for i in range(1, 10):
doc = "
one
" + "
two
" * i + "
xyz
" * (9 - i)
doc = "
one
" + "
two
" * i + "
xyz
" * (9 - i)
self.zc_index.index_object(i, Indexable(doc))
self.zc_index.index_object(i, Indexable(doc))
self._checkRelativeScores()
# Exercise re-indexing. This should leave things exactly as they were.
self.zc_index.index_object(9, Indexable("
two
xyz
"))
self.zc_index.index_object(9, Indexable(doc))
self._checkRelativeScores()
def _checkRelativeScores(self):
r, num = self.zc_index.query("
one
two
")
r, num = self.zc_index.query("
one
two
")
self.assertEqual(num, 9)
self.assertEqual(num, 9)
self.assertEqual(len(r), 9)
self.assertEqual(len(r), 9)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment