Exemplo n.º 1
0
def get_hotword_list():
    hotword_sort = OrderedDict()
    if config.analyze_lang.lower() == "all":
        data_hotword = dbc.sql_select(
            'select language, hotword '
            'from %s '
            'where scene="总计" '
            'and sdk_version = "%s" '
            'order by language' %
            (HOTWORD_RESULT_NAME, config.new_sdk_version))
        languages = []
        [
            languages.append(info[0]) for info in data_hotword
            if info[0] not in languages
        ]
    else:
        data_hotword = dbc.sql_select(
            "select hotword \
                                       from %s \
                                       where scene='总计' \
                                       and language='%s' \
                                       order by hotword" %
            (HOTWORD_RESULT_NAME, config.analyze_lang.capitalize()))
        languages = [config.analyze_lang.capitalize()]

    for lang in languages:
        for data in data_hotword:
            if data[0] == lang:
                hotword_sort.get(lang).append(data[1]) if hotword_sort.__contains__(lang) \
                    else hotword_sort.setdefault(lang, []).append(data[1])

    return hotword_sort
Exemplo n.º 2
0
def get_keyword_list():
    keyword_sort = OrderedDict()
    if config.analyze_lang.lower() == "all":
        data_keyword = dbc.sql_select("select language, keyword \
                                       from %s \
                                       where scene=1 \
                                       order by language" %
                                      KEYWORD_BENCHMARK_NAME)
        languages = []
        [
            languages.append(info[0]) for info in data_keyword
            if info[0] not in languages
        ]
    else:
        data_keyword = dbc.sql_select(
            "select keyword \
                                       from %s \
                                       where scene=1 \
                                       and language='%s' \
                                       order by keyword" %
            (BENCHMARK_NAME, config.analyze_lang.capitalize()))
        languages = [config.analyze_lang.capitalize()]

    for lang in languages:
        for data in data_keyword:
            if data[0] == lang:
                keyword_sort.get(lang).append(data[1]) if keyword_sort.__contains__(lang) \
                    else keyword_sort.setdefault(lang, []).append(data[1])

    return keyword_sort
Exemplo n.º 3
0
def get_category_lists(analyze_lang):
    category_sort = OrderedDict()
    if analyze_lang.lower() == "all":
        data_category = dbc.sql_select("select net_status, category, language \
                                        from %s \
                                        where scene=1 \
                                        order by language" % BENCHMARK_NAME)
        languages = []
        [
            languages.append(info[2]) for info in data_category
            if info[2] not in languages
        ]
    else:
        data_category = dbc.sql_select(
            "select net_status, category \
                                        from %s \
                                        where scene=1 \
                                        and language='%s' \
                                        order by net_status" %
            (BENCHMARK_NAME, analyze_lang.capitalize()))
        languages = [analyze_lang.capitalize()]

    for lang in languages:
        for data in data_category:
            if data[2] == lang:
                if category_sort.__contains__(lang):
                    category_sort.get(lang).get(data[0]).append(data[1]) if category_sort.get(lang).__contains__(data[0]) \
                    else category_sort.get(lang).setdefault(data[0], []).append(data[1])
                else:
                    category_sort.setdefault(lang,
                                             {}).update({data[0]: [data[1]]})

    #print(category_sort)
    return category_sort
Exemplo n.º 4
0
def get_keyword_target(lang, keyword):
    target = dbc.sql_select('select target, number '
                            'from %s '
                            'where keyword="%s" '
                            'and language="%s" '
                            'order by scene' %
                            (KEYWORD_BENCHMARK_NAME, keyword, lang))
    return target
Exemplo n.º 5
0
def get_target(lang, net_status, category):
    target = dbc.sql_select('select word, sentence, meaning, number '
                            'from %s '
                            'where category="%s" '
                            'and net_status="%s" '
                            'and language="%s" '
                            'order by scene' %
                            (BENCHMARK_NAME, category, net_status, lang))
    return target
Exemplo n.º 6
0
def get_hotword_data(lang, hotword, sdk_version):
    try:
        data = dbc.sql_select(
            'select pass_rate, number '
            'from %s '
            'where hotword="%s" '
            'and sdk_version="%s" '
            'and language="%s" '
            'order by scene' %
            (HOTWORD_RESULT_NAME, hotword, sdk_version, lang))
        return data
    except pymysql.Error as e:
        print(e)
Exemplo n.º 7
0
def get_nlu_data(lang, net_status, category, sdk_version):
    try:
        nlu_data = dbc.sql_select(
            'select nlu, number '
            'from %s '
            'where category="%s" '
            'and sdk_version="%s" '
            'and net_status="%s" '
            'and language="%s" ' %
            (NLU_RESULT_NAME, category, sdk_version, net_status, lang))
        return nlu_data
    except pymysql.Error as e:
        print(e)
Exemplo n.º 8
0
def get_sdk_data(lang, net_status, category, sdk_version):
    try:
        data = dbc.sql_select(
            'select word, sentence, meaning, number '
            'from %s '
            'where category="%s" '
            'and sdk_version="%s" '
            'and net_status="%s" '
            'and language="%s" '
            'order by scene' %
            (SDK_RESULT_NAME, category, sdk_version, net_status, lang))
        return data
    except pymysql.Error as e:
        print(e)
Exemplo n.º 9
0
    # 计算新旧数据差值并填表
    for gap in gap_slot:
        excel_row_tmp[gap] = cal_gap(excel_row_tmp[gap - 1][:-1],
                                     excel_row_tmp[gap - 2][:-1])

    return excel_row_tmp


def cal_gap(data1, data2):
    return "%.2f" % (float(data2) - float(data1)) + "%"


if __name__ == '__main__':
    target = dbc.sql_select('select ben_word, ben_sentence, ben_meaning '
                            'from CNS_BENCHMARK_MAP '
                            'where category="Audio" '
                            'and net_status="Mix" '
                            'and language="Mandarin" '
                            'order by scene')

    data_old = dbc.sql_select('select word, sentence, meaning, material '
                              'from CNS_SDK_Test '
                              'where category="Audio" '
                              'and created_at like "2020-05-22%" '
                              'and net_status="Mix" '
                              'and language="Mandarin" '
                              'order by scene')

    data_new = dbc.sql_select('select word, sentence, meaning '
                              'from CNS_SDK_Test '
                              'where category="Audio" '
                              'and created_at like "2020-05-29%" '