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
bad257b8
Commit
bad257b8
authored
May 17, 2002
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a little splitter that behaves pretty much like HTMLWordSplitter,
but works with a TextIndex Lexicon.
parent
81682acc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
2 deletions
+18
-2
lib/python/Products/ZCTextIndex/tests/indexhtml.py
lib/python/Products/ZCTextIndex/tests/indexhtml.py
+18
-2
No files found.
lib/python/Products/ZCTextIndex/tests/indexhtml.py
View file @
bad257b8
#! /usr/bin/env python
"""Index a collection of HTML files on the filesystem.
usage: indexhtml.py [options] dir
...
...
@@ -9,6 +8,7 @@ Will create an index of all files in dir or its subdirectories.
options:
-f data.fs -- the path to the filestorage datafile
"""
from
__future__
import
nested_scopes
import
os
from
time
import
clock
...
...
@@ -32,12 +32,28 @@ def make_zc_index():
caller
.
lexicon
=
Lexicon
(
HTMLWordSplitter
(),
StopWordRemover
())
return
ZCTextIndex
(
"read"
,
extra
,
caller
)
# XXX make a splitter more like the HTMLSplitter for TextIndex
# signature is
# Splitter(string, stop_words, encoding,
# singlechar, indexnumbers, casefolding)
class
MySplitter
:
def
__init__
(
self
):
self
.
_v_splitter
=
HTMLWordSplitter
()
def
__call__
(
self
,
text
,
stopdict
,
*
args
,
**
kwargs
):
words
=
self
.
_v_splitter
.
_split
(
text
)
def
lookup
(
w
):
return
stopdict
.
get
(
w
,
w
)
return
filter
(
None
,
map
(
lookup
,
words
))
def
make_old_index
():
from
Products.PluginIndexes.TextIndex.TextIndex
import
TextIndex
from
Products.PluginIndexes.TextIndex.Lexicon
\
import
Lexicon
,
stop_word_dict
return
TextIndex
(
"read"
,
lexicon
=
Lexicon
(
stop_word_dict
))
l
=
Lexicon
(
stop_word_dict
)
l
.
SplitterFunc
=
MySplitter
()
return
TextIndex
(
"read"
,
lexicon
=
l
)
def
main
(
db
,
root
,
dir
):
rt
[
"index"
]
=
index
=
INDEX
()
...
...
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