Beispiel #1
0
import timeit
import json
import logging

from django.http import JsonResponse
from django.views.decorators.csrf import csrf_exempt
from sementic_server.source.ner_task.semantic_tf_serving import SemanticSearch
from sementic_server.source.intent_extraction.item_matcher import ItemMatcher
from sementic_server.source.ner_task.system_info import SystemInfo
from sementic_server.source.ner_task.account import get_account_sets
from sementic_server.source.qa_graph.query_parser import QueryParser
from sementic_server.source.qa_graph.query_interface import QueryInterface

# 在这里定义在整个程序都会用到的类的实例
semantic = SemanticSearch()
item_matcher = ItemMatcher(new_actree=True)

logger = logging.getLogger("server_log")


@csrf_exempt
def get_result(request):
    """
    input: 接收客户端发送的POST请求:{"sentence": "raw_sentence"}
    output: 服务器返回JSON格式的数据,返回的数据格式如下:


    :param request: 用户输入的查询句子
    :return
    """
Beispiel #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)
@version: 0.0.1
"""

import os
from pprint import pprint
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
        """
Beispiel #4
0
from sementic_server.source.intent_extraction.item_matcher import ItemMatcher
from sementic_server.source.qa_graph.query_parser import QueryParser
from sementic_server.source.qa_graph.query_interface import QueryInterface
from sementic_server.source.dependency_parser.dependency_parser import DependencyParser
from sementic_server.source.recommend.recommend_server import RecommendServer

# 定义整体服务用到的日志文件
logger = logging.getLogger("server_log")
recommend_logger = logging.getLogger("recommend_log")
correction_logger = logging.getLogger("correction_log")
correction_behavior_logger = logging.getLogger("correction_behavior_log")

# 在这里定义在整个程序都会用到的类的实例
account_model = Account()
semantic = SemanticSearch()
item_matcher = ItemMatcher(
    loggers=[correction_logger, correction_behavior_logger], new_actree=True)
dependency_parser = DependencyParser()
recommend_server = RecommendServer(recommend_logger)


def account_recognition(sentence):
    """
    账号识别模块调用
    :param sentence:
    :return:
    """
    logger.info("Account Recognition model...")
    t_account = timeit.default_timer()
    accounts_info = account_model.get_account_labels_info(sentence)
    logger.info(accounts_info)
    logger.info("Account Recognition model done. Time consume: {0}".format(