コード例 #1
0
 def test_patter_simple(self):
     rules_str = """
     S : NP VP ::
     """
     rule = self.parser.parse_rules(rules_str)[0]
     self.assertEqual(rule.head,
                      RuleParser.PatternToken('S', {'label': {'S'}}))
     self.assertEqual(rule.pattern[0],
                      RuleParser.PatternToken('NP', {'label': {'NP'}}))
     self.assertEqual(rule.pattern[1],
                      RuleParser.PatternToken('VP', {'label': {'VP'}}))
コード例 #2
0
 def test_patter_complex(self):
     rules_str = """
     S[type=animal] : NP[a={c,x}, b=0] VP ::
     """
     rule = self.parser.parse_rules(rules_str)[0]
     self.assertEqual(
         rule.head,
         RuleParser.PatternToken('S', {
             'label': {'S'},
             'type': {'animal'}
         }))
     self.assertEqual(
         rule.pattern[0],
         RuleParser.PatternToken('NP', {
             'label': {'NP'},
             'a': {'c', 'x'},
             'b': {'0'}
         }))
     self.assertEqual(rule.pattern[1],
                      RuleParser.PatternToken('VP', {'label': {'VP'}}))