-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from aryamccarthy/master
unittests, code formatting with black, and Type inclusion
- Loading branch information
Showing
6 changed files
with
121 additions
and
58 deletions.
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
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,5 +1,3 @@ | ||
|
||
from .tweet_utils import TweetReader | ||
from .tweet_utils import TweetWriter | ||
from .tweet_tokenizer import TweetTokenizer | ||
|
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
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,58 @@ | ||
#!/usr/bin/env python3 | ||
""" | ||
Tests for littlebird/tweet_tokenizer.py | ||
""" | ||
import unittest | ||
from typing import List | ||
|
||
import littlebird | ||
from littlebird import TweetTokenizer | ||
|
||
|
||
class TestTweetTokenizer(unittest.TestCase): | ||
def test_default_tokenize(self): | ||
tokenizer = TweetTokenizer() | ||
tweet: str = ( | ||
"Me: I think I have Ebola " | ||
"Doctor: when did you start feel" | ||
"ing symptoms Me: bout a w" | ||
"eek ago Everyone in hospi" | ||
"tal: http://t.co/LoIPKzvOmT" | ||
) | ||
tokenized = tokenizer.tokenize(tweet) | ||
right_answer: List[str] = [ | ||
"me", | ||
"i", | ||
"think", | ||
"i", | ||
"have", | ||
"ebola", | ||
"doctor", | ||
"when", | ||
"did", | ||
"you", | ||
"start", | ||
"feeling", | ||
"symptoms", | ||
"me", | ||
"bout", | ||
"a", | ||
"week", | ||
"ago", | ||
"everyone", | ||
"in", | ||
"hospital", | ||
] | ||
self.assertListEqual(tokenized, right_answer) | ||
|
||
def test_supported_langs(self): | ||
with self.assertRaises(littlebird.tweet_tokenizer.LanguageNotSupportedError): | ||
tokenizer = TweetTokenizer(language="zxx") | ||
with self.assertRaises(littlebird.tweet_tokenizer.LanguageNotSupportedError): | ||
tokenizer = TweetTokenizer(language="es") | ||
with self.assertRaises(littlebird.tweet_tokenizer.LanguageNotSupportedError): | ||
tokenizer = TweetTokenizer(language="english") | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |