From 9d1df9ba9ec67f19cff047bfe20b9bcd1ba06dbe Mon Sep 17 00:00:00 2001 From: massongit Date: Sun, 26 Nov 2017 19:15:24 +0900 Subject: [PATCH] Add test --- tests/test_mecab.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test_mecab.py b/tests/test_mecab.py index 061e604..4322597 100644 --- a/tests/test_mecab.py +++ b/tests/test_mecab.py @@ -320,6 +320,18 @@ def test_parse_tonodes_boundary(self): if not node.is_eos(): self.assertEqual(node.feature, expected[i]) + with mecab.MeCab(r'-O "" -F%m\s%s') as nm: + # with empty string option + yml1 = self.yaml.get('text5') + txt1 = self._u2str(yml1.get('text')) + pat1 = self._u2str(yml1.get('pattern')) + expected = [self._u2str(e) for e in yml1.get('expected')] + + gen = nm.parse(txt1, boundary_constraints=pat1, as_nodes=True) + for i, node in enumerate(gen): + if not node.is_eos(): + self.assertEqual(node.feature, expected[i]) + with mecab.MeCab(r'-F%m\s%F\s[0,1]\s%s -N2') as nm: # with N-best and output formatting yml1 = self.yaml.get('text6')