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
7ec734a4
Commit
7ec734a4
authored
May 17, 2002
by
Tim Peters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some simplifications unique to the cosine index.
parent
38ba01b6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
8 deletions
+4
-8
lib/python/Products/ZCTextIndex/CosineIndex.py
lib/python/Products/ZCTextIndex/CosineIndex.py
+4
-8
No files found.
lib/python/Products/ZCTextIndex/CosineIndex.py
View file @
7ec734a4
...
...
@@ -54,11 +54,11 @@ class CosineIndex(BaseIndex):
# ._wordinfo for cosine is wid -> {docid -> weight};
# t -> D -> w(d, t)/W(d)
# ._docweight for
Okapi
is
# ._docweight for
cosine
is
# docid -> W(docid)
# Most of the computation for computing a relevance score for the
# document occurs in the
search
() method. The code currently
# document occurs in the
_search_wids
() method. The code currently
# implements the cosine similarity function described in Managing
# Gigabytes, eq. 4.3, p. 187. The index_object() method
# precomputes some values that are independent of the particular
...
...
@@ -109,17 +109,13 @@ class CosineIndex(BaseIndex):
L
=
[]
DictType
=
type
({})
for
wid
in
wids
:
d2w
=
self
.
_wordinfo
.
get
(
wid
)
# maps docid to w(docid, wid)
if
d2w
is
None
:
# Need a test case to cover this
L
.
append
((
IIBucket
(),
scaled_int
(
1
)))
continue
assert
self
.
_wordinfo
.
has_key
(
wid
)
# caller responsible for OOV
d2w
=
self
.
_wordinfo
[
wid
]
# maps docid to w(docid, wid)
idf
=
query_term_weight
(
len
(
d2w
),
N
)
# this is an unscaled float
#print "idf = %.3f" % idf
if
isinstance
(
d2w
,
DictType
):
d2w
=
IIBucket
(
d2w
)
L
.
append
((
d2w
,
scaled_int
(
idf
)))
L
.
sort
(
lambda
x
,
y
:
cmp
(
len
(
x
[
0
]),
len
(
y
[
0
])))
return
L
def
query_weight
(
self
,
terms
):
...
...
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