def testDeliminateNumbers5(self):
     rule = RecognitionRule(r'NUM_START<two~.+><hundred~.+><and~.+><sixty~.+><eight~.+>NUM_END', 'date', 'test', deliminate_numbers=True)
     (sent, success) = rule.apply([('these', 'POS', set()), ('are', 'POS', set()), ('the', 'POS', set()),
                                   ('first', 'POS', set()), ('two', 'POS', set()), ('hundred', 'POS', set()),
                                   ('and', 'POS', set()), ('sixty', 'POS', set()), ('eight', 'POS', set()),
                                   ('balloons', 'POS', set())])
     self.assertTrue(success)
 def testMatchCaseSensitive1(self):
     rule = RecognitionRule(r'<wednesday~.+>', 'date', 'test', case_sensitive=True)
     (sent, success) = rule.apply([('the', 'POS', set()),
                        ('plane', 'POS', set()),
                        ('leaves', 'POS', set()),
                        ('on', 'POS', set()),
                        ('Wednesday', 'POS', set())])
     self.assertEquals([len(s[2]) for s in sent], [0,0,0,0,0], 'actual result was '+str(sent))
     self.assertFalse(success)
 def testMatch(self):
     rule = RecognitionRule(r'<Friday~.+>', 'date', 'test')
     (sent, success) = rule.apply([('the', 'POS', set()),
                        ('plane', 'POS', set()),
                        ('leaves', 'POS', set()),
                        ('on', 'POS', set()),
                        ('Friday', 'POS', set())])
     self.assertEquals([len(s[2]) for s in sent], [0,0,0,0,1], 'actual result was '+str(sent))
     self.assertTrue(success)
 def testPosBefore1(self):
     rule = RecognitionRule(r'<Friday~.+>', 'date', 'test',
                             before_guards=[r'<last~.+>$'])
     (sent, success) = rule.apply([('the', 'POS', set()),
                        ('plane', 'POS', set()),
                        ('left', 'POS', set()),
                        ('last', 'POS', set()),
                        ('Friday', 'POS', set())])
     self.assertEquals([len(s[2]) for s in sent], [0,0,0,0,1], 'actual result was '+str(sent))
     self.assertTrue(success)
Exemple #5
0
 def testMatch(self):
     rule = RecognitionRule(r'<Friday~.+>', 'date', 'test')
     (sent, success) = rule.apply([('the', 'POS', set()),
                                   ('plane', 'POS', set()),
                                   ('leaves', 'POS', set()),
                                   ('on', 'POS', set()),
                                   ('Friday', 'POS', set())])
     self.assertEquals([len(s[2]) for s in sent], [0, 0, 0, 0, 1],
                       'actual result was ' + str(sent))
     self.assertTrue(success)
Exemple #6
0
 def testDeliminateNumbers2(self):
     rule = RecognitionRule(r'NUM_START<twenty-one~.+>NUM_END',
                            'date',
                            'test',
                            deliminate_numbers=True)
     (sent, success) = rule.apply([('there', 'POS', set()),
                                   ('are', 'POS', set()),
                                   ('twenty-one', 'POS', set()),
                                   ('balloons', 'POS', set())])
     self.assertTrue(success)
 def testNegGuard1(self):
     rule = RecognitionRule(r'<Friday~.+>', 'date', 'test',
                             guards=[r'!<plane~.+>'])
     (sent, success) = rule.apply([('the', 'POS', set()),
                        ('plane', 'POS', set()),
                        ('leaves', 'POS', set()),
                        ('on', 'POS', set()),
                        ('Friday', 'POS', set())])
     self.assertEquals([len(s[2]) for s in sent], [0,0,0,0,0], 'actual result was '+str(sent))
     self.assertFalse(success)
 def testPosAfter1(self):
     rule = RecognitionRule(r'<Friday~.+>', 'date', 'test',
                             after_guards=[r'^<for~.+>'])
     (sent, success) = rule.apply([('the', 'POS', set()),
                        ('plane', 'POS', set()),
                        ('leaves', 'POS', set()),
                        ('on', 'POS', set()),
                        ('Friday', 'POS', set()),
                        ('for', 'POS', set()),
                        ('Atlanta', 'POS', set())])
     self.assertEquals([len(s[2]) for s in sent], [0,0,0,0,1,0,0], 'actual result was '+str(sent))
     self.assertTrue(success)
Exemple #9
0
 def testMatchCaseSensitive1(self):
     rule = RecognitionRule(r'<wednesday~.+>',
                            'date',
                            'test',
                            case_sensitive=True)
     (sent, success) = rule.apply([('the', 'POS', set()),
                                   ('plane', 'POS', set()),
                                   ('leaves', 'POS', set()),
                                   ('on', 'POS', set()),
                                   ('Wednesday', 'POS', set())])
     self.assertEquals([len(s[2]) for s in sent], [0, 0, 0, 0, 0],
                       'actual result was ' + str(sent))
     self.assertFalse(success)
Exemple #10
0
 def testNegGuard1(self):
     rule = RecognitionRule(r'<Friday~.+>',
                            'date',
                            'test',
                            guards=[r'!<plane~.+>'])
     (sent, success) = rule.apply([('the', 'POS', set()),
                                   ('plane', 'POS', set()),
                                   ('leaves', 'POS', set()),
                                   ('on', 'POS', set()),
                                   ('Friday', 'POS', set())])
     self.assertEquals([len(s[2]) for s in sent], [0, 0, 0, 0, 0],
                       'actual result was ' + str(sent))
     self.assertFalse(success)
Exemple #11
0
 def testDeliminateNumbers4(self):
     rule = RecognitionRule(
         r'NUM_ORD_START<first~.+>NUM_ORD_ENDNUM_START<two~.+>NUM_END',
         'date',
         'test',
         deliminate_numbers=True)
     (sent, success) = rule.apply([('these', 'POS', set()),
                                   ('are', 'POS', set()),
                                   ('the', 'POS', set()),
                                   ('first', 'POS', set()),
                                   ('two', 'POS', set()),
                                   ('balloons', 'POS', set())])
     self.assertTrue(success)
Exemple #12
0
 def testPosBefore1(self):
     rule = RecognitionRule(r'<Friday~.+>',
                            'date',
                            'test',
                            before_guards=[r'<last~.+>$'])
     (sent, success) = rule.apply([('the', 'POS', set()),
                                   ('plane', 'POS', set()),
                                   ('left', 'POS', set()),
                                   ('last', 'POS', set()),
                                   ('Friday', 'POS', set())])
     self.assertEquals([len(s[2]) for s in sent], [0, 0, 0, 0, 1],
                       'actual result was ' + str(sent))
     self.assertTrue(success)
 def testMatchMultiMiddle(self):
     rule = RecognitionRule(r'<Friday~.+><afternoon~.+>', 'time', 'test')
     (sent, success) = rule.apply([('the', 'POS', set()),
                        ('plane', 'POS', set()),
                        ('leaves', 'POS', set()),
                        ('on', 'POS', set()),
                        ('Friday', 'POS', set()),
                        ('afternoon', 'POS', set()),
                        ('for', 'POS', set()),
                        ('Atlanta', 'POS', set())])
     self.assertEquals([len(s[2]) for s in sent], [0,0,0,0,1,1,0,0], 'actual result was '+str(sent))
     self.assertEquals(sent[4][2], sent[5][2])
     self.assertTrue(success)
Exemple #14
0
 def testMatchMultiMiddle(self):
     rule = RecognitionRule(r'<Friday~.+><afternoon~.+>', 'time', 'test')
     (sent, success) = rule.apply([('the', 'POS', set()),
                                   ('plane', 'POS', set()),
                                   ('leaves', 'POS', set()),
                                   ('on', 'POS', set()),
                                   ('Friday', 'POS', set()),
                                   ('afternoon', 'POS', set()),
                                   ('for', 'POS', set()),
                                   ('Atlanta', 'POS', set())])
     self.assertEquals([len(s[2]) for s in sent], [0, 0, 0, 0, 1, 1, 0, 0],
                       'actual result was ' + str(sent))
     self.assertEquals(sent[4][2], sent[5][2])
     self.assertTrue(success)
Exemple #15
0
 def testPosAfter1(self):
     rule = RecognitionRule(r'<Friday~.+>',
                            'date',
                            'test',
                            after_guards=[r'^<for~.+>'])
     (sent, success) = rule.apply([('the', 'POS', set()),
                                   ('plane', 'POS', set()),
                                   ('leaves', 'POS', set()),
                                   ('on', 'POS', set()),
                                   ('Friday', 'POS', set()),
                                   ('for', 'POS', set()),
                                   ('Atlanta', 'POS', set())])
     self.assertEquals([len(s[2]) for s in sent], [0, 0, 0, 0, 1, 0, 0],
                       'actual result was ' + str(sent))
     self.assertTrue(success)
Exemple #16
0
 def testDeliminateNumbers5(self):
     rule = RecognitionRule(
         r'NUM_START<two~.+><hundred~.+><and~.+><sixty~.+><eight~.+>NUM_END',
         'date',
         'test',
         deliminate_numbers=True)
     (sent, success) = rule.apply([('these', 'POS', set()),
                                   ('are', 'POS', set()),
                                   ('the', 'POS', set()),
                                   ('first', 'POS', set()),
                                   ('two', 'POS', set()),
                                   ('hundred', 'POS', set()),
                                   ('and', 'POS', set()),
                                   ('sixty', 'POS', set()),
                                   ('eight', 'POS', set()),
                                   ('balloons', 'POS', set())])
     self.assertTrue(success)
 def testDeliminateNumbers4(self):
     rule = RecognitionRule(r'NUM_ORD_START<first~.+>NUM_ORD_ENDNUM_START<two~.+>NUM_END', 'date', 'test', deliminate_numbers=True)
     (sent, success) = rule.apply([('these', 'POS', set()), ('are', 'POS', set()), ('the', 'POS', set()), ('first', 'POS', set()), ('two', 'POS', set()), ('balloons', 'POS', set())])
     self.assertTrue(success)
 def testDeliminateNumbers2(self):
     rule = RecognitionRule(r'NUM_START<twenty-one~.+>NUM_END', 'date', 'test', deliminate_numbers=True)
     (sent, success) = rule.apply([('there', 'POS', set()), ('are', 'POS', set()), ('twenty-one', 'POS', set()), ('balloons', 'POS', set())])
     self.assertTrue(success)