Esempio n. 1
0
class AttributeExtractorTest(unittest.TestCase):

    def setUp(self):
        self.extractor = RuleBasedAttributeExtractor()
        self.estimator = RuleBasedDialogueActTypeEstimator()

    def tearDown(self):
        pass

    def test_extract(self):
        attribute = self.extractor.extract(text='男の子')
        act_type = self.estimator.estimate(attribute)
        self.assertEqual(act_type, 'gender')
        attribute = self.extractor.extract(text='12歳')
        act_type = self.estimator.estimate(attribute)
        self.assertEqual(act_type, 'age')
        attribute = self.extractor.extract(text='1000円以下で')
        act_type = self.estimator.estimate(attribute)
        self.assertEqual(act_type, 'maximum_amount')
        attribute = self.extractor.extract(text='孫')
        act_type = self.estimator.estimate(attribute)
        self.assertEqual(act_type, 'relationship')        
        attribute = self.extractor.extract(text='こんにちは')
        act_type = self.estimator.estimate(attribute)
        self.assertEqual(act_type, 'other')
class AttributeExtractorTest(unittest.TestCase):
    def setUp(self):
        self.extractor = RuleBasedAttributeExtractor()

    def tearDown(self):
        pass

    def test_extract(self):
        attribute = self.extractor.extract(text='ラーメンを食べたい')
        self.assertEqual(attribute, {
            'LOCATION': '',
            'GENRE': 'ラーメン',
            'MAXIMUM_AMOUNT': ''
        })
        attribute = self.extractor.extract(text='西新宿のあたり')
        self.assertEqual(attribute, {
            'LOCATION': '西新宿',
            'GENRE': '',
            'MAXIMUM_AMOUNT': ''
        })
        attribute = self.extractor.extract(text='1000円以下で')
        self.assertEqual(attribute, {
            'LOCATION': '',
            'GENRE': '',
            'MAXIMUM_AMOUNT': '1000'
        })
Esempio n. 3
0
class AttributeExtractorTest(unittest.TestCase):
    def setUp(self):
        self.extractor = RuleBasedAttributeExtractor()

    def tearDown(self):
        pass

    def test_extract(self):
        attribute = self.extractor.extract(text='9月の第2土曜日あたり')
        self.assertTrue(attribute['date'] == '9')
        attribute = self.extractor.extract(text='草津のあたり')
        self.assertTrue(attribute['small_area'] == '草津')
        attribute = self.extractor.extract(text='東京らへん')
        self.assertTrue(attribute['middle_area'] == '東京')
        attribute = self.extractor.extract(text='関東近郊')
        self.assertTrue(attribute['large_area'] == '関東')
        attribute = self.extractor.extract(text='海かな')
        self.assertTrue(attribute['seamt'] == '海')
Esempio n. 4
0
class AttributeExtractorTest(unittest.TestCase):
    def setUp(self):
        self.extractor = RuleBasedAttributeExtractor()
        self.estimator = RuleBasedDialogueActTypeEstimator()

    def tearDown(self):
        pass

    def test_extract(self):
        attribute = self.extractor.extract(text='ラーメンを食べたい')
        act_type = self.estimator.estimate(attribute)
        self.assertEqual(act_type, 'INFORM_GENRE')
        attribute = self.extractor.extract(text='西新宿のあたり')
        act_type = self.estimator.estimate(attribute)
        self.assertEqual(act_type, 'INFORM_LOC')
        attribute = self.extractor.extract(text='1000円以下で')
        act_type = self.estimator.estimate(attribute)
        self.assertEqual(act_type, 'INFORM_MONEY')
        attribute = self.extractor.extract(text='こんにちは')
        act_type = self.estimator.estimate(attribute)
        self.assertEqual(act_type, 'OTHER')
Esempio n. 5
0
class AttributeExtractorTest(unittest.TestCase):
    def setUp(self):
        self.extractor = RuleBasedAttributeExtractor()
        self.estimator = RuleBasedDialogueActTypeEstimator()

    def tearDown(self):
        pass

    def test_extract(self):
        attribute = self.extractor.extract(text='草津のあたり')
        act_type = self.estimator.estimate(attribute)
        self.assertEqual(act_type, 'RespondSmallArea')

        attribute = self.extractor.extract(text='東京観光をしたい')
        act_type = self.estimator.estimate(attribute)
        self.assertEqual(act_type, 'RespondMiddleArea')

        attribute = self.extractor.extract(text='関東近郊らへん')
        act_type = self.estimator.estimate(attribute)
        self.assertEqual(act_type, 'RespondLargeArea')

        attribute = self.extractor.extract(text='海かな')
        act_type = self.estimator.estimate(attribute)
        self.assertEqual(act_type, 'RespondSeaMt')

        attribute = self.extractor.extract(text='9月の第2土曜日あたり')
        act_type = self.estimator.estimate(attribute)
        self.assertEqual(act_type, 'RespondSchedule')

        attribute = self.extractor.extract(text='こんにちは')
        act_type = self.estimator.estimate(attribute)
        self.assertEqual(act_type, 'OTHER')
Esempio n. 6
0
class RuleBasedLanguageUnderstanding(object):
    def __init__(self):
        self.__estimator = RuleBasedDialogueActTypeEstimator()
        self.__extractor = RuleBasedAttributeExtractor()

    def execute(self, sent):
        attribute = self.__extractor.extract(sent)
        act_type = self.__estimator.estimate(attribute)

        dialogue_act = {'user_act_type': act_type, 'utt': sent}
        attribute_cp = copy.copy(attribute)
        for k, v in attribute_cp.items():
            if v == '':
                del attribute[k]
        dialogue_act.update(attribute)

        return dialogue_act
Esempio n. 7
0
    def __init__(self):

        self.__estimator = RuleBasedDialogueActTypeEstimator()
        self.__extractor = RuleBasedAttributeExtractor()
Esempio n. 8
0
 def setUp(self):
     self.extractor = RuleBasedAttributeExtractor()
     self.estimator = RuleBasedDialogueActTypeEstimator()
Esempio n. 9
0
 def setUp(self):
     self.extractor = RuleBasedAttributeExtractor()