Esempio n. 1
0
File: main.py Progetto: dim-an/gnTai
def loop(options):
    understander = Understander(options.dictionary_path)
    try:
        while True:
            text = raw_input("Write a simple sentence (write ':q' to quit): ")
            if text == '':
                continue
            if text == ':q':
                break
            try:
                thought = understander.understand(text)
                print "My statement: ", ThoughtImplementation(thought.set_question(False))
                print "My question   : ", ThoughtImplementation(thought.set_question(True))
            except AIException, e:
                print 'Error: ', str(e).decode('utf-8')
    except EOFError:
        print "\nGoodbye!"
    except KeyboardInterrupt:
        print "\nGoodbye!"
Esempio n. 2
0
class AllTest(unittest.TestCase):
    def setUp(self):
        self.understander = Understander(DICTIONARY_TEST_PATH)

    def test_side_effects(self):
        texts = ["A man is not a woman.",
                 "A man works.",
                 "Diman is not a fruit kind.",
                 "An apple is a fruit.",
                 "Diman's works exist."]
        for text in texts:
            thought = self.understander.understand(text)
            self.assertEqual(text, str(ThoughtImplementation(thought)))
Esempio n. 3
0
 def setUp(self):
     self.understander = Understander(DICTIONARY_TEST_PATH)