Exemplo n.º 1
0
 def test_find_wrong_pattern(self):
     with self.assertRaises(PatternSyntaxException):
         match_tree(_sentence, "*//[]")
Exemplo n.º 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"))
Exemplo n.º 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"))
Exemplo n.º 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/*"))
Exemplo n.º 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/**/*"))
Exemplo n.º 6
0
 def test_not_match_simple_patterns(self):
     self.assertFalse(match_tree(_sentence, "VBD/prep/IN/pobj/VBD"))
Exemplo n.º 7
0
 def test_match_simple_patterns(self):
     self.assertTrue(match_tree(_sentence, "VBD/prep/IN/pobj/NNP"))
Exemplo n.º 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 []