How to use the nlu.nlu_framework.Nlu_Framework.match 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
# #     list1.append(dict1)
# #     # print force_utf8_new(match_dict_list[0])
# #
# #
# # list1 = force_utf8_new(list1)
# #
# # print yaml.safe_dump_all(list1, allow_unicode=True, encoding='utf-8')
# f = open('./test/test.yaml')
# input = yaml.safe_load_all(f)
# for i in input:
#     print force_utf8_new(i)

# print 'start'
# a = time.time()
# for i in range(1000):
match_dict_list = Nlu_Framework.match('我要听刘德华的冰雨')
print match_dict_list
# b = time.time()
github JK-River / RobotAIEngine / query_analysis / usage.py View on Github external
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)