Skip to content

Commit

Permalink
fix tests for new release
Browse files Browse the repository at this point in the history
  • Loading branch information
nournia committed Aug 28, 2014
1 parent 9ce9b58 commit 6454f2a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Python library for digesting Persian text.
>>> from hazm import POSTagger
>>> tagger = POSTagger()
>>> tagger.tag(word_tokenize('ما بسیار کتاب می‌خوانیم'))
[('ما', 'PR'), ('بسیار', 'ADV'), ('کتاب', 'N'), ('می‌خوانیم', 'V')]
[('ما', 'PRO'), ('بسیار', 'ADV'), ('کتاب', 'N'), ('می‌خوانیم', 'V')]

>>> from hazm import DependencyParser
>>> parser = DependencyParser(tagger=POSTagger())
Expand Down
2 changes: 1 addition & 1 deletion data.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def train_maltparser(train_file='resources/train.conll', validation_file='resour
parsed = parser.tagged_parse_sents(tagged)

test_data, test_results = test_file +'.data', test_file +'.results'
print('\n'.join([sentence.to_conll(10) for sentence in test.trees()]).strip(), file=codecs.open(test_data, 'w', 'utf8'))
print('\n'.join([sentence.to_conll(10).replace('/', '') for sentence in test.trees()]).strip(), file=codecs.open(test_data, 'w', 'utf8'))
print('\n'.join([sentence.to_conll(10) for sentence in parsed]).strip(), file=codecs.open(test_results, 'w', 'utf8'))

subprocess.Popen(['java', '-jar', 'resources/MaltEval.jar', '-g', test_data, '-s', test_results]).wait()
2 changes: 1 addition & 1 deletion hazm/POSTagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, *args, **kwargs):
def tag_sents(self, sentences):
"""
>>> tagger.tag(['من', 'به', 'مدرسه', 'رفته بودم', '.'])
[('من', 'PR'), ('به', 'PREP'), ('مدرسه', 'N'), ('رفته بودم', 'V'), ('.', 'PUNC')]
[('من', 'PRO'), ('به', 'P'), ('مدرسه', 'N'), ('رفته بودم', 'V'), ('.', 'PUNC')]
"""

refined = map(lambda s: [w.replace(' ', '_') for w in s], sentences)
Expand Down

0 comments on commit 6454f2a

Please sign in to comment.