Skip to content

Commit

Permalink
fix white space bug in nagisa.decode
Browse files Browse the repository at this point in the history
  • Loading branch information
taishi-i committed Dec 30, 2019
1 parent 29e93c6 commit 6897b07
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion nagisa/tagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def decode(self, words, lower=False):
"""
if not type(words) == list:
raise AssertionError("Please input a list of words.")
words = [utils.preprocess(w) for w in words]
words = [" " if w == " " or w == " " else utils.preprocess(w) for w in words]
postags = self._postagging(words, lower)
return postags

Expand Down
26 changes: 24 additions & 2 deletions test/nagisa_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,39 @@ def test_tagging(self):
postags = nagisa.decode(words)
self.assertEqual(output, postags)

# test_13
words = [" (人•ᴗ•♡)", " ", "こんばんは","♪"]
output = ['補助記号', "空白", '感動詞', '補助記号']
postags = nagisa.postagging(words)

self.assertEqual(output, postags)

# test_14
postags = nagisa.decode(words)
self.assertEqual(output, postags)

# test_15
words = [" (人•ᴗ•♡)", " ", "こんばんは","♪"]
output = ['補助記号', "空白", '感動詞', '補助記号']
postags = nagisa.postagging(words)

self.assertEqual(output, postags)

# test_16
postags = nagisa.decode(words)
self.assertEqual(output, postags)


def test_fit(self):
# test_13
# test_17
nagisa.fit(
train_file="nagisa/data/sample_datasets/sample.train",
dev_file="nagisa/data/sample_datasets/sample.dev",
test_file="nagisa/data/sample_datasets/sample.test",
model_name="sample",
)

# test_14
# test_18
nagisa.fit(
train_file="nagisa/data/sample_datasets/sample.train",
dev_file="nagisa/data/sample_datasets/sample.dev",
Expand Down

0 comments on commit 6897b07

Please sign in to comment.