-
Notifications
You must be signed in to change notification settings - Fork 97
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
Recognize "@" in gender-neutral word endings as part of the token #60
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
## Version 2.2 | ||
|
||
## Version 2.1 (2018-06-18) | ||
|
||
Data changes: | ||
|
This file contains 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
This file contains 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
This file contains 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,109 @@ | ||
from wordfreq import tokenize, lossy_tokenize, word_frequency | ||
|
||
|
||
def test_gender_neutral_at(): | ||
# Recognize the gender-neutral @ in Spanish as part of the word | ||
text = "La protección de los derechos de tod@s l@s trabajador@s migrantes" | ||
assert tokenize(text, "es") == [ | ||
"la", | ||
"protección", | ||
"de", | ||
"los", | ||
"derechos", | ||
"de", | ||
"tod@s", | ||
"l@s", | ||
"trabajador@s", | ||
"migrantes" | ||
] | ||
|
||
text = "el distrito 22@ de Barcelona" | ||
assert tokenize(text, 'es') == ["el", "distrito", "22@", "de", "barcelona"] | ||
assert lossy_tokenize(text, 'es') == ["el", "distrito", "00@", "de", "barcelona"] | ||
|
||
# It also appears in Portuguese | ||
text = "direitos e deveres para @s membr@s da comunidade virtual" | ||
assert tokenize(text, "pt") == [ | ||
"direitos", | ||
"e", | ||
"deveres", | ||
"para", | ||
"@s", | ||
"membr@s", | ||
"da", | ||
"comunidade", | ||
"virtual" | ||
] | ||
|
||
# Because this is part of our tokenization, the language code doesn't | ||
# actually matter, as long as it's a language with Unicode tokenization | ||
text = "@s membr@s da comunidade virtual" | ||
assert tokenize(text, "en") == ["@s", "membr@s", "da", "comunidade", "virtual"] | ||
|
||
|
||
def test_at_in_corpus(): | ||
# We have a word frequency for "l@s" | ||
assert word_frequency('l@s', 'es') > 0 | ||
|
||
# It's not just treated as a word break | ||
assert word_frequency('l@s', 'es') < word_frequency('l s', 'es') | ||
|
||
|
||
def test_punctuation_at(): | ||
# If the @ appears alone in a word, we consider it to be punctuation | ||
text = "operadores de canal, que são aqueles que têm um @ ao lado do nick" | ||
assert tokenize(text, "pt") == [ | ||
"operadores", | ||
"de", | ||
"canal", | ||
"que", | ||
"são", | ||
"aqueles", | ||
"que", | ||
"têm", | ||
"um", | ||
"ao", | ||
"lado", | ||
"do", | ||
"nick" | ||
] | ||
|
||
assert tokenize(text, "pt", include_punctuation=True) == [ | ||
"operadores", | ||
"de", | ||
"canal", | ||
",", | ||
"que", | ||
"são", | ||
"aqueles", | ||
"que", | ||
"têm", | ||
"um", | ||
"@", | ||
"ao", | ||
"lado", | ||
"do", | ||
"nick" | ||
] | ||
|
||
# If the @ is not at the end of the word or part of the word ending '@s', | ||
# it is also punctuation | ||
text = "un archivo hosts.deny que contiene la línea ALL:ALL@ALL" | ||
assert tokenize(text, "es") == [ | ||
"un", | ||
"archivo", | ||
"hosts.deny", | ||
"que", | ||
"contiene", | ||
"la", | ||
"línea", | ||
"all:all", | ||
"all" | ||
] | ||
|
||
# Make sure not to catch e-mail addresses | ||
text = "info@something.example" | ||
assert tokenize(text, "en") == [ | ||
"info", | ||
"something.example" | ||
] |
This file contains 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
Oops, something went wrong.
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.
It looks like this section still needs to be written?
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.
Ah yeah. I started thinking I should write it, then changed my mind because I didn't know what date to put on it, and decided I'd write it after the PR was merged. But then I left it like this. I could just write the section and put tomorrow's date on it.