コード例 #1
0
    def setUp(self):
        self.dialog = Dialog()
        self.dialog.start()

        self.oro = ResourcePool().ontology_server

        try:
            self.oro.reload()
            self.oro.add([
                'shelf1 rdf:type Shelf', 'table1 rdf:type Table',
                'table2 rdf:type Table', 'table2 hasColor blue',
                'Banana rdfs:subClassOf Plant', 'y_banana rdf:type Banana',
                'y_banana hasColor yellow', 'y_banana isOn shelf1',
                'green_banana rdf:type Banana', 'green_banana hasColor green',
                'green_banana isOn table2', 'ACCESSKIT rdf:type Gamebox',
                'ACCESSKIT hasColor white', 'ACCESSKIT hasSize big',
                'ACCESSKIT isOn table1', 'ORANGEBOX rdf:type Gamebox',
                'ORANGEBOX hasColor orange', 'ORANGEBOX hasSize big',
                'ORANGEBOX isOn ACCESSKIT', 'MYBOX rdf:type Gamebox',
                'MYBOX hasColor orange', 'MYBOX hasSize small',
                'MYBOX isOn ACCESSKIT', 'SPACENAVBOX rdf:type Gamebox',
                'SPACENAVBOX hasColor white', 'SPACENAVBOX hasSize big',
                'SPACENAVBOX isOn ACCESSKIT', 'y_bottle rdf:type Bottle',
                'y_bottle isLocated RIGHT', 'r_bottle rdf:type Bottle',
                'r_bottle isLocated FRONT', 'b_bottle rdf:type Bottle',
                'b_bottle isLocated BACK'
            ])
        except AttributeError:  #the ontology server is not started of doesn't know the method
            pass
コード例 #2
0
    def setUp(self):
        self.dialog = Dialog()
        self.dialog.start()

        self.oro = ResourcePool().ontology_server

        try:

            self.oro.add(['ACHILLE rdf:type Human',
                          'ACHILLE rdfs:label Achille',
                          'JULIE rdf:type Human',
                          'JULIE rdfs:label Julie',
                          'table1 rdf:type Table',
                          'Trashbin rdfs:subClassOf Box',
                          'CardBoardBox rdfs:subClassOf Box',
                          'CardBoardBox rdfs:label "cardboard box"',
                          'TRASHBIN rdf:type Trashbin',
                          'CARDBOARD_BOX rdf:type CardBoardBox',
                          'CARDBOARD_BOX isOn table1',
                          'TAPE1 rdf:type VideoTape',
                          'TAPE1 rdfs:label "The Lords of the robots"',
                          'TAPE1 isOn table1',
                          'TAPE2 rdf:type VideoTape',
                          'TAPE2 rdfs:label "Jido-E"',
                          'TAPE2 isOn table1',

                          'VideoTape owl:equivalentClass Tape',
                          'TAPE1 owl:differentFrom TAPE2',
            ])
        except AttributeError:
            pass

        try:

            self.oro.addForAgent(ResourcePool().get_model_mapping('ACHILLE'),
                                 ['ACHILLE rdf:type Human',
                                  'ACHILLE rdfs:label Achille',
                                  'JULIE rdf:type Human',
                                  'JULIE rdfs:label Julie',
                                  'table1 rdf:type Table',
                                  'Trashbin rdfs:subClassOf Box',
                                  'CardBoardBox rdfs:subClassOf Box',
                                  'CardBoardBox rdfs:label "cardboard box"',
                                  'TRASHBIN rdf:type Trashbin',
                                  'CARDBOARD_BOX rdf:type CardBoardBox',
                                  'CARDBOARD_BOX isOn table1',
                                  'TAPE1 rdf:type VideoTape',
                                  'TAPE1 rdfs:label "The Lords of the robots"',
                                  'TAPE1 isOn table1',
                                  'TAPE2 rdf:type VideoTape',
                                  'TAPE2 rdfs:label "Jido-E"',
                                  'TAPE2 isOn table1',

                                  'VideoTape owl:equivalentClass Tape',

                                  'TAPE1 owl:differentFrom TAPE2',
                                 ])
        except AttributeError:
            pass
コード例 #3
0
    def setUp(self):
        self.dialog = Dialog()
        self.dialog.start()

        self.oro = ResourcePool().ontology_server

        try:
            self.oro.reload()
            self.oro.add(['shelf1 rdf:type Shelf',
                          'table1 rdf:type Table',
                          'table2 rdf:type Table', 'table2 hasColor blue',
                          'Banana rdfs:subClassOf Plant',
                          'y_banana rdf:type Banana', 'y_banana hasColor yellow', 'y_banana isOn shelf1',
                          'green_banana rdf:type Banana', 'green_banana hasColor green', 'green_banana isOn table2',
                          'ACCESSKIT rdf:type Gamebox', 'ACCESSKIT hasColor white', 'ACCESSKIT hasSize big',
                          'ACCESSKIT isOn table1',
                          'ORANGEBOX rdf:type Gamebox', 'ORANGEBOX hasColor orange', 'ORANGEBOX hasSize big',
                          'ORANGEBOX isOn ACCESSKIT',
                          'MYBOX rdf:type Gamebox', 'MYBOX hasColor orange', 'MYBOX hasSize small',
                          'MYBOX isOn ACCESSKIT',
                          'SPACENAVBOX rdf:type Gamebox', 'SPACENAVBOX hasColor white', 'SPACENAVBOX hasSize big',
                          'SPACENAVBOX isOn ACCESSKIT',
                          'y_bottle rdf:type Bottle', 'y_bottle isLocated RIGHT',
                          'r_bottle rdf:type Bottle', 'r_bottle isLocated FRONT',
                          'b_bottle rdf:type Bottle', 'b_bottle isLocated BACK'
            ])
        except AttributeError: #the ontology server is not started of doesn't know the method
            pass
コード例 #4
0
    def setUp(self):
        self.dialog = Dialog()
        self.dialog.start()

        self.oro = ResourcePool().ontology_server

        try:
            self.oro.add(['shelf1 rdf:type Shelf',
                          'table1 rdf:type Table',
                          'table2 rdf:type Table',
                          'table2 hasColor blue',
                          'Banana rdfs:subClassOf Plant',
                          'y_banana rdf:type Banana',
                          'y_banana hasColor yellow',
                          'y_banana isAt LEFT',
                          'y_banana isAt shelf1_front', 'shel1_front rdf:type Location',
                          'LEFT isLeftOf myself', 'LEFT rdf:type Location',
                          'shelf1_front isFrontOf shelf1',
                          'green_banana rdf:type Banana',
                          'green_banana hasColor green',
                          'green_banana isOn table2',
                          'green_banana isAt FRONT', 'FRONT rdf:type Location',
                          'FRONT isFrontOf myself',
                          'myself focusesOn y_banana',
                          'myself rdfs:label "Jido"',
                          'myself sees id_tom',
                          'myself sees y_banana',
                          'myself sees shelf1',
                          'myself_name rdf:type Name',
                          'myself_name belongsTo myself',
                          'myself_name rdfs:label "Jido"',
                          'id_tom rdf:type Human',
                          'id_tom rdfs:label "Tom"',
                          'id_tom isNextTo myself',
                          'Banana rdfs:subClassOf Object',
            ])

        except AttributeError: #the ontology server is not started of doesn't know the method
            pass
コード例 #5
0
ファイル: discrimination_test.py プロジェクト: Kuew/dialogs
    def setUp(self):
        self.dialog = Dialog()
        self.dialog.start()

        self.oro = ResourcePool().ontology_server

        try:
            self.oro.reload()
            self.oro.add(
                [
                    "shelf1 rdf:type Shelf",
                    "table1 rdf:type Table",
                    "table2 rdf:type Table",
                    "table2 hasColor blue",
                    "Banana rdfs:subClassOf Plant",
                    "y_banana rdf:type Banana",
                    "y_banana hasColor yellow",
                    "y_banana isOn shelf1",
                    "green_banana rdf:type Banana",
                    "green_banana hasColor green",
                    "green_banana isOn table2",
                    "ACCESSKIT rdf:type Gamebox",
                    "ACCESSKIT hasColor white",
                    "ACCESSKIT hasSize big",
                    "ACCESSKIT isOn table1",
                    "ORANGEBOX rdf:type Gamebox",
                    "ORANGEBOX hasColor orange",
                    "ORANGEBOX hasSize big",
                    "ORANGEBOX isOn ACCESSKIT",
                    "MYBOX rdf:type Gamebox",
                    "MYBOX hasColor orange",
                    "MYBOX hasSize small",
                    "MYBOX isOn ACCESSKIT",
                    "SPACENAVBOX rdf:type Gamebox",
                    "SPACENAVBOX hasColor white",
                    "SPACENAVBOX hasSize big",
                    "SPACENAVBOX isOn ACCESSKIT",
                    "y_bottle rdf:type Bottle",
                    "y_bottle isLocated RIGHT",
                    "r_bottle rdf:type Bottle",
                    "r_bottle isLocated FRONT",
                    "b_bottle rdf:type Bottle",
                    "b_bottle isLocated BACK",
                ]
            )
        except AttributeError:  # the ontology server is not started of doesn't know the method
            pass
コード例 #6
0
class TestDiscriminateCompleteDialog(unittest.TestCase):
    """Tests the differents features of the Dialog module.
    This must be tested with oro-server using the testsuite.oro.owl ontology.
    """

    def setUp(self):
        self.dialog = Dialog()
        self.dialog.start()

        self.oro = ResourcePool().ontology_server

        try:
            self.oro.reload()
            self.oro.add(['shelf1 rdf:type Shelf',
                          'table1 rdf:type Table',
                          'table2 rdf:type Table', 'table2 hasColor blue',
                          'Banana rdfs:subClassOf Plant',
                          'y_banana rdf:type Banana', 'y_banana hasColor yellow', 'y_banana isOn shelf1',
                          'green_banana rdf:type Banana', 'green_banana hasColor green', 'green_banana isOn table2',
                          'ACCESSKIT rdf:type Gamebox', 'ACCESSKIT hasColor white', 'ACCESSKIT hasSize big',
                          'ACCESSKIT isOn table1',
                          'ORANGEBOX rdf:type Gamebox', 'ORANGEBOX hasColor orange', 'ORANGEBOX hasSize big',
                          'ORANGEBOX isOn ACCESSKIT',
                          'MYBOX rdf:type Gamebox', 'MYBOX hasColor orange', 'MYBOX hasSize small',
                          'MYBOX isOn ACCESSKIT',
                          'SPACENAVBOX rdf:type Gamebox', 'SPACENAVBOX hasColor white', 'SPACENAVBOX hasSize big',
                          'SPACENAVBOX isOn ACCESSKIT',
                          'y_bottle rdf:type Bottle', 'y_bottle isLocated RIGHT',
                          'r_bottle rdf:type Bottle', 'r_bottle isLocated FRONT',
                          'b_bottle rdf:type Bottle', 'b_bottle isLocated BACK'
            ])
        except AttributeError: #the ontology server is not started of doesn't know the method
            pass

    def test_discriminate1(self):
        """ Color discriminant should be found"""

        logger.info("\n##################### test_discriminate1 ########################\n")
        ####
        stmt = "the banana is good"
        answer = "the green one"
        ####
        res = self.dialog.test('myself', stmt, answer)
        logger.info(res)
        expected_result = ['green_banana hasFeature good']
        self.assertTrue(check_results(res[0], expected_result))

        """ Color discriminant should be found"""

        logger.info("\n##################### test_discriminate2 ########################\n")
        ####
        stmt = "the banana is good"
        answer = "the yellow one"
        ####
        res = self.dialog.test('myself', stmt, answer)
        logger.info(res)
        expected_result = ['y_banana hasFeature good']
        self.assertTrue(check_results(res[0], expected_result))

    def test_discriminate3(self):
        """ Color discriminant should be found"""

        logger.info("\n##################### test_discriminate3 ########################\n")
        ####
        stmt = "give me the banana"
        answer = "the green one"
        ####
        expected_result = ['myself desires *',
                           '* rdf:type Give',
                           '* performedBy myself',
                           '* actsOnObject green_banana',
                           '* receivedBy myself']
        ###
        res = self.dialog.test('myself', stmt, answer)
        logger.info(res)
        self.assertTrue(check_results(res[0], expected_result))


    def test_discriminate4(self):
        """No ambiguity."""

        logger.info("\n##################### test_discriminate4 ########################\n")
        ####
        stmt = "get the gamebox which is on the table"
        answer = None
        ####
        expected_result = ['myself desires *',
                           '* rdf:type Get',
                           '* performedBy myself',
                           '* actsOnObject ACCESSKIT']
        ###
        res = self.dialog.test('myself', stmt)
        logger.info(res)
        self.assertTrue(check_results(res[0], expected_result))

    def test_discriminate5(self):
        """ Size discriminant should be found """

        logger.info("\n##################### test_discriminate5 ########################\n")
        ####
        stmt = "get the orange gamebox"
        answer = "the big one"
        ####
        expected_result = ['myself desires *',
                           '* rdf:type Get',
                           '* performedBy myself',
                           '* actsOnObject ORANGEBOX']
        ###
        res = self.dialog.test('myself', stmt, answer)
        logger.info(res)
        self.assertTrue(check_results(res[0], expected_result))

    def test_discriminate6(self):
        """No complete discriminant found. More info required"""

        logger.info("\n##################### test_discriminate6 ########################\n")
        ####
        stmt = "get the big gamebox"
        answer = "the orange one"
        ####
        expected_result = ['myself desires *',
                           '* rdf:type Get',
                           '* performedBy myself',
                           '* actsOnObject ORANGEBOX']
        ###
        res = self.dialog.test('myself', stmt, answer)
        logger.info(res)
        self.assertTrue(check_results(res[0], expected_result))


    def test_discriminate7(self):
        """ Location discriminant should be found """

        logger.info("\n##################### test_discriminate7 ########################\n")
        ####
        stmt = "get the white gamebox"
        answer = "the one which is on the table1"
        ####
        expected_result = ['myself desires *',
                           '* rdf:type Get',
                           '* performedBy myself',
                           '* actsOnObject ACCESSKIT']
        ###
        res = self.dialog.test('myself', stmt, answer)
        logger.info(res)
        self.assertTrue(check_results(res[0], expected_result))

    def test_discriminate8(self):
        """ Location wrt robot discriminant should be found """

        logger.info("\n##################### test_discriminate8 ########################\n")
        ####
        stmt = "get the bottle"
        answer = "the one which is in front of you"
        ####
        expected_result = ['myself desires *',
                           '* rdf:type Get',
                           '* performedBy myself',
                           '* actsOnObject r_bottle']
        ###
        res = self.dialog.test('myself', stmt, answer)
        logger.info(res)
        self.assertTrue(check_results(res[0], expected_result))

    def test_discriminate9(self):
        logger.info("\n##################### Class grounding ########################\n")
        ####
        stmt = "a fruit is a plant"
        answer = "a kind of thing"
        ####
        expected_result = ['Plant rdfs:subClassOf Thing', 'Fruit rdfs:subClassOf Plant']
        ###
        res = self.dialog.test('myself', stmt, answer)
        logger.info(res)
        self.assertTrue(check_results(res[0], expected_result))

    def tearDown(self):
        self.dialog.stop()
        self.dialog.join()
コード例 #7
0
class TestQuestionHandlerScenarioMovingToLondon(unittest.TestCase):
    """Tests the processing of question by the Dialog module.
    This must be tested with oro-server using the testsuite.oro.owl ontology.
    """

    def setUp(self):
        self.dialog = Dialog()
        self.dialog.start()

        self.oro = ResourcePool().ontology_server

        try:

            self.oro.add(['ACHILLE rdf:type Human',
                          'ACHILLE rdfs:label Achille',
                          'JULIE rdf:type Human',
                          'JULIE rdfs:label Julie',
                          'table1 rdf:type Table',
                          'Trashbin rdfs:subClassOf Box',
                          'CardBoardBox rdfs:subClassOf Box',
                          'CardBoardBox rdfs:label "cardboard box"',
                          'TRASHBIN rdf:type Trashbin',
                          'CARDBOARD_BOX rdf:type CardBoardBox',
                          'CARDBOARD_BOX isOn table1',
                          'TAPE1 rdf:type VideoTape',
                          'TAPE1 rdfs:label "The Lords of the robots"',
                          'TAPE1 isOn table1',
                          'TAPE2 rdf:type VideoTape',
                          'TAPE2 rdfs:label "Jido-E"',
                          'TAPE2 isOn table1',

                          'VideoTape owl:equivalentClass Tape',
                          'TAPE1 owl:differentFrom TAPE2',
            ])
        except AttributeError:
            pass

        try:

            self.oro.addForAgent(ResourcePool().get_model_mapping('ACHILLE'),
                                 ['ACHILLE rdf:type Human',
                                  'ACHILLE rdfs:label Achille',
                                  'JULIE rdf:type Human',
                                  'JULIE rdfs:label Julie',
                                  'table1 rdf:type Table',
                                  'Trashbin rdfs:subClassOf Box',
                                  'CardBoardBox rdfs:subClassOf Box',
                                  'CardBoardBox rdfs:label "cardboard box"',
                                  'TRASHBIN rdf:type Trashbin',
                                  'CARDBOARD_BOX rdf:type CardBoardBox',
                                  'CARDBOARD_BOX isOn table1',
                                  'TAPE1 rdf:type VideoTape',
                                  'TAPE1 rdfs:label "The Lords of the robots"',
                                  'TAPE1 isOn table1',
                                  'TAPE2 rdf:type VideoTape',
                                  'TAPE2 rdfs:label "Jido-E"',
                                  'TAPE2 isOn table1',

                                  'VideoTape owl:equivalentClass Tape',

                                  'TAPE1 owl:differentFrom TAPE2',
                                 ])
        except AttributeError:
            pass

    def test1(self):

        self.oro.add(['TAPE1 isIn CARDBOARD_BOX'])
        self.oro.removeForAgent(ResourcePool().get_model_mapping('ACHILLE'), ['ACHILLE focusesOn TAPE2'])
        self.oro.addForAgent(ResourcePool().get_model_mapping('ACHILLE'), ['ACHILLE focusesOn CARDBOARD_BOX'])

        stmt = "Jido, what is in the box?"
        answer = "this box"
        ####
        self.assertEquals(self.dialog.test('ACHILLE', stmt, answer)[1][1], "The Lords of the robots.")


    def test2(self):
        #Fill in the history
        stmt = " the TAPE1 is in the CARDBOARD_BOX"
        self.dialog.test('ACHILLE', stmt)

        stmt = "Ok. And where is the other tape?"
        ####
        self.assertEquals(self.dialog.test('ACHILLE', stmt)[1][1], "Alright. The other tape is on the table.")

    def test3(self):
        stmt = "Ok thank you."
        self.assertIn(self.dialog.test('ACHILLE', stmt)[1][1], AGREEMENTS)

    def test3_2(self):
        stmt = "thank you."
        self.assertEquals(self.dialog.test('ACHILLE', stmt)[1][1], "You're welcome.")


    def test4(self):
        self.oro.update(['TAPE2 isReachable false'])

        stmt = "can you take Jido-E?"
        ####
        res = self.dialog.test('ACHILLE', stmt)

        expected_result = ['ACHILLE desires *',
                           '* rdf:type Get',
                           '* performedBy myself',
                           '* actsOnObject TAPE2']

        self.assertTrue(check_results(res[0], expected_result))
        self.assertIn(res[1][1], AGREEMENTS)

    def test_5(self):
        self.oro.update(['TAPE2 isReachable false'])

        stmt = "can you take Jido-E?"
        ####
        res = self.dialog.test('ACHILLE', stmt)

        expected_result = ['ACHILLE desires *',
                           '* rdf:type Get',
                           '* performedBy myself',
                           '* actsOnObject TAPE2']

        self.assertTrue(check_results(res[0], expected_result))
        self.assertIn(res[1][1], AGREEMENTS)

    def test_6(self):

        ###
        self.oro.removeForAgent(ResourcePool().get_model_mapping('ACHILLE'), ['ACHILLE focusesOn CARDBOARD_BOX'])
        self.oro.addForAgent(ResourcePool().get_model_mapping('ACHILLE'), ['ACHILLE focusesOn TAPE2'])
        stmt = "Jido, can you reach this tape?"
        ####
        ## expected to check['myself reaches TAPE2']
        self.assertEquals(self.dialog.test('ACHILLE', stmt)[1][1], "I don't know, if I can reach it.")


    def test_7(self):
        self.oro.update(['TAPE2 isReachable true'])
        #Feel history
        self.dialog.dialog_history = []
        stmt = "can you reach Jido-E?"
        res = self.dialog.test('ACHILLE', stmt)
        ###
        stmt = "can you take it?"
        ####
        answer = "yes"
        ###
        res = self.dialog.test('ACHILLE', stmt, answer)

        expected_result = ['ACHILLE desires *',
                           '* rdf:type Get',
                           '* performedBy myself',
                           '* actsOnObject TAPE2']

        self.assertTrue(check_results(res[0], expected_result))

    def test_8(self):
        ###
        stmt = "can you take the tape?"
        ####
        answer = "forget it"
        ###
        res = self.dialog.test('ACHILLE', stmt, answer)

        expected_result = []

        self.assertTrue(check_results(res[0], expected_result))
コード例 #8
0
class TestQuestionHandlerDialog(unittest.TestCase):
    """Tests the processing of question by the Dialog module.
    This must be tested with oro-server using the testsuite.oro.owl ontology.
    """

    def setUp(self):
        self.dialog = Dialog()
        self.dialog.start()

        self.oro = ResourcePool().ontology_server

        try:
            self.oro.add(['shelf1 rdf:type Shelf',
                          'table1 rdf:type Table',
                          'table2 rdf:type Table',
                          'table2 hasColor blue',
                          'Banana rdfs:subClassOf Plant',
                          'y_banana rdf:type Banana',
                          'y_banana hasColor yellow',
                          'y_banana isAt LEFT',
                          'y_banana isAt shelf1_front', 'shel1_front rdf:type Location',
                          'LEFT isLeftOf myself', 'LEFT rdf:type Location',
                          'shelf1_front isFrontOf shelf1',
                          'green_banana rdf:type Banana',
                          'green_banana hasColor green',
                          'green_banana isOn table2',
                          'green_banana isAt FRONT', 'FRONT rdf:type Location',
                          'FRONT isFrontOf myself',
                          'myself focusesOn y_banana',
                          'myself rdfs:label "Jido"',
                          'myself sees id_tom',
                          'myself sees y_banana',
                          'myself sees shelf1',
                          'myself_name rdf:type Name',
                          'myself_name belongsTo myself',
                          'myself_name rdfs:label "Jido"',
                          'id_tom rdf:type Human',
                          'id_tom rdfs:label "Tom"',
                          'id_tom isNextTo myself',
                          'Banana rdfs:subClassOf Object',
            ])

        except AttributeError: #the ontology server is not started of doesn't know the method
            pass

    def test_question1_where(self):

        logger.info("\n##################### test_question1_where ########################\n")

        ####
        stmt = "Where is the green banana?"
        ####

        ###
        res = self.dialog.test('myself', stmt)
        logger.info(">> input: " + stmt)

        self.assertTrue(val in res[1][1] for val in ["The green banana", "is", "on the blue table", "in front of me"])

        logger.info("\n##################### test_question1_where ########################\n")

        ####
        stmt = "Where is the yellow banana?"
        ####

        ###
        res = self.dialog.test('myself', stmt)
        logger.info(">> input: " + stmt)
        self.assertTrue(val in res[1][1] for val in ["The yellow banana is", "in front of the shelf", "at my left"])


    def test_question2_what(self):

        logger.info("\n##################### test_question2_what ########################\n")

        ####
        stmt = "What is yellow?"
        ####

        ###
        res = self.dialog.test('myself', stmt)
        self.assertEquals(res[1][1], "The yellow banana.")

    def test_question3_what(self):
        logger.info("\n##################### test_question3_what ########################\n")

        stmt = "What object is yellow?"
        ####

        ###
        res = self.dialog.test('myself', stmt)
        self.assertEquals(res[1][1], "The yellow banana.")


    def test_question4_what(self):
        logger.info("\n##################### test_question4_what ########################\n")

        stmt = "What color is the banana that is on the blue table?"
        ####

        ###
        res = self.dialog.test('myself', stmt)
        self.assertTrue(val in res[1][1] for val in ["The banana", "that's", "on the blue table", "is green"])

    def test_question5_what(self):
        logger.info("\n##################### test_question5_what ########################\n")

        stmt = "What is this?"
        ####

        ###
        res = self.dialog.test('myself', stmt)
        self.assertEquals(res[1][1], "This is the yellow banana.")


    def test_question6_who(self):

        logger.info("\n##################### test_question6_who ########################\n")

        ####
        stmt = "Who are you?"
        ####

        ###
        res = self.dialog.test('myself', stmt)
        self.assertEquals(res[1][1], "I am Jido.")

    def test_question6_who(self):

        logger.info("\n##################### test_question6_who_bis ########################\n")

        ####
        stmt = "What is your name?"
        ####

        ###
        res = self.dialog.test('myself', stmt)
        self.assertEquals(res[1][1], "My name is Jido.")


    def test_question7_who(self):
        logger.info("\n##################### test_question7_who ########################\n")

        stmt = "Who is the myself?"
        ####

        ###
        res = self.dialog.test('myself', stmt)
        self.assertTrue(val in res[1][1] for val in ["The myself", "Jido"])

    def test_question8_who(self):
        logger.info("\n##################### test_question8_who ########################\n")

        stmt = "Who do you see?"

        res = self.dialog.test('myself', stmt)
        self.assertEquals(res[1][1], "I see Tom.")

    def test_question8_what(self):
        logger.info("\n##################### test_question8_what ########################\n")
        stmt = "What do you see?"

        res = self.dialog.test('myself', stmt)
        self.assertTrue(val in res[1][1] for val in ["I see", "Tom", "the yellow banana", "and", "the shelf"])

    def test_question9_who(self):
        logger.info("\n##################### test_question9_who ########################\n")

        stmt = "Who is Tom?"
        ####

        ###
        res = self.dialog.test('myself', stmt)
        self.assertEquals(res[1][1], "Tom is Tom.")


    def test_question10(self):
        logger.info("\n##################### test_question10 ########################\n")

        stmt = "Do you see the yellow banana?"
        ####

        ###
        res = self.dialog.test('myself', stmt)
        self.assertEquals(res[1][1], "Yes. I see the yellow banana.")

    def test_question11(self):
        logger.info("\n##################### test_question11 ########################\n")

        stmt = "is the yellow banana on the shelf?"
        ####

        ###
        res = self.dialog.test('myself', stmt)
        self.assertEquals(res[1][1], "Yes. The yellow banana is on the shelf.")

    def test_question12(self):
        logger.info("\n##################### Check label ########################\n")

        stmt = "What human do you see?"
        ####

        ###
        res = self.dialog.test('myself', stmt)
        self.assertEquals(res[1][1], "I see Tom.")

    def test_question13(self):
        logger.info("\n##################### Check label ########################\n")

        stmt = "What human do you know?"
        ####

        ###
        res = self.dialog.test('myself', stmt)
        self.assertTrue(val in res[1][1] for val in ["I know Tom"])

    def test_question14(self):
        logger.info("\n##################### KNOW ########################\n")

        stmt = "What object do you know?"
        ####

        ###
        res = self.dialog.test('myself', stmt)
        self.assertTrue(val in res[1][1] for val in
                        ["I know", "Tom", "the yellow banana", "the green banana", "the table", "and", "the shelf"])

    def test_question15(self):
        logger.info("\n##################### KNOW ########################\n")

        stmt = "do you know the yellow banana?"
        ####

        ###
        res = self.dialog.test('myself', stmt)
        self.assertEquals(res[1][1], "Yes. I know the yellow banana.")


    def test_question16(self):
        logger.info("\n##################### WHICH ########################\n")

        stmt = "which banana is at the left?"
        ####

        ###
        res = self.dialog.test('myself', stmt)
        self.assertEquals(res[1][1], "The yellow banana.")
コード例 #9
0
class TestDiscriminateCompleteDialog(unittest.TestCase):
    """Tests the differents features of the Dialog module.
    This must be tested with oro-server using the testsuite.oro.owl ontology.
    """
    def setUp(self):
        self.dialog = Dialog()
        self.dialog.start()

        self.oro = ResourcePool().ontology_server

        try:
            self.oro.reload()
            self.oro.add([
                'shelf1 rdf:type Shelf', 'table1 rdf:type Table',
                'table2 rdf:type Table', 'table2 hasColor blue',
                'Banana rdfs:subClassOf Plant', 'y_banana rdf:type Banana',
                'y_banana hasColor yellow', 'y_banana isOn shelf1',
                'green_banana rdf:type Banana', 'green_banana hasColor green',
                'green_banana isOn table2', 'ACCESSKIT rdf:type Gamebox',
                'ACCESSKIT hasColor white', 'ACCESSKIT hasSize big',
                'ACCESSKIT isOn table1', 'ORANGEBOX rdf:type Gamebox',
                'ORANGEBOX hasColor orange', 'ORANGEBOX hasSize big',
                'ORANGEBOX isOn ACCESSKIT', 'MYBOX rdf:type Gamebox',
                'MYBOX hasColor orange', 'MYBOX hasSize small',
                'MYBOX isOn ACCESSKIT', 'SPACENAVBOX rdf:type Gamebox',
                'SPACENAVBOX hasColor white', 'SPACENAVBOX hasSize big',
                'SPACENAVBOX isOn ACCESSKIT', 'y_bottle rdf:type Bottle',
                'y_bottle isLocated RIGHT', 'r_bottle rdf:type Bottle',
                'r_bottle isLocated FRONT', 'b_bottle rdf:type Bottle',
                'b_bottle isLocated BACK'
            ])
        except AttributeError:  #the ontology server is not started of doesn't know the method
            pass

    def test_discriminate1(self):
        """ Color discriminant should be found"""

        logger.info(
            "\n##################### test_discriminate1 ########################\n"
        )
        ####
        stmt = "the banana is good"
        answer = "the green one"
        ####
        res = self.dialog.test('myself', stmt, answer)
        logger.info(res)
        expected_result = ['green_banana hasFeature good']
        self.assertTrue(check_results(res[0], expected_result))
        """ Color discriminant should be found"""

        logger.info(
            "\n##################### test_discriminate2 ########################\n"
        )
        ####
        stmt = "the banana is good"
        answer = "the yellow one"
        ####
        res = self.dialog.test('myself', stmt, answer)
        logger.info(res)
        expected_result = ['y_banana hasFeature good']
        self.assertTrue(check_results(res[0], expected_result))

    def test_discriminate3(self):
        """ Color discriminant should be found"""

        logger.info(
            "\n##################### test_discriminate3 ########################\n"
        )
        ####
        stmt = "give me the banana"
        answer = "the green one"
        ####
        expected_result = [
            'myself desires *', '* rdf:type Give', '* performedBy myself',
            '* actsOnObject green_banana', '* receivedBy myself'
        ]
        ###
        res = self.dialog.test('myself', stmt, answer)
        logger.info(res)
        self.assertTrue(check_results(res[0], expected_result))

    def test_discriminate4(self):
        """No ambiguity."""

        logger.info(
            "\n##################### test_discriminate4 ########################\n"
        )
        ####
        stmt = "get the gamebox which is on the table"
        answer = None
        ####
        expected_result = [
            'myself desires *', '* rdf:type Get', '* performedBy myself',
            '* actsOnObject ACCESSKIT'
        ]
        ###
        res = self.dialog.test('myself', stmt)
        logger.info(res)
        self.assertTrue(check_results(res[0], expected_result))

    def test_discriminate5(self):
        """ Size discriminant should be found """

        logger.info(
            "\n##################### test_discriminate5 ########################\n"
        )
        ####
        stmt = "get the orange gamebox"
        answer = "the big one"
        ####
        expected_result = [
            'myself desires *', '* rdf:type Get', '* performedBy myself',
            '* actsOnObject ORANGEBOX'
        ]
        ###
        res = self.dialog.test('myself', stmt, answer)
        logger.info(res)
        self.assertTrue(check_results(res[0], expected_result))

    def test_discriminate6(self):
        """No complete discriminant found. More info required"""

        logger.info(
            "\n##################### test_discriminate6 ########################\n"
        )
        ####
        stmt = "get the big gamebox"
        answer = "the orange one"
        ####
        expected_result = [
            'myself desires *', '* rdf:type Get', '* performedBy myself',
            '* actsOnObject ORANGEBOX'
        ]
        ###
        res = self.dialog.test('myself', stmt, answer)
        logger.info(res)
        self.assertTrue(check_results(res[0], expected_result))

    def test_discriminate7(self):
        """ Location discriminant should be found """

        logger.info(
            "\n##################### test_discriminate7 ########################\n"
        )
        ####
        stmt = "get the white gamebox"
        answer = "the one which is on the table1"
        ####
        expected_result = [
            'myself desires *', '* rdf:type Get', '* performedBy myself',
            '* actsOnObject ACCESSKIT'
        ]
        ###
        res = self.dialog.test('myself', stmt, answer)
        logger.info(res)
        self.assertTrue(check_results(res[0], expected_result))

    def test_discriminate8(self):
        """ Location wrt robot discriminant should be found """

        logger.info(
            "\n##################### test_discriminate8 ########################\n"
        )
        ####
        stmt = "get the bottle"
        answer = "the one which is in front of you"
        ####
        expected_result = [
            'myself desires *', '* rdf:type Get', '* performedBy myself',
            '* actsOnObject r_bottle'
        ]
        ###
        res = self.dialog.test('myself', stmt, answer)
        logger.info(res)
        self.assertTrue(check_results(res[0], expected_result))

    def test_discriminate9(self):
        logger.info(
            "\n##################### Class grounding ########################\n"
        )
        ####
        stmt = "a fruit is a plant"
        answer = "a kind of thing"
        ####
        expected_result = [
            'Plant rdfs:subClassOf Thing', 'Fruit rdfs:subClassOf Plant'
        ]
        ###
        res = self.dialog.test('myself', stmt, answer)
        logger.info(res)
        self.assertTrue(check_results(res[0], expected_result))

    def tearDown(self):
        self.dialog.stop()
        self.dialog.join()
コード例 #10
0
    def setUp(self):
        self.dialog = Dialog()
        self.dialog.start()

        self.oro = ResourcePool().ontology_server

        try:

            self.oro.add([
                'ACHILLE rdf:type Human',
                'ACHILLE rdfs:label Achille',
                'JULIE rdf:type Human',
                'JULIE rdfs:label Julie',
                'TABLE rdf:type Table',
                'Trashbin rdfs:subClassOf Box',
                'CardBoardBox rdfs:subClassOf Box',
                'CardBoardBox rdfs:label "cardboard box"',
                'TRASHBIN rdf:type Trashbin',
                'CARDBOARD_BOX rdf:type CardBoardBox',
                'CARDBOARD_BOX isOn TABLE',
                'TAPE1 rdf:type VideoTape',
                'TAPE1 rdfs:label "The Lords of the robots"',
                'TAPE1 isOn TABLE',
                'TAPE2 rdf:type VideoTape',
                'TAPE2 rdfs:label "Jido-E"',
                'TAPE2 isOn TABLE',
                'VideoTape owl:equivalentClass Tape',
                'TAPE1 owl:differentFrom TAPE2',
            ])
            """           
            self.oro.addForAgent('ACHILLE',
                        ['BLUE_TRASHBIN rdf:type Trashbin',
                        'PINK_TRASHBIN rdf:type Trashbin',
                        'BLACK_TAPE rdf:type VideoTape', 'BLACK_TAPE isIn PINK_TRASHBIN',
                        'GREY_TAPE rdf:type VideoTape', 'GREY_TAPE isOn HRP2TABLE'])
            """
        except AttributeError:  #the ontology server is not started of doesn't know the method
            print(
                "Couldn't connect to the ontology server. Aborting the test.")
            raise

        try:
            self.oro.addForAgent('ACHILLE', [
                'ACHILLE rdf:type Human',
                'ACHILLE rdfs:label Achille',
                'JULIE rdf:type Human',
                'JULIE rdfs:label Julie',
                'TABLE rdf:type Table',
                'Trashbin rdfs:subClassOf Box',
                'CardBoardBox rdfs:subClassOf Box',
                'CardBoardBox rdfs:label "cardboard box"',
                'TRASHBIN rdf:type Trashbin',
                'CARDBOARD_BOX rdf:type CardBoardBox',
                'CARDBOARD_BOX isOn TABLE',
                'TAPE1 rdf:type VideoTape',
                'TAPE1 rdfs:label "The Lords of the robots"',
                'TAPE1 isOn TABLE',
                'TAPE2 rdf:type VideoTape',
                'TAPE2 rdfs:label "Jido-E"',
                'TAPE2 isOn TABLE',
                'VideoTape owl:equivalentClass Tape',
                'TAPE1 owl:differentFrom TAPE2',
            ])
        except AttributeError:  #the ontology server is not started of doesn't know the method
            print(
                "Couldn't connect to the ontology server. Aborting the test.")
            raise

        try:
            self.oro.addForAgent('JULIE', [
                'ACHILLE rdf:type Human',
                'ACHILLE rdfs:label Achille',
                'JULIE rdf:type Human',
                'JULIE rdfs:label Julie',
                'TABLE rdf:type Table',
                'Trashbin rdfs:subClassOf Box',
                'CardBoardBox rdfs:subClassOf Box',
                'CardBoardBox rdfs:label "cardboard box"',
                'TRASHBIN rdf:type Trashbin',
                'CARDBOARD_BOX rdf:type CardBoardBox',
                'CARDBOARD_BOX isOn TABLE',
                'TAPE1 rdf:type VideoTape',
                'TAPE1 rdfs:label "The Lords of the robots"',
                'TAPE1 isOn TABLE',
                'TAPE2 rdf:type VideoTape',
                'TAPE2 rdfs:label "Jido-E"',
                'TAPE2 isOn TABLE',
                'VideoTape owl:equivalentClass Tape',
                'TAPE1 owl:differentFrom TAPE2',
            ])
        except AttributeError:  #the ontology server is not started of doesn't know the method
            print(
                "Couldn't connect to the ontology server. Aborting the test.")
            raise
コード例 #11
0
class TestMovingToLondonScenario(unittest.TestCase):
    """
    Scenario
    --------
    ACHILLE and JULIE are moving from Toulouse to London, and they must
    pack everything before leaving. ACHILLE is sorting its video tapes, and he 
    throws away the oldest ones. Jido is watching him.

    Setup:
      One trashbin, one cardboard box, 2 tapes on the table [TAPE1 = Lord of 
      the Robots (lotr) and TAPE2 = JIDO-E].
    
    Complete scenario here:
    http://homepages.laas.fr/slemaign/wiki/doku.php?id=scenario_demo_roman
    """
    def setUp(self):
        self.dialog = Dialog()
        self.dialog.start()

        self.oro = ResourcePool().ontology_server

        try:

            self.oro.add([
                'ACHILLE rdf:type Human',
                'ACHILLE rdfs:label Achille',
                'JULIE rdf:type Human',
                'JULIE rdfs:label Julie',
                'TABLE rdf:type Table',
                'Trashbin rdfs:subClassOf Box',
                'CardBoardBox rdfs:subClassOf Box',
                'CardBoardBox rdfs:label "cardboard box"',
                'TRASHBIN rdf:type Trashbin',
                'CARDBOARD_BOX rdf:type CardBoardBox',
                'CARDBOARD_BOX isOn TABLE',
                'TAPE1 rdf:type VideoTape',
                'TAPE1 rdfs:label "The Lords of the robots"',
                'TAPE1 isOn TABLE',
                'TAPE2 rdf:type VideoTape',
                'TAPE2 rdfs:label "Jido-E"',
                'TAPE2 isOn TABLE',
                'VideoTape owl:equivalentClass Tape',
                'TAPE1 owl:differentFrom TAPE2',
            ])
            """           
            self.oro.addForAgent('ACHILLE',
                        ['BLUE_TRASHBIN rdf:type Trashbin',
                        'PINK_TRASHBIN rdf:type Trashbin',
                        'BLACK_TAPE rdf:type VideoTape', 'BLACK_TAPE isIn PINK_TRASHBIN',
                        'GREY_TAPE rdf:type VideoTape', 'GREY_TAPE isOn HRP2TABLE'])
            """
        except AttributeError:  #the ontology server is not started of doesn't know the method
            print(
                "Couldn't connect to the ontology server. Aborting the test.")
            raise

        try:
            self.oro.addForAgent('ACHILLE', [
                'ACHILLE rdf:type Human',
                'ACHILLE rdfs:label Achille',
                'JULIE rdf:type Human',
                'JULIE rdfs:label Julie',
                'TABLE rdf:type Table',
                'Trashbin rdfs:subClassOf Box',
                'CardBoardBox rdfs:subClassOf Box',
                'CardBoardBox rdfs:label "cardboard box"',
                'TRASHBIN rdf:type Trashbin',
                'CARDBOARD_BOX rdf:type CardBoardBox',
                'CARDBOARD_BOX isOn TABLE',
                'TAPE1 rdf:type VideoTape',
                'TAPE1 rdfs:label "The Lords of the robots"',
                'TAPE1 isOn TABLE',
                'TAPE2 rdf:type VideoTape',
                'TAPE2 rdfs:label "Jido-E"',
                'TAPE2 isOn TABLE',
                'VideoTape owl:equivalentClass Tape',
                'TAPE1 owl:differentFrom TAPE2',
            ])
        except AttributeError:  #the ontology server is not started of doesn't know the method
            print(
                "Couldn't connect to the ontology server. Aborting the test.")
            raise

        try:
            self.oro.addForAgent('JULIE', [
                'ACHILLE rdf:type Human',
                'ACHILLE rdfs:label Achille',
                'JULIE rdf:type Human',
                'JULIE rdfs:label Julie',
                'TABLE rdf:type Table',
                'Trashbin rdfs:subClassOf Box',
                'CardBoardBox rdfs:subClassOf Box',
                'CardBoardBox rdfs:label "cardboard box"',
                'TRASHBIN rdf:type Trashbin',
                'CARDBOARD_BOX rdf:type CardBoardBox',
                'CARDBOARD_BOX isOn TABLE',
                'TAPE1 rdf:type VideoTape',
                'TAPE1 rdfs:label "The Lords of the robots"',
                'TAPE1 isOn TABLE',
                'TAPE2 rdf:type VideoTape',
                'TAPE2 rdfs:label "Jido-E"',
                'TAPE2 isOn TABLE',
                'VideoTape owl:equivalentClass Tape',
                'TAPE1 owl:differentFrom TAPE2',
            ])
        except AttributeError:  #the ontology server is not started of doesn't know the method
            print(
                "Couldn't connect to the ontology server. Aborting the test.")
            raise

    def runTest(self):
        """ MOVING TO LONDON SCENARIO
        
        ACHILLE puts TAPE1 in CARDBOARDBOX"""

        print()
        self.oro.add(['TAPE1 isIn CARDBOARD_BOX'])
        self.oro.addForAgent('ACHILLE', ['ACHILLE pointsAt CARDBOARD_BOX'])

        stmt = "Jido, what is in the box?"
        answer = "This box"
        ####
        res = self.dialog.test('ACHILLE', stmt, answer)
        self.assertEquals(res[1][1], "The Lords of the robots.")

        self.oro.removeForAgent('ACHILLE', ['ACHILLE pointsAt CARDBOARD_BOX'])

        stmt = "Ok. And where is the other tape?"
        ####
        self.assertEquals(
            self.dialog.test('ACHILLE', stmt)[1][1],
            "The other tape is on the table.")

        stmt = "Ok. Thanks."
        self.assertEquals(
            self.dialog.test('ACHILLE', stmt)[1][1], "You're welcome.")
        """Julie arrives, and gives two big boxes to ACHILLE. He can not take anything!"""

        self.oro.update(['TAPE2 isReachable false'])

        stmt = "Jido, can you take Jido-E?"
        ####
        res = self.dialog.test('ACHILLE', stmt)

        expected_result = [
            'ACHILLE desires *', '* rdf:type Get', '* performedBy myself',
            '* actsOnObject TAPE2'
        ]

        self.assertTrue(check_results(res[0], expected_result))
        """Julie pushes a bit the TAPE2, which is now close enough, but still 
        unreachable because of an obstacle.
        """
        self.oro.addForAgent('ACHILLE', ['ACHILLE pointsAt TAPE2'])
        stmt = "And now, can you reach this tape?"
        ####
        ### Check ['myself reaches TAPE2']
        self.assertEquals(
            self.dialog.test('ACHILLE', stmt)[1][1],
            "I don't know, if I can reach this tape now.")
        self.oro.removeForAgent('ACHILLE', ['ACHILLE pointsAt TAPE2'])
        """Julie pushes again the tape. It is now reachable.
        """
        self.oro.update(['TAPE2 isReachable true'])

        stmt = "Jido, can you take it?"
        ####
        ### Do you mean Jido-E
        answer = "I mean Jido-E"
        ###
        res = self.dialog.test('JULIE', stmt, answer)
        expected_result = [
            'JULIE desires *', '* rdf:type Get', '* performedBy myself',
            '* actsOnObject TAPE2'
        ]

        self.assertTrue(check_results(res[0], expected_result))
        """Achille puts JIDO-E in the trashbin. Jido still observes. Achille 
        leaves. Julie finds JIDO-E in the trashbin, and takes it away. ACHILLE 
        comes back to the table.
        """

        print()
        self.oro.remove(['TAPE2 isOn TABLE'])
        self.oro.add(['TAPE2 isAt JULIE'])
        self.oro.addForAgent('ACHILLE', ['TAPE2 isIn TRASHBIN'])

        stmt = "Can you give me the tape in the trashbin?"
        #Expected intermediate question: "You mean, the JIDO-E tape?"
        #NOT FOR ROMAN demo!
        #answer = "Yes"
        ####
        res = self.dialog.test('ACHILLE', stmt)

        expected_result = [
            'ACHILLE desires *', '* rdf:type Give', '* performedBy myself',
            '* actsOnObject TAPE2', '* receivedBy ACHILLE'
        ]

        self.assertTrue(check_results(res[0], expected_result))

    def tearDown(self):
        self.dialog.stop()
        self.dialog.join()
コード例 #12
0
ファイル: scenario_moving.py プロジェクト: Kuew/dialogs
 def setUp(self):
     self.dialog = Dialog()
     self.dialog.start()
     
     self.oro = ResourcePool().ontology_server
     
     try:
         
         self.oro.add([  'ACHILLE rdf:type Human',
                         'ACHILLE rdfs:label Achille',
                         'JULIE rdf:type Human', 
                         'JULIE rdfs:label Julie',
                         'TABLE rdf:type Table',
                         'Trashbin rdfs:subClassOf Box',
                         'CardBoardBox rdfs:subClassOf Box',
                         'CardBoardBox rdfs:label "cardboard box"',
                         'TRASHBIN rdf:type Trashbin',
                         'CARDBOARD_BOX rdf:type CardBoardBox',
                         'CARDBOARD_BOX isOn TABLE',
                         'TAPE1 rdf:type VideoTape', 
                         'TAPE1 rdfs:label "The Lords of the robots"', 
                         'TAPE1 isOn TABLE',
                         'TAPE2 rdf:type VideoTape', 
                         'TAPE2 rdfs:label "Jido-E"', 
                         'TAPE2 isOn TABLE',
                         'VideoTape owl:equivalentClass Tape',
                         'TAPE1 owl:differentFrom TAPE2',
                         ])
         """           
         self.oro.addForAgent('ACHILLE',
                     ['BLUE_TRASHBIN rdf:type Trashbin',
                     'PINK_TRASHBIN rdf:type Trashbin',
                     'BLACK_TAPE rdf:type VideoTape', 'BLACK_TAPE isIn PINK_TRASHBIN',
                     'GREY_TAPE rdf:type VideoTape', 'GREY_TAPE isOn HRP2TABLE'])
         """        
     except AttributeError: #the ontology server is not started of doesn't know the method
         print("Couldn't connect to the ontology server. Aborting the test.")
         raise
     
     try:
         self.oro.addForAgent('ACHILLE',[
                         'ACHILLE rdf:type Human',
                         'ACHILLE rdfs:label Achille',
                         'JULIE rdf:type Human', 
                         'JULIE rdfs:label Julie',
                         'TABLE rdf:type Table',
                         'Trashbin rdfs:subClassOf Box',
                         'CardBoardBox rdfs:subClassOf Box',
                         'CardBoardBox rdfs:label "cardboard box"',
                         'TRASHBIN rdf:type Trashbin',
                         'CARDBOARD_BOX rdf:type CardBoardBox',
                         'CARDBOARD_BOX isOn TABLE',
                         'TAPE1 rdf:type VideoTape', 
                         'TAPE1 rdfs:label "The Lords of the robots"', 
                         'TAPE1 isOn TABLE',
                         'TAPE2 rdf:type VideoTape', 
                         'TAPE2 rdfs:label "Jido-E"', 
                         'TAPE2 isOn TABLE',
                         
                         'VideoTape owl:equivalentClass Tape',
                         
                         'TAPE1 owl:differentFrom TAPE2',
                         ])
     except AttributeError: #the ontology server is not started of doesn't know the method
         print("Couldn't connect to the ontology server. Aborting the test.")
         raise
     
     
     try:
         self.oro.addForAgent('JULIE',[
                         'ACHILLE rdf:type Human',
                         'ACHILLE rdfs:label Achille',
                         'JULIE rdf:type Human', 
                         'JULIE rdfs:label Julie',
                         'TABLE rdf:type Table',
                         'Trashbin rdfs:subClassOf Box',
                         'CardBoardBox rdfs:subClassOf Box',
                         'CardBoardBox rdfs:label "cardboard box"',
                         'TRASHBIN rdf:type Trashbin',
                         'CARDBOARD_BOX rdf:type CardBoardBox',
                         'CARDBOARD_BOX isOn TABLE',
                         'TAPE1 rdf:type VideoTape', 
                         'TAPE1 rdfs:label "The Lords of the robots"', 
                         'TAPE1 isOn TABLE',
                         'TAPE2 rdf:type VideoTape', 
                         'TAPE2 rdfs:label "Jido-E"', 
                         'TAPE2 isOn TABLE',
                         
                         'VideoTape owl:equivalentClass Tape',
                         
                         'TAPE1 owl:differentFrom TAPE2',
                         ])
     except AttributeError: #the ontology server is not started of doesn't know the method
         print("Couldn't connect to the ontology server. Aborting the test.")
         raise
コード例 #13
0
ファイル: scenario_moving.py プロジェクト: Kuew/dialogs
class TestMovingToLondonScenario(unittest.TestCase):
    """
    Scenario
    --------
    ACHILLE and JULIE are moving from Toulouse to London, and they must
    pack everything before leaving. ACHILLE is sorting its video tapes, and he 
    throws away the oldest ones. Jido is watching him.

    Setup:
      One trashbin, one cardboard box, 2 tapes on the table [TAPE1 = Lord of 
      the Robots (lotr) and TAPE2 = JIDO-E].
    
    Complete scenario here:
    http://homepages.laas.fr/slemaign/wiki/doku.php?id=scenario_demo_roman
    """
    
    def setUp(self):
        self.dialog = Dialog()
        self.dialog.start()
        
        self.oro = ResourcePool().ontology_server
        
        try:
            
            self.oro.add([  'ACHILLE rdf:type Human',
                            'ACHILLE rdfs:label Achille',
                            'JULIE rdf:type Human', 
                            'JULIE rdfs:label Julie',
                            'TABLE rdf:type Table',
                            'Trashbin rdfs:subClassOf Box',
                            'CardBoardBox rdfs:subClassOf Box',
                            'CardBoardBox rdfs:label "cardboard box"',
                            'TRASHBIN rdf:type Trashbin',
                            'CARDBOARD_BOX rdf:type CardBoardBox',
                            'CARDBOARD_BOX isOn TABLE',
                            'TAPE1 rdf:type VideoTape', 
                            'TAPE1 rdfs:label "The Lords of the robots"', 
                            'TAPE1 isOn TABLE',
                            'TAPE2 rdf:type VideoTape', 
                            'TAPE2 rdfs:label "Jido-E"', 
                            'TAPE2 isOn TABLE',
                            'VideoTape owl:equivalentClass Tape',
                            'TAPE1 owl:differentFrom TAPE2',
                            ])
            """           
            self.oro.addForAgent('ACHILLE',
                        ['BLUE_TRASHBIN rdf:type Trashbin',
                        'PINK_TRASHBIN rdf:type Trashbin',
                        'BLACK_TAPE rdf:type VideoTape', 'BLACK_TAPE isIn PINK_TRASHBIN',
                        'GREY_TAPE rdf:type VideoTape', 'GREY_TAPE isOn HRP2TABLE'])
            """        
        except AttributeError: #the ontology server is not started of doesn't know the method
            print("Couldn't connect to the ontology server. Aborting the test.")
            raise
        
        try:
            self.oro.addForAgent('ACHILLE',[
                            'ACHILLE rdf:type Human',
                            'ACHILLE rdfs:label Achille',
                            'JULIE rdf:type Human', 
                            'JULIE rdfs:label Julie',
                            'TABLE rdf:type Table',
                            'Trashbin rdfs:subClassOf Box',
                            'CardBoardBox rdfs:subClassOf Box',
                            'CardBoardBox rdfs:label "cardboard box"',
                            'TRASHBIN rdf:type Trashbin',
                            'CARDBOARD_BOX rdf:type CardBoardBox',
                            'CARDBOARD_BOX isOn TABLE',
                            'TAPE1 rdf:type VideoTape', 
                            'TAPE1 rdfs:label "The Lords of the robots"', 
                            'TAPE1 isOn TABLE',
                            'TAPE2 rdf:type VideoTape', 
                            'TAPE2 rdfs:label "Jido-E"', 
                            'TAPE2 isOn TABLE',
                            
                            'VideoTape owl:equivalentClass Tape',
                            
                            'TAPE1 owl:differentFrom TAPE2',
                            ])
        except AttributeError: #the ontology server is not started of doesn't know the method
            print("Couldn't connect to the ontology server. Aborting the test.")
            raise
        
        
        try:
            self.oro.addForAgent('JULIE',[
                            'ACHILLE rdf:type Human',
                            'ACHILLE rdfs:label Achille',
                            'JULIE rdf:type Human', 
                            'JULIE rdfs:label Julie',
                            'TABLE rdf:type Table',
                            'Trashbin rdfs:subClassOf Box',
                            'CardBoardBox rdfs:subClassOf Box',
                            'CardBoardBox rdfs:label "cardboard box"',
                            'TRASHBIN rdf:type Trashbin',
                            'CARDBOARD_BOX rdf:type CardBoardBox',
                            'CARDBOARD_BOX isOn TABLE',
                            'TAPE1 rdf:type VideoTape', 
                            'TAPE1 rdfs:label "The Lords of the robots"', 
                            'TAPE1 isOn TABLE',
                            'TAPE2 rdf:type VideoTape', 
                            'TAPE2 rdfs:label "Jido-E"', 
                            'TAPE2 isOn TABLE',
                            
                            'VideoTape owl:equivalentClass Tape',
                            
                            'TAPE1 owl:differentFrom TAPE2',
                            ])
        except AttributeError: #the ontology server is not started of doesn't know the method
            print("Couldn't connect to the ontology server. Aborting the test.")
            raise
       
            
    def runTest(self):
        """ MOVING TO LONDON SCENARIO
        
        ACHILLE puts TAPE1 in CARDBOARDBOX"""

        print()
        self.oro.add(['TAPE1 isIn CARDBOARD_BOX'])
        self.oro.addForAgent('ACHILLE',['ACHILLE pointsAt CARDBOARD_BOX'])
        
        stmt = "Jido, what is in the box?"
        answer = "This box"
        ####
        res = self.dialog.test('ACHILLE', stmt, answer)
        self.assertEquals(res[1][1],"The Lords of the robots.")
        
        self.oro.removeForAgent('ACHILLE',['ACHILLE pointsAt CARDBOARD_BOX'])
        
        stmt = "Ok. And where is the other tape?"
        ####
        self.assertEquals(self.dialog.test('ACHILLE', stmt)[1][1],"The other tape is on the table.")
        
        stmt = "Ok. Thanks."
        self.assertEquals(self.dialog.test('ACHILLE', stmt)[1][1],"You're welcome.")
        
        """Julie arrives, and gives two big boxes to ACHILLE. He can not take anything!"""
       
        self.oro.update(['TAPE2 isReachable false'])
                            
        stmt = "Jido, can you take Jido-E?"
        ####
        res = self.dialog.test('ACHILLE', stmt)
        
        expected_result = ['ACHILLE desires *',
                  '* rdf:type Get',
                  '* performedBy myself',
                  '* actsOnObject TAPE2']
        
        self.assertTrue(check_results(res[0], expected_result))
        
        """Julie pushes a bit the TAPE2, which is now close enough, but still 
        unreachable because of an obstacle.
        """
        self.oro.addForAgent('ACHILLE',['ACHILLE pointsAt TAPE2'])
        stmt = "And now, can you reach this tape?"
        ####
        ### Check ['myself reaches TAPE2']
        self.assertEquals(self.dialog.test('ACHILLE', stmt)[1][1],"I don't know, if I can reach this tape now.")
        self.oro.removeForAgent('ACHILLE',['ACHILLE pointsAt TAPE2'])
        
        """Julie pushes again the tape. It is now reachable.
        """
        self.oro.update(['TAPE2 isReachable true'])
        
        stmt = "Jido, can you take it?"
        ####
        ### Do you mean Jido-E
        answer = "I mean Jido-E"
        ###
        res = self.dialog.test('JULIE', stmt, answer)
        expected_result = ['JULIE desires *',
                  '* rdf:type Get',
                  '* performedBy myself',
                  '* actsOnObject TAPE2']
        
        self.assertTrue(check_results(res[0], expected_result))
        
        """Achille puts JIDO-E in the trashbin. Jido still observes. Achille 
        leaves. Julie finds JIDO-E in the trashbin, and takes it away. ACHILLE 
        comes back to the table.
        """

        print()
        self.oro.remove(['TAPE2 isOn TABLE'])
        self.oro.add(['TAPE2 isAt JULIE'])
        self.oro.addForAgent('ACHILLE', ['TAPE2 isIn TRASHBIN'])
                            
        stmt = "Can you give me the tape in the trashbin?"
        #Expected intermediate question: "You mean, the JIDO-E tape?"
        #NOT FOR ROMAN demo!
        #answer = "Yes"
        ####
        res = self.dialog.test('ACHILLE', stmt)
        
        expected_result = ['ACHILLE desires *',
                  '* rdf:type Give',
                  '* performedBy myself',
                  '* actsOnObject TAPE2',
                  '* receivedBy ACHILLE']
        
        self.assertTrue(check_results(res[0], expected_result))

    def tearDown(self):
        self.dialog.stop()
        self.dialog.join()