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
b3cb1b87
Commit
b3cb1b87
authored
May 14, 2002
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Coding convention update: avoid use of "__" prefix for instance vars.
parent
9db492f1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
21 deletions
+21
-21
lib/python/Products/ZCTextIndex/Lexicon.py
lib/python/Products/ZCTextIndex/Lexicon.py
+21
-21
No files found.
lib/python/Products/ZCTextIndex/Lexicon.py
View file @
b3cb1b87
...
@@ -24,45 +24,45 @@ class Lexicon:
...
@@ -24,45 +24,45 @@ class Lexicon:
__implements__
=
ILexicon
__implements__
=
ILexicon
def
__init__
(
self
,
*
pipeline
):
def
__init__
(
self
,
*
pipeline
):
self
.
_
_
wids
=
OIBTree
()
# word -> wid
self
.
_wids
=
OIBTree
()
# word -> wid
self
.
_
_
words
=
IOBTree
()
# wid -> word
self
.
_words
=
IOBTree
()
# wid -> word
# XXX we're reserving wid 0, but that might be yagni
# XXX we're reserving wid 0, but that might be yagni
self
.
_
_
nextwid
=
1
self
.
_nextwid
=
1
self
.
_
_
pipeline
=
pipeline
self
.
_pipeline
=
pipeline
def
length
(
self
):
def
length
(
self
):
"""Return the number of unique terms in the lexicon."""
"""Return the number of unique terms in the lexicon."""
return
self
.
_
_
nextwid
-
1
return
self
.
_nextwid
-
1
def
words
(
self
):
def
words
(
self
):
return
self
.
_
_
wids
.
keys
()
return
self
.
_wids
.
keys
()
def
wids
(
self
):
def
wids
(
self
):
return
self
.
_
_
words
.
keys
()
return
self
.
_words
.
keys
()
def
items
(
self
):
def
items
(
self
):
return
self
.
_
_
wids
.
items
()
return
self
.
_wids
.
items
()
def
sourceToWordIds
(
self
,
text
):
def
sourceToWordIds
(
self
,
text
):
last
=
_text2list
(
text
)
last
=
_text2list
(
text
)
for
element
in
self
.
_
_
pipeline
:
for
element
in
self
.
_pipeline
:
last
=
element
.
process
(
last
)
last
=
element
.
process
(
last
)
return
map
(
self
.
_getWordIdCreate
,
last
)
return
map
(
self
.
_getWordIdCreate
,
last
)
def
termToWordIds
(
self
,
text
):
def
termToWordIds
(
self
,
text
):
last
=
_text2list
(
text
)
last
=
_text2list
(
text
)
for
element
in
self
.
_
_
pipeline
:
for
element
in
self
.
_pipeline
:
last
=
element
.
process
(
last
)
last
=
element
.
process
(
last
)
wids
=
[]
wids
=
[]
for
word
in
last
:
for
word
in
last
:
wid
=
self
.
_
_
wids
.
get
(
word
)
wid
=
self
.
_wids
.
get
(
word
)
if
wid
is
not
None
:
if
wid
is
not
None
:
wids
.
append
(
wid
)
wids
.
append
(
wid
)
return
wids
return
wids
def
get_word
(
self
,
wid
):
def
get_word
(
self
,
wid
):
"""Return the word for the given word id"""
"""Return the word for the given word id"""
return
self
.
_
_
words
[
wid
]
return
self
.
_words
[
wid
]
def
globToWordIds
(
self
,
pattern
):
def
globToWordIds
(
self
,
pattern
):
if
not
re
.
match
(
"^
\
w+
\
*$"
,
pattern
):
if
not
re
.
match
(
"^
\
w+
\
*$"
,
pattern
):
...
@@ -71,27 +71,27 @@ class Lexicon:
...
@@ -71,27 +71,27 @@ class Lexicon:
assert
pattern
.
endswith
(
"*"
)
assert
pattern
.
endswith
(
"*"
)
prefix
=
pattern
[:
-
1
]
prefix
=
pattern
[:
-
1
]
assert
prefix
and
not
prefix
.
endswith
(
"*"
)
assert
prefix
and
not
prefix
.
endswith
(
"*"
)
keys
=
self
.
_
_
wids
.
keys
(
prefix
)
# Keys starting at prefix
keys
=
self
.
_wids
.
keys
(
prefix
)
# Keys starting at prefix
wids
=
[]
wids
=
[]
words
=
[]
words
=
[]
for
key
in
keys
:
for
key
in
keys
:
if
not
key
.
startswith
(
prefix
):
if
not
key
.
startswith
(
prefix
):
break
break
wids
.
append
(
self
.
_
_
wids
[
key
])
wids
.
append
(
self
.
_wids
[
key
])
words
.
append
(
key
)
words
.
append
(
key
)
return
wids
return
wids
def
_getWordIdCreate
(
self
,
word
):
def
_getWordIdCreate
(
self
,
word
):
wid
=
self
.
_
_
wids
.
get
(
word
)
wid
=
self
.
_wids
.
get
(
word
)
if
wid
is
None
:
if
wid
is
None
:
wid
=
self
.
_
_
new_wid
()
wid
=
self
.
_new_wid
()
self
.
_
_
wids
[
word
]
=
wid
self
.
_wids
[
word
]
=
wid
self
.
_
_
words
[
wid
]
=
word
self
.
_words
[
wid
]
=
word
return
wid
return
wid
def
_
_
new_wid
(
self
):
def
_new_wid
(
self
):
wid
=
self
.
_
_
nextwid
wid
=
self
.
_nextwid
self
.
_
_
nextwid
+=
1
self
.
_nextwid
+=
1
return
wid
return
wid
def
_text2list
(
text
):
def
_text2list
(
text
):
...
...
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