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
6cb8ab91
Commit
6cb8ab91
authored
May 17, 2002
by
Tim Peters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Compute scaled_int the same way everywhere.
parent
85236fcc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
35 deletions
+7
-35
lib/python/Products/ZCTextIndex/CosineIndex.py
lib/python/Products/ZCTextIndex/CosineIndex.py
+3
-17
lib/python/Products/ZCTextIndex/OkapiIndex.py
lib/python/Products/ZCTextIndex/OkapiIndex.py
+3
-17
lib/python/Products/ZCTextIndex/tests/testZCTextIndex.py
lib/python/Products/ZCTextIndex/tests/testZCTextIndex.py
+1
-1
No files found.
lib/python/Products/ZCTextIndex/CosineIndex.py
View file @
6cb8ab91
...
...
@@ -21,28 +21,14 @@ from BTrees.IIBTree import IIBTree, IIBucket
from
Products.ZCTextIndex.IIndex
import
IIndex
from
Products.ZCTextIndex
import
WidCode
from
Products.ZCTextIndex.BaseIndex
import
BaseIndex
,
inverse_doc_frequency
from
Products.ZCTextIndex.BaseIndex
import
BaseIndex
,
\
inverse_doc_frequency
,
\
scaled_int
,
SCALE_FACTOR
from
Products.ZCTextIndex.SetOps
import
mass_weightedIntersection
,
\
mass_weightedUnion
import
ZODB
# Instead of storing floats, we generally store scaled ints. Binary pickles
# can store those more efficiently. The default SCALE_FACTOR of 1024
# is large enough to get about 3 decimal digits of fractional info, and
# small enough so that scaled values should almost always fit in a signed
# 16-bit int (we're generally storing logs, so a few bits before the radix
# point goes a long way; on the flip side, for reasonably small numbers x
# most of the info in log(x) is in the fractional bits, so we do want to
# save a lot of those).
SCALE_FACTOR
=
1024.0
def
scaled_int
(
f
,
scale
=
SCALE_FACTOR
):
# We expect only positive inputs, so "add a half and chop" is the
# same as round(). Surprising, calling round() is significantly more
# expensive.
return
int
(
f
*
scale
+
0.5
)
class
CosineIndex
(
BaseIndex
):
__implements__
=
IIndex
...
...
lib/python/Products/ZCTextIndex/OkapiIndex.py
View file @
6cb8ab91
...
...
@@ -24,28 +24,14 @@ from BTrees.IIBTree import IIBTree, IIBucket
from
Products.ZCTextIndex.IIndex
import
IIndex
from
Products.ZCTextIndex
import
WidCode
from
Products.ZCTextIndex.BaseIndex
import
BaseIndex
,
inverse_doc_frequency
from
Products.ZCTextIndex.BaseIndex
import
BaseIndex
,
\
inverse_doc_frequency
,
\
scaled_int
from
Products.ZCTextIndex.SetOps
import
mass_weightedIntersection
,
\
mass_weightedUnion
import
ZODB
# Instead of storing floats, we generally store scaled ints. Binary pickles
# can store those more efficiently. The default SCALE_FACTOR of 1024
# is large enough to get about 3 decimal digits of fractional info, and
# small enough so that scaled values should almost always fit in a signed
# 16-bit int (we're generally storing logs, so a few bits before the radix
# point goes a long way; on the flip side, for reasonably small numbers x
# most of the info in log(x) is in the fractional bits, so we do want to
# save a lot of those).
SCALE_FACTOR
=
1024.0
def
scaled_int
(
f
,
scale
=
SCALE_FACTOR
):
# We expect only positive inputs, so "add a half and chop" is the
# same as round(). Surprising, calling round() is significantly more
# expensive.
return
int
(
f
*
scale
+
0.5
)
class
OkapiIndex
(
BaseIndex
):
__implements__
=
IIndex
...
...
lib/python/Products/ZCTextIndex/tests/testZCTextIndex.py
View file @
6cb8ab91
from
Products.ZCTextIndex.ZCTextIndex
import
ZCTextIndex
from
Products.ZCTextIndex.tests
\
import
testIndex
,
testQueryEngine
,
testQueryParser
from
Products.ZCTextIndex.
Cosin
eIndex
import
scaled_int
,
SCALE_FACTOR
from
Products.ZCTextIndex.
Bas
eIndex
import
scaled_int
,
SCALE_FACTOR
from
Products.ZCTextIndex.CosineIndex
import
CosineIndex
from
Products.ZCTextIndex.OkapiIndex
import
OkapiIndex
from
Products.ZCTextIndex.Lexicon
import
Lexicon
,
Splitter
...
...
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