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
a8226c4e
Commit
a8226c4e
authored
May 22, 2002
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get rid of the unused HTMLSplitter class (it's too simple).
Add glob support to the HTMLWordSplitter class.
parent
fbd41e2f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
16 deletions
+9
-16
lib/python/Products/ZCTextIndex/HTMLSplitter.py
lib/python/Products/ZCTextIndex/HTMLSplitter.py
+9
-16
No files found.
lib/python/Products/ZCTextIndex/HTMLSplitter.py
View file @
a8226c4e
...
@@ -17,33 +17,26 @@ from Products.ZCTextIndex.PipelineFactory import element_factory
...
@@ -17,33 +17,26 @@ from Products.ZCTextIndex.PipelineFactory import element_factory
import
re
import
re
class
HTMLSplitter
:
__implements__
=
ISplitter
def
process
(
self
,
text
):
return
re
.
sub
(
'<[^>]*>'
,
' '
,
text
).
split
()
class
HTMLWordSplitter
:
class
HTMLWordSplitter
:
__implements__
=
ISplitter
__implements__
=
ISplitter
def
process
(
self
,
text
):
def
process
(
self
,
text
,
wordpat
=
r"\
w+
"
):
splat = []
splat = []
for t in text:
for t in text:
splat
+=
self
.
_split
(
t
)
splat += self._split(t
, wordpat
)
return splat
return splat
def
_split
(
self
,
text
):
def processGlob(self, text):
return self.process(text, r"
\
w
+
[
\
w
*
?
]
*
") # see Lexicon.globToWordIds()
def _split(self, text, wordpat):
text = text.lower()
text = text.lower()
remove
=
[
"<[^>]*>"
,
remove = [r"
<
[
^<>
]
*>
",
"&[A-Za-z]+;"
,
r"
&
[
A
-
Za
-
z
]
+
;
"]
"
\
W+
"
]
for pat in remove:
for pat in remove:
text = re.sub(pat, "
", text)
text = re.sub(pat, "
", text)
rx = re.compile("
[
A
-
Za
-
z
]
")
return re.findall(wordpat, text)
return [word for word in text.split()
if len(word) > 1 and rx.search(word)]
element_factory.registerFactory('Word Splitter',
element_factory.registerFactory('Word Splitter',
'HTML aware splitter',
'HTML aware splitter',
...
...
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