Пример #1
0
 def test_find_wrong_pattern(self):
     with self.assertRaises(PatternSyntaxException):
         match_tree(_sentence, "*//[]")
Пример #2
0
 def test_match_with_lists(self):
     self.assertTrue(match_tree(_sentence, "VBD/prep/IN/*/[NNP,DT]"))
     self.assertTrue(match_tree(_sentence, "VBD/prep/IN/[pobj,prep,*]/NNP"))
Пример #3
0
 def test_not_match_with_lists(self):
     self.assertFalse(match_tree(_sentence, "VBD/prep/IN/pobj/[IN,DT]"))
     self.assertFalse(match_tree(_sentence, "VBD/**/IN/[pobj,prep]/DT"))
Пример #4
0
 def test_not_match_pattern_with_stars(self):
     self.assertFalse(match_tree(_sentence, "VBD/*/DT/pobj/*"))
     self.assertFalse(match_tree(_sentence, "VBD/**/DT/pobj/*"))
Пример #5
0
 def test_match_pattern_with_stars(self):
     self.assertTrue(match_tree(_sentence, "VBD/prep/IN/pobj/*"))
     self.assertTrue(match_tree(_sentence, "VBD/prep/*/pobj/NNP"))
     self.assertTrue(match_tree(_sentence, "VBD/**/DT"))
     self.assertTrue(match_tree(_sentence, "VBD/**/*"))
Пример #6
0
 def test_not_match_simple_patterns(self):
     self.assertFalse(match_tree(_sentence, "VBD/prep/IN/pobj/VBD"))
Пример #7
0
 def test_match_simple_patterns(self):
     self.assertTrue(match_tree(_sentence, "VBD/prep/IN/pobj/NNP"))
Пример #8
0
 def process(self, context, passed_tokens=None):
     return \
         find_tokens(context.current_sent(), self._pattern) \
         if not self._precondition or match_tree(context.current_sent(), self._precondition) else []