예제 #1
0
파일: utils.py 프로젝트: yiwen92/my-project
def getFunc(content):
    server_name = func_tag_ip  # 开发:'http://192.168.1.204:51677';测试:'http://testing2.nlp.rpc';线上:'http://nlp.rpc'
    service_name = 'function_tag_for_edps'
    results = []
    req_dict = {
        "header": {
            "log_id": "0x666",
            "user_ip": "192.168.8.52",
            "uid": "0x666",
            "product_name": "algo_survey",
            "provider": "algo_survey"
        },
        "request": {
            "p": {
                #"content": "大客户经理-500强客户(企业移动云产品,月入2万)",
                "content": content,
                "id": "12"
            },
            "c": "edps_query_tag",
            "m": "get_edps_query_tags"
        }
    }
    client = pyrpc.HttpRpcClient(server_name)
    response = client.call_service(service_name, json.dumps(req_dict))
    try:
        should = json.loads(response)['response']['results']['should']
        must = json.loads(response)['response']['results']['must']
        for sh in should:
            results.append(sh)
        for sh in must:
            results.append(sh)
    except Exception, e:
        logging.warn('getFunc_error=%s' % (str(repr(e))))
예제 #2
0
파일: utils.py 프로젝트: yiwen92/my-project
def getCorp(content):
    server_name = corp_tag_ip  # 开发:'http://192.168.1.204:51699';测试:'http://10.9.10.10:51699';线上:'http://algo.rpc'
    service_name = 'corp_tag'
    resMap = {}
    req_dict = {
        "header": {},
        "request": {
            "p": {
                "corp_name": content  #"阿里巴巴"
            },
            "c": "corp_tag_simple",
            "m": "corp_tag_by_name"
        }
    }
    client = pyrpc.HttpRpcClient(server_name)
    response = client.call_service(service_name, json.dumps(req_dict))
    try:
        company_id = json.loads(response)['response']['result']['company_id']
        first_trade_list = json.loads(
            response)['response']['result']['first_trade_list']
        resMap['company_id'] = company_id
        resMap['first_trade_list'] = first_trade_list
        #print company_id, first_trade_list
    except Exception, e:
        logging.warn('getCorp_error=%s' % (str(repr(e))))
예제 #3
0
파일: utils.py 프로젝트: yiwen92/my-project
def getNerRes(text):
    server_name = ner_tag_ip  # 开发:'http://192.168.1.111:51631';测试:'http://10.9.10.23:51631';线上:'http://algo.rpc'
    service_name = 'echeng_ner_server'
    entity_type = [
        'IMPORTANT_POSITION', 'IMPORTANT_INDUSTRY', 'IMPORTANT_CORPORATION',
        'ENTITY'
    ]  # 职位,行业,公司, 实体
    nerRes = {}
    req_dict = {
        'header': {
            'product_name': 'algo.echeng_ner_server',
            'uid': '',
            'session_id': '',
            'user_ip': '',
            'local_ip': '127.0.0.1',
            'log_id': '123456'
        },
        'request': {
            'c': 'echeng_ner_server',
            'm': 'echeng_ner_server',
            'p': {
                'Strings': text
            }
        }
    }
    client = pyrpc.HttpRpcClient(server_name)
    response = client.call_service(service_name, json.dumps(req_dict))
    #print 'response : ', response       #json.dumps(response, ensure_ascii=False)
    try:
        results = json.loads(response)['response']['results']
        for res in results:
            entities = getter_info(res, 'entities', None, True)
            if entities is None: continue
            for en in entities:
                en_type = en['type']
                en_word = en['word']
                if en_type in entity_type:
                    if en_type not in nerRes:
                        nerRes[en_type] = []
                    nerRes[en_type].append(en_word)
        # 实体扩充行业和职位
        if 'ENTITY' in nerRes:
            if 'IMPORTANT_POSITION' not in nerRes:
                nerRes['IMPORTANT_POSITION'] = []
            if 'IMPORTANT_INDUSTRY' not in nerRes:
                nerRes['IMPORTANT_INDUSTRY'] = []
            for e in nerRes['ENTITY']:
                nerRes['IMPORTANT_POSITION'].append(e)
                nerRes['IMPORTANT_INDUSTRY'].append(e)

    except Exception, e:
        logging.warn('getNerRes_error=%s' % (str(repr(e))))
예제 #4
0
def get_user_preferences(server_name, service_name, qesStr):

    req_dict = {
        'header': {},
        'request': {
            'c': '',
            'm': 'consult_recommend',
            'p': {
                'consult_question': qesStr
            }
        }
    }
    #print 'req_dict', json.dumps(req_dict, ensure_ascii=False)
    client = pyrpc.HttpRpcClient(server_name)
    response = client.call_service(service_name, json.dumps(req_dict))
    #print type(response)
    return response
예제 #5
0
def get_user_preferences(server_name, service_name, cid, content, query):

    req_dict = {
        'header': {},
        'request': {
            'c': '',
            'm': query,
            'p': {
                'id': cid,
                'sql': content,
            }
        }
    }
    #print 'req_dict', json.dumps(req_dict, ensure_ascii=False)
    client = pyrpc.HttpRpcClient(server_name)
    response = client.call_service(service_name, json.dumps(req_dict))
    #print type(response)
    return response
예제 #6
0
def get_cv_by_id(ids):
    req_dict={
            'header':{
                'uname': 'zhanglong',
                'local_ip': '127.0.0.1'
                },
            'request':{
                'w': 'icdc_basic',
                'c':'resumes/logic_resume',
                'm':'get_multi_all',
                'p':{
                    'ids': ids  #[12345]
                    }
                }
            }
    client = pyrpc.HttpRpcClient(server_name)
    response = client.call_service(service_name, json.dumps(req_dict))
    return response
예제 #7
0
def get_cv_by_phone(phone):
    req_dict = {
        'header': {
            'uname': 'zhanglong',
            'local_ip': '127.0.0.1'
        },
        'request': {
            'w': 'icdc_basic',
            'c': 'resumes/logic_resume',
            'm': 'get_cv_by_phone',
            'p': {
                'phone': phone
            }
        }
    }
    client = pyrpc.HttpRpcClient(cv_ip)
    response = client.call_service(service_name, json.dumps(req_dict))
    return response
예제 #8
0
def get_user_preferences(server_name, service_name, qesCls, qesStr,
                         adviser_blacklist, cnt, uid):

    req_dict = {
        'header': {},
        'request': {
            'c': '',
            'm': 'consult_recommend',
            'p': {
                'consult_orientation': qesCls,
                'consult_question': qesStr,
                'adviser_blacklist': adviser_blacklist,
                'count': cnt,
                'uid': uid
            }
        }
    }
    #print 'req_dict', json.dumps(req_dict, ensure_ascii=False)
    client = pyrpc.HttpRpcClient(server_name)
    response = client.call_service(service_name, json.dumps(req_dict))
    #print type(response)
    return response