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
import
re
class
HTMLSplitter
:
__implements__
=
ISplitter
def
process
(
self
,
text
):
return
re
.
sub
(
'<[^>]*>'
,
' '
,
text
).
split
()
class
HTMLWordSplitter
:
__implements__
=
ISplitter
def
process
(
self
,
text
):
def
process
(
self
,
text
,
wordpat
=
r"\
w+
"
):
splat = []
for t in text:
splat
+=
self
.
_split
(
t
)
splat += self._split(t
, wordpat
)
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()
remove
=
[
"<[^>]*>"
,
"&[A-Za-z]+;"
,
"
\
W+
"
]
remove = [r"
<
[
^<>
]
*>
",
r"
&
[
A
-
Za
-
z
]
+
;
"]
for pat in remove:
text = re.sub(pat, "
", text)
rx = re.compile("
[
A
-
Za
-
z
]
")
return [word for word in text.split()
if len(word) > 1 and rx.search(word)]
return re.findall(wordpat, text)
element_factory.registerFactory('Word 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