-
Notifications
You must be signed in to change notification settings - Fork 59
Letter-precise html tokenization #49
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
36d56f2
text tokenizer return postions of token
whalebot-helmsman 2d4d2ef
update tests
whalebot-helmsman 80658ca
separate statement for every action
whalebot-helmsman c52e449
comma preserving test
whalebot-helmsman 8178776
too much tokens around
whalebot-helmsman 51c0932
encode in indices instead of entities
whalebot-helmsman 1a667ec
handle empty lists
whalebot-helmsman 24465b1
pass token length and position from TextToken to HtmlToken
whalebot-helmsman 06befbb
letter perfect detokenization
whalebot-helmsman e5730b2
do not cleanup tokenized tree by default, separate method for tree cl…
e340444
update tests for separate tree cleaning
89673c1
update tests for correct punctuation positions
7c45984
correct length for replaced quotes
46fc4df
pep8
388170e
comma at line end, not start
71caf61
one join instead of many additions, dont be Schleimel
37d7470
correct formatting
e93c6dc
add clarification
e02c275
fix typo
f26569f
pep8
d1aecbb
preserve tokenize method for compatibility
35a9d88
function to reduce code in tests
9033188
remove test for nltk tokenizer
c14f363
test our behaviour, which difers from original treebank tokenizer
a071cd4
remove useless conversion
a33f564
rename method to avoid confusion with nltk tokenize_span method
75a9698
remove brittle tests
4729323
small benchmark for html tokenizer
943a44e
Revert "remove brittle tests"
whalebot-helmsman ba7d6fe
move brittle tests to pytest xfail
whalebot-helmsman b72bcc1
expect behaviour of nltk tokenizer
whalebot-helmsman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import unittest | ||
| import pytest | ||
|
|
||
| from webstruct.text_tokenizers import TextToken, WordTokenizer | ||
|
|
||
| class TestTokenizerTest(unittest.TestCase): | ||
| def do_tokenize(self, text, result): | ||
| self.assertEqual(result, WordTokenizer().segment_words(text)) | ||
|
|
||
| @pytest.mark.xfail | ||
| def test_phone(self): | ||
| return self.do_tokenize( | ||
| "Phone:855-349-1914", | ||
| [TextToken(chars='Phone:855-349-1914', position=0, length=18)] | ||
| ) | ||
|
|
||
| @pytest.mark.xfail | ||
| def test_hyphen_mid(self): | ||
| return self.do_tokenize( | ||
| "Powai Campus, Mumbai-400077", | ||
| [TextToken(chars='Powai', position=0, length=5), | ||
| TextToken(chars='Campus', position=6, length=6), | ||
| TextToken(chars=',', position=12, length=1), | ||
| TextToken(chars='Mumbai-400077', position=14, length=13)] | ||
| ) | ||
|
|
||
| @pytest.mark.xfail | ||
| def test_hyphen_end(self): | ||
| return self.do_tokenize( | ||
| "Saudi Arabia-", | ||
| [TextToken(chars='Saudi', position=0, length=5), | ||
| TextToken(chars='Arabia-', position=6, length=7)] | ||
| ) | ||
|
|
||
| @pytest.mark.xfail | ||
| def test_hyphen_end(self): | ||
| return self.do_tokenize( | ||
| "1 5858/ 1800", | ||
| [TextToken(chars='1', position=0, length=1), | ||
| TextToken(chars='5858/', position=2, length=5), | ||
| TextToken(chars='1800', position=8, length=4)] | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the output we're expecting, phone should be separated (like it was in old doctests)