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
fa090d93
Commit
fa090d93
authored
Oct 13, 2009
by
Takeshi Yamamoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merged Zope/branches/tyam-unicodeSplitterPatch 104723:104761
parent
0b7c433b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
1 deletion
+24
-1
src/Products/ZCTextIndex/Lexicon.py
src/Products/ZCTextIndex/Lexicon.py
+2
-1
src/Products/ZCTextIndex/tests/testLexicon.py
src/Products/ZCTextIndex/tests/testLexicon.py
+22
-0
No files found.
src/Products/ZCTextIndex/Lexicon.py
View file @
fa090d93
...
...
@@ -76,7 +76,8 @@ class Lexicon(Persistent):
def
termToWordIds
(
self
,
text
):
last
=
_text2list
(
text
)
for
element
in
self
.
_pipeline
:
last
=
element
.
process
(
last
)
process
=
getattr
(
element
,
"process_post_glob"
,
element
.
process
)
last
=
process
(
last
)
wids
=
[]
for
word
in
last
:
wids
.
append
(
self
.
_wids
.
get
(
word
,
0
))
...
...
src/Products/ZCTextIndex/tests/testLexicon.py
View file @
fa090d93
...
...
@@ -94,6 +94,28 @@ class Test(unittest.TestCase):
wids
=
lexicon
.
termToWordIds
(
'boxes'
)
self
.
assertEqual
(
wids
,
[
0
])
def
testTermToWordIdsWithProcess_post_glob
(
self
):
"""This test is for added process_post_glob"""
class
AddedSplitter
(
Splitter
):
def
process_post_glob
(
self
,
lst
):
assert
lst
==
[
'dogs'
]
return
[
'dogs'
]
lexicon
=
Lexicon
(
AddedSplitter
())
wids
=
lexicon
.
sourceToWordIds
(
'cats and dogs'
)
wids
=
lexicon
.
termToWordIds
(
'dogs'
)
self
.
assertEqual
(
wids
,
[
3
])
def
testMissingTermToWordIdsWithProcess_post_glob
(
self
):
"""This test is for added process_post_glob"""
class
AddedSplitter
(
Splitter
):
def
process_post_glob
(
self
,
lst
):
assert
lst
==
[
'dogs'
]
return
[
'fox'
]
lexicon
=
Lexicon
(
AddedSplitter
())
wids
=
lexicon
.
sourceToWordIds
(
'cats and dogs'
)
wids
=
lexicon
.
termToWordIds
(
'dogs'
)
self
.
assertEqual
(
wids
,
[
0
])
def
testOnePipelineElement
(
self
):
lexicon
=
Lexicon
(
Splitter
(),
StupidPipelineElement
(
'dogs'
,
'fish'
))
wids
=
lexicon
.
sourceToWordIds
(
'cats and dogs'
)
...
...
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