How to use the nlu.nlu_framework.Nlu_Framework.register function in nlu

To help you get started, we’ve selected a few nlu examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JK-River / RobotAIEngine / query_analysis / main.py View on Github external
# Nlu_Framework.register(battery.Battery)
# Nlu_Framework.register(dance.Dance)
# Nlu_Framework.register(display.Display)
# Nlu_Framework.register(entertainment.Entertainment)
# Nlu_Framework.register(photo.Photo)
# Nlu_Framework.register(recognition.Recognition)
# Nlu_Framework.register(xiaoyi.XiaoYi)
# Nlu_Framework.register(story.Story)
# Nlu_Framework.register(expand_instruction.ExtendInstruction)
# Nlu_Framework.register(volume.Volume)
# Nlu_Framework.register(mode.Mode)
# Nlu_Framework.register(motion.Motion)
# Nlu_Framework.register(profile.Profile)
# Nlu_Framework.register(vehicle.Vehicle)
# Nlu_Framework.register(sight.Sight)
Nlu_Framework.register(music.Music)
# Nlu_Framework.register(phone.Phone)
# Nlu_Framework.register(trick.Trick)
# Nlu_Framework.register(store_location.StoreLocation)

# def load_from_file(file_name):
#     """
#     从文件中直接加载词典,只有词,没有属性
#     :param file_name:
#     :param group_name:
#     :return:
#     """
#     with open(file_name) as f:
#         test_list = [line.strip().replace('\n', '') for line in f if line and not line.startswith('=')]
#     return test_list
#
# test_list = load_from_file('./test/test.csv')
github JK-River / RobotAIEngine / query_analysis / usage.py View on Github external
from utils.utils import range_tag, attach_perperty


class Test(object):
    # 标识是test领域(这个service字段必须存在,命中本类中正则时,会输出这个字段)
    service = 'test'
    # 表示抓取2个字长度的信息,输出字段为name
    name = range_tag(2, 'user_name')

    # 正则规则:我的名字是小明
    name_case1 = '我的名字是' + name

    # 生成规则对象
    rule_case1 = Rule(attach_perperty(name_case1, {'operation': 'query', 'rule': 1}))

Nlu_Framework.register(Test)

match_dict_list = Nlu_Framework.match('我的名字是小明')

for k, v in match_dict_list[0].items():
    print '{} : {}'.format(k, v)