Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix segment-wiki script #1694

Merged
merged 8 commits into from
Nov 6, 2017
9 changes: 6 additions & 3 deletions gensim/scripts/segment_wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,13 @@ def get_texts_with_sections(self):
for group in utils.chunkize(page_xmls, chunksize=10 * self.processes, maxsize=1):
for article_title, sections in pool.imap(segment, group): # chunksize=10):
# article redirects are pruned here
if any(article_title.startswith(ignore + ':') for ignore in IGNORED_NAMESPACES) \
or len(sections) == 0 \
or sections[0][1].lstrip().startswith("#REDIRECT"):
if any(article_title.startswith(ignore + ':') for ignore in IGNORED_NAMESPACES): # filter non-articles
continue
if len(sections) == 0 or sections[0][1].lstrip().lower().startswith("#redirect"): # filter redirect
continue
if sum(len(body.strip()) for (_, body) in sections) < 250: # filter very short articles (thrash)
Copy link
Owner

@piskvorky piskvorky Nov 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thrash => trash ; but it's more stubs than trash.

The constant (250) should be configurable (min_article_characters?), not hardwired like this.

continue

articles += 1
yield (article_title, sections)
pool.terminate()
Expand Down