Skip to content

Commit

Permalink
tests TextModel
Browse files Browse the repository at this point in the history
  • Loading branch information
mgraffg committed Jun 2, 2016
1 parent c3150ff commit 69855af
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
9 changes: 9 additions & 0 deletions b4msa/tests/test_texmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,12 @@ def test_tweet_iterator():
for a0, b0 in zip(a, b):
assert a0['text'] == b0['text']
os.unlink(fname_gz)


def text_texmodel():
from b4msa.textmodel import TextModel, tweet_iterator
import os
fname = os.path.dirname(__file__) + '/text.json'
tw = [x for x in tweet_iterator(fname)]
text = TextModel([x['text'] for x in tw])
assert isinstance(text[tw[0]['text']], list)
2 changes: 1 addition & 1 deletion b4msa/tests/text.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{"text": "buenos dias b4msa", "klass": "POS"}
{"text": "buenos dia b4msa", "klass": "POS"}
{"text": "las vascas me deprimen", "klass": "NEG"}
{"text": "excelente dia", "klass": "POS"}
{"text": "la computadora", "klass": "NEU"}
4 changes: 2 additions & 2 deletions b4msa/textmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def expand_qgrams(text, qsize, output):
OPTION_GROUP = 'group'
OPTION_DELETE = 'delete'


class TextModel:
def __init__(self,
docs,
Expand All @@ -98,8 +99,7 @@ def __init__(self,
url_option=OPTION_GROUP,
lc=True,
token_list=[1, 2, 3, 4, 5, 6, 7],
language_dependent=[]
):
language_dependent=[]):
self.strip_diac = strip_diac
self.usr_option = usr_option
self.url_option = url_option
Expand Down

0 comments on commit 69855af

Please sign in to comment.