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
3630a0bb
Commit
3630a0bb
authored
Mar 05, 1997
by
chris
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed PersistentResultList, placing it in its own module
parent
830142f9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
18 deletions
+30
-18
lib/python/SearchIndex/InvertedIndex.py
lib/python/SearchIndex/InvertedIndex.py
+30
-18
No files found.
lib/python/SearchIndex/InvertedIndex.py
View file @
3630a0bb
...
...
@@ -30,7 +30,7 @@ Example usage:
print i['blah']
$Id: InvertedIndex.py,v 1.1
7 1997/02/24 16:29:01
chris Exp $'''
$Id: InvertedIndex.py,v 1.1
8 1997/03/05 19:21:36
chris Exp $'''
# Copyright
#
# Copyright 1996 Digital Creations, L.C., 910 Princess Anne
...
...
@@ -82,6 +82,9 @@ $Id: InvertedIndex.py,v 1.17 1997/02/24 16:29:01 chris Exp $'''
# (540) 371-6909
#
# $Log: InvertedIndex.py,v $
# Revision 1.18 1997/03/05 19:21:36 chris
# removed PersistentResultList, placing it in its own module
#
# Revision 1.17 1997/02/24 16:29:01 chris
# *** empty log message ***
#
...
...
@@ -138,10 +141,10 @@ $Id: InvertedIndex.py,v 1.17 1997/02/24 16:29:01 chris Exp $'''
#
#
#
__version__
=
'$Revision: 1.1
7
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
8
$'
[
11
:
-
2
]
import
regex
,
regsub
,
string
,
SingleThreadedTransaction
,
copy
import
regex
,
regsub
,
string
,
copy
from
types
import
*
...
...
@@ -454,7 +457,7 @@ class Index(SingleThreadedTransaction.Persistent):
index
=
self
.
_index_object
src
=
regsub
.
gsub
(
'-[
\
t
]*
\
n
[
\
t
]*'
,
''
,
str
(
src
))
# de-hyphenate
src
=
filter
(
None
,
self
.
split_words
(
src
))
src
=
filter
(
None
,
self
.
split_words
(
src
))
if
(
len
(
src
)
<
2
):
raise
IndexingError
,
'cannot index document with fewer than two keywords'
...
...
@@ -462,8 +465,9 @@ class Index(SingleThreadedTransaction.Persistent):
nwords
=
math
.
log
(
len
(
src
))
d
=
{}
for
i
in
range
(
len
(
src
)):
s
=
src
[
i
]
s
=
-
1
for
s
in
src
:
i
=
i
+
1
s
=
string
.
lower
(
s
)
stopword_flag
=
0
...
...
@@ -496,7 +500,7 @@ class Index(SingleThreadedTransaction.Persistent):
def
__getitem__
(
self
,
key
):
'''
'''
\
Get the ResultList objects for the inverted key, key.
The key may be a regular expression, in which case a regular
...
...
@@ -554,11 +558,29 @@ class Index(SingleThreadedTransaction.Persistent):
def
remove_document
(
self
,
doc_key
,
s
=
None
):
'''
\
remove_document(doc_key, s = None)
Remove a specified document from the index, given the document key.
Optionally, the document source may be provided. This helps to
speed up removal of documents from a large index.
'''
if
(
s
is
None
):
for
key
in
self
.
keys
():
try
:
del
self
[
key
][
doc_key
]
except
:
except
KeyError
:
continue
else
:
s
=
regsub
.
gsub
(
'-[
\
t
]*
\
n
[
\
t
]*'
,
''
,
str
(
s
))
# de-hyphenate
s
=
filter
(
None
,
self
.
split_words
(
s
))
for
key
in
s
:
try
:
del
self
[
key
][
doc_key
]
except
KeyError
:
continue
...
...
@@ -610,16 +632,6 @@ class Index(SingleThreadedTransaction.Persistent):
return
(
self
.
_index_object
,
self
.
list_class
)
class
PersistentResultList
(
ResultList
,
SingleThreadedTransaction
.
Persistent
):
def
addentry
(
self
,
key
,
*
info
):
'''Add a frequency/key pair to this object'''
t
=
(
self
,
key
)
+
info
apply
(
PersistentResultList
.
inheritedAttribute
(
'addentry'
),
t
)
self
.
__changed__
(
1
)
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