コード例 #1
0
def recogniser():
    """
    Returns the default recogniser, already configured.
    """
    r = RecognitionRuleEngine()
    r.load_rules(os.path.join(os.path.split(__file__)[0], 'rules', 'recognition'))
    return r
コード例 #2
0
 def testBadBlockErrors(self):
     r = RecognitionRuleEngine()
     try:
         r.load_rules(os.path.join(os.path.dirname(__file__), 'test_recognition_rule_blocks_malformed/'))
     except RuleLoadErrors as e:
         self.assertEquals(len(e.errors), 9, "These errors were raised: " + str(e))
     else:
         self.fail('No exceptions were raised/caught')
コード例 #3
0
 def testAfterAndDuplicateIDErrors(self):
     r = RecognitionRuleEngine()
     try:
         r.load_rules(os.path.join(os.path.dirname(__file__), 'test_recognition_rules_after/'))
     except RuleLoadErrors as e:
         self.assertEquals(len(e.errors), 2, "These errors were raised: " + str(e))
     else:
         self.fail('No exceptions were raised/caught')
コード例 #4
0
def recogniser():
    """
    Returns the default recogniser, already configured.
    """
    r = RecognitionRuleEngine()
    r.load_rules(
        os.path.join(os.path.split(__file__)[0], 'rules', 'recognition'))
    return r
コード例 #5
0
 def testBadBlockErrors(self):
     r = RecognitionRuleEngine()
     try:
         r.load_rules(os.path.join(os.path.dirname(__file__), 'test_recognition_rule_blocks_malformed/'))
     except RuleLoadErrors as e:
         self.assertEquals(len(e.errors), 9, "These errors were raised: " + str(e))
     else:
         self.fail('No exceptions were raised/caught')
コード例 #6
0
 def testAfterAndDuplicateIDErrors(self):
     r = RecognitionRuleEngine()
     try:
         r.load_rules(os.path.join(os.path.dirname(__file__), 'test_recognition_rules_after/'))
     except RuleLoadErrors as e:
         self.assertEquals(len(e.errors), 2, "These errors were raised: " + str(e))
     else:
         self.fail('No exceptions were raised/caught')
コード例 #7
0
 def testTag(self):
     e = RecognitionRuleEngine()
     e.load_rules(
         os.path.join(os.path.dirname(__file__), 'test_recognition_rules/'))
     tagged = e.tag([[('We', 'POS', set()), ('went', 'POS', set()),
                      ('shopping', 'POS', set()), ('on', 'POS', set()),
                      ('Friday', 'POS', set())],
                     [('We', 'POS', set()), ('went', 'POS', set()),
                      ('shopping', 'POS', set()), ('last', 'POS', set()),
                      ('Thursday', 'POS', set())]])
     self.assertEqual([[len(s[2]) for s in sent] for sent in tagged],
                      [[0, 0, 0, 0, 1], [0, 0, 0, 0, 0]],
                      'actual result was ' + str([[len(s[2]) for s in sent]
                                                  for sent in tagged]))
コード例 #8
0
 def testTag(self):
     e = RecognitionRuleEngine()
     e.load_rules(os.path.join(os.path.dirname(__file__), 'test_recognition_rules/'))
     tagged = e.tag([[('We', 'POS', set()), ('went', 'POS', set()), ('shopping', 'POS', set()), ('on', 'POS', set()), ('Friday', 'POS', set())],
                     [('We', 'POS', set()), ('went', 'POS', set()), ('shopping', 'POS', set()), ('last', 'POS', set()), ('Thursday', 'POS', set())]])
     self.assertEquals([[len(s[2]) for s in sent] for sent in tagged], [[0,0,0,0,1],[0,0,0,0,0]], 'actual result was '+str([[len(s[2]) for s in sent] for sent in tagged]))