import json
from sementic_server.source.qa_graph.query_parser import QueryParser
from sementic_server.source.ner_task.semantic_tf_serving import SemanticSearch
from sementic_server.source.ner_task.account import Account
from sementic_server.source.intent_extraction.item_matcher import ItemMatcher
from sementic_server.source.qa_graph.query_interface import QueryInterface
from sementic_server.source.dependency_parser.dependency_parser import DependencyParser

if __name__ == '__main__':
    semantic = SemanticSearch()
    item_matcher = ItemMatcher(True)
    account = Account()
    while True:
        sentence = input("please input:")
        account_info = account.get_account_labels_info(sentence)
        intent = item_matcher.match(sentence, accounts_info=account_info)
        result, _ = semantic.sentence_ner_entities(intent)
        pprint(result)
        entity = result.get('entity') + result.get('accounts')
        relation = result.get('relation')
        intention = result.get('intent')

        if len(result.get("entity") + result.get("accounts")) == 0:
            print({"query": sentence, "error": "实体识别模块返回空值"})
            continue
        """
        # dependency_tree_recovered, tokens_recovered, dependency_graph, entities, relations =\
        #     DependencyParser().get_denpendency_tree(result["query"], entity, relation)
        """

        data = dict(query=sentence,
Пример #2
0
"""
@description: 测试代码   测试账户识别和命名实体识别功能是否正常
@author: Cui Rui long
@email: [email protected]
@time: 2019-06-05
@version: 0.1.1
"""

from sementic_server.source.ner_task.semantic_tf_serving import SemanticSearch
from sementic_server.source.ner_task.account import get_account_sets
from sementic_server.source.intent_extraction.item_matcher import ItemMatcher
from pprint import pprint

if __name__ == '__main__':
    semantic = SemanticSearch(test_mode=True)
    item_matcher = ItemMatcher(True, is_test=True)
    while True:
        sentence = input("please input:")
        result = item_matcher.match(sentence)
        result_account = get_account_sets(result["query"])
        result_ner = semantic.sentence_ner_entities(result_account)
        pprint(result_ner)