예제 #1
0
def get_templates(properties):
    """
    得到模板
    :param properties:
    :return:
    """
    current_templates = []  # type: list[AnswerTemplate]
    if properties['阻力位'] != '无' and properties['阻力位'] != '无':
        current_templates = get_template_by_title("趋势", '趋势')
    elif properties['阻力位'] == '无':
        current_templates = get_template_by_title("趋势", '趋势无压力')
    elif properties['支撑位'] == '无':
        current_templates = get_template_by_title("趋势", '趋势无支撑')
    model_nums = len(current_templates)  # 得到模板数量
    select = random.randint(0, model_nums - 1)
    return current_templates[select]
예제 #2
0
def get_exchange_answer_template():
    """
    得到交易所板块的模板
    :param type_name:
    :return:
    """
    templates = get_template_by_title("交易所板块", '属于')
    model_nums = len(templates)  # 得到模板数量
    select = random.randint(0, model_nums - 1)
    return templates[select]
예제 #3
0
def get_region_answer_template():
    """
    得到地域回答的模板
    :param type_name:
    :return:
    """
    templates = get_template_by_title("地域", "所属")  # type: list[AnswerTemplate]
    model_nums = len(templates)  # 得到模板数量
    select = random.randint(0, model_nums - 1)
    return templates[select]
예제 #4
0
def answer_industry_contain(question):
    industry = get_industry_from_question(question)
    answers = ''
    if len(industry) == 0:
        answers = '我没有你要知道的【行业】信息', ""
    for one in industry:
        companies = stock_industry_service.get_one_industry_contain(one)
        one_answer = ''
        template = get_template_by_title("行业", "包含")[0].content
        template = template.replace('N', one)
        for one_c in companies:
            one_answer = one_answer + ',' + one_c['公司代码'] + one_c['公司简称']
        template = template.replace('M', one_answer)
        answers = answers + '</br>' + template

    return answers, industry
예제 #5
0
def answer_industry(domains):
    answers = ''
    for domain in domains:
        info = stock_industry_service.get_one_company_industry(
            domain.stock_num)
        if len(info) == 0:
            return "没有您要知道的【行业】信息", domains
        template = get_template_by_title("行业", "所属")[0].content
        for one in info:
            if one['级别'] == 'L1':
                template = template.replace('N', one['行业名称'])
            if one['级别'] == 'L2':
                template = template.replace('O', one['行业名称'])
            if one['级别'] == 'L3':
                template = template.replace('P', one['行业名称'])
        answers = answers + "</br>" + template.replace('M', domain.stock_name)
    return answers, domains
예제 #6
0
def get_answer_concept_templates(child_title):
    current_templates = get_template_by_title("概念", child_title)
    model_nums = len(current_templates)  # 得到模板数量
    select = random.randint(0, model_nums - 1)
    return current_templates[select]
예제 #7
0
def get_templates(properties):
    current_status = stock_trends_service.get_stock_status(properties)
    current_templates = get_template_by_title("持有或卖", current_status)
    model_nums = len(current_templates)  # 得到模板数量
    select = random.randint(0, model_nums - 1)
    return current_templates[select]