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
9d2add7e
Commit
9d2add7e
authored
Sep 24, 1999
by
Michel Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added __len__
parent
faf9d50c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
3 deletions
+29
-3
lib/python/SearchIndex/Lexicon.py
lib/python/SearchIndex/Lexicon.py
+29
-3
No files found.
lib/python/SearchIndex/Lexicon.py
View file @
9d2add7e
...
...
@@ -97,8 +97,10 @@ mapping.
from
Splitter
import
Splitter
from
Persistence
import
Persistent
from
Acquisition
import
Implicit
import
OIBTree
import
OIBTree
,
BTree
OIBTree
=
OIBTree
.
BTree
OOBTree
=
BTree
.
BTree
import
re
class
Lexicon
(
Persistent
,
Implicit
):
...
...
@@ -111,8 +113,10 @@ class Lexicon(Persistent, Implicit):
"""
def
__init__
(
self
):
def
__init__
(
self
,
globbish
=
None
):
self
.
_lexicon
=
OIBTree
()
if
globbish
:
self
.
_ngrams
=
OOBTree
()
self
.
counter
=
0
def
__getitem__
(
self
,
key
):
...
...
@@ -130,12 +134,32 @@ class Lexicon(Persistent, Implicit):
self
.
counter
=
self
.
counter
+
1
return
self
.
counter
def
__len__
(
self
):
return
len
(
self
.
_lexicon
)
def
Splitter
(
self
,
astring
,
words
):
""" wrap the splitter """
return
Splitter
(
astring
,
words
)
def
grep
(
self
,
query
):
"""
regular expression search through the lexicon
he he.
"""
expr
=
re
.
compile
(
query
)
hits
=
[]
for
x
in
self
.
_lexicon
.
keys
():
if
expr
.
search
(
x
):
hits
.
append
(
x
)
return
hits
def
ngramatize
(
self
,
word
,
word_id
):
""" returns a dictionary of {ngram : word_id} pairs:
"""
ngrams
=
[]
for
x
in
word
:
AndNot
=
'andnot'
And
=
'and'
...
...
@@ -268,8 +292,10 @@ def get_operands(q, i, index, ListType=type([]), StringType=type('')):
return (left, right)
def evaluate(q, index,ListType=type([])):
def evaluate(q, index,
ListType=type([])):
'''Evaluate a parsed query'''
import pdb
pdb.set_trace()
if (len(q) == 1):
if (type(q[0]) is ListType):
...
...
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