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

Allow word tokenization override #27

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

freecraver
Copy link

See #26 (comment)

Introduces a non-breaking change which allows to override custom word-level tokenization.

The new f_tokenize_words argument accepts a function which maps a text to its words.

example:

from nltk import word_tokenize
r = Readability(text, f_tokenize_words=word_tokenize)

Tests run ✔️
Tests added ✔️
Added section 'What makes a word' to Readme ✔️

Additional remarks:

  • The main difference between nltks TweetTokenizer and the TreebankWordTokenizer I observed is the handling of clitics and abbreviations:
Text Tweet Treebank
"We've got two different solutions" ["We've", 'got', 'two', 'different', 'solutions'] ['We', "'ve", 'got', 'two', 'different', 'solutions']
'How common are abbreviations in the U.S.?' ['How', 'common', 'are', 'abbreviations', 'in', 'the', 'U', '.', 'S', '.', '?'] ['How', 'common', 'are', 'abbreviations', 'in', 'the', 'U.S.', '?']

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant