Пример #1
0
    flag_map,static_map=cul_flag(data,table,n,0.27,static_map)
    # print(flag_map)
    # print(data)


    # 5.建表
    fraudsters_table_name=config.get_tablename("fraudsters_name")
    sql_createTb = "create table {} (id int primary key auto_increment,data_type int(1) ,`{}`char(10) not null default ''," + "`{}` char(10) not null default ''," * (
                len(table) - 2) + "{} char(255) not null default '')CHARSET=utf8;"
    sql_createTb = sql_createTb.format(fraudsters_table_name, *table)
    # print(sql_createTb)
    con = db.DB()
    con.chech_table_exit(fraudsters_table_name, sql_createTb)
    # 6.数据写入
    data_arr = []
    # print(len(table))
    # print(flag_map)
    for key in data:
        adata = data[key]
        sql_insert = "insert into {} values(default,0," + "'{}'," * (len(adata)) + "'{}');"
        try:
            sql_insert = sql_insert.format(fraudsters_table_name, *adata, join(flag_map[key]))
        except:
            sql_insert = sql_insert.format(fraudsters_table_name, *adata, "无")
        print(sql_insert)
        con.insert(sql_insert)

    #7.保存table用于提供web接口
    np.save(curPath.mainPath()+"/fraudsters_zp/fraudsters.npy", table)
    sava_to_json.save_json(static_map,curPath.mainPath()+"/temp_file/fraudsters_static_map")
Пример #2
0
    # 5.建表
    traffic_table_name = config.get_tablename("traffic_name")
    sql_createTb = "create table {} (id int primary key auto_increment,data_type int(1) ,`{}`char(20) not null default ''," + "`{}` char(20) not null default ''," * (
        len(table) - 2) + "{} text(1000))CHARSET=utf8;"
    sql_createTb = sql_createTb.format(traffic_table_name, *table)
    print(table)
    print(sql_createTb)
    con = db.DB()
    con.chech_table_exit(traffic_table_name, sql_createTb)

    # 6.数据写入
    data_arr = []
    for key in data:
        adata = data[key]
        sql_insert = "insert into {} values(default,0," + "'{}'," * (
            len(adata)) + "'{}');"
        try:
            sql_insert = sql_insert.format(traffic_table_name, *adata,
                                           p.join(flag_map[key]))
        except:
            sql_insert = sql_insert.format(traffic_table_name, *adata, "无")
        print(sql_insert)
        con.insert(sql_insert)
    # print(data)  # {key(编号),value:数据}

    # 7.保存table用于提供web接口
    np.save(curPath.mainPath() + "/traffic/traffic.npy", table)
    # 3.5+4步骤中的数据static_map进行保存
    sava_to_json.save_json(
        static_map,
        curPath.mainPath() + "/temp_file/traffic_static_map")
Пример #3
0
                data_json.append(adata_json)
                name_set.add(name)
        if table == "intentkill":
            qid_start = 8000
            # 故意杀人
            for j in range(1000):
                adata = data[j]
                id = adata[0]
                name = adata[2]
                age = adata[4]
                type = adata[7]
                note = name + "," + str(age) + "岁," + type + "," + kill_note()
                # print(desc)
                sql_updata = "update {} set note=\"{}\" where id={};".format(
                    table, note, int(id))
                # print(sql_updata)
                con.updata(sql_updata)

                adata_json = {}
                adata_json["qid"] = qid_start + int(id)
                adata_json["type"] = table
                adata_json["note"] = note
                data_json.append(adata_json)
                name_set.add(name)
        sava_to_json.save_json(data_json,
                               curPath.mainPath() + "/bert/data/data.json")

        save_to_txt(
            name_set,
            curPath.mainPath() +
            "/bert/stopwords/姓名年龄岁.txt")  #bert里面进行用的时候,去掉这些姓名等词语,所以提前保存停止词
Пример #4
0
            "适用人群": "暂时没有",
            "单元": ["虚拟单元1(00017)", "虚拟单元2(00018)"]},
        "虚拟疗法(20)": {
            "age": "暂时没有",
            "edu": "暂时没有",
            "适用人群": "暂时没有",
            "单元": ["虚拟单元1(00017)", "虚拟单元2(00018)"]},
        "虚拟疗法(21)": {
            "age": "暂时没有",
            "edu": "暂时没有",
            "适用人群": "暂时没有",
            "单元": ["虚拟单元1(00017)", "虚拟单元2(00018)"]},
        "虚拟疗法(22)": {
            "age": "暂时没有",
            "edu": "暂时没有",
            "适用人群": "暂时没有",
            "单元": ["虚拟单元1(00017)", "虚拟单元2(00018)"]},
        "虚拟疗法(23)": {
            "age": "暂时没有",
            "edu": "暂时没有",
            "适用人群": "暂时没有",
            "单元": ["虚拟单元1(00017)", "虚拟单元2(00018)"]},
        "虚拟疗法(24)": {
            "age": "暂时没有",
            "edu": "暂时没有",
            "适用人群": "暂时没有",
            "单元": ["虚拟单元1(00017)", "虚拟单元2(00018)"]},

        }
    s.save_json(flag_method,curPath.mainPath()+"/temp_file/flag_method.json")
    s.save_json(method_plan,curPath.mainPath()+"/temp_file/method_plan.json")
Пример #5
0
        # print(table)
        print(sql_createTb)
        con = db.DB()
        con.chech_table_exit(position_table_name, sql_createTb)

        # 6.数据写入
        data_arr = []
        # print(len(table))
        # print(flag_map)
        for key in n_data:
            adata = n_data[key]
            sql_insert = "insert into {} values(default,0," + "'{}'," * (
                len(adata)) + "'{}');"
            try:
                sql_insert = sql_insert.format(position_table_name, *adata,
                                               p.join(flag_map[key]))
            except:
                sql_insert = sql_insert.format(position_table_name, *adata,
                                               "无")
            print(sql_insert)
            con.insert(sql_insert)

        # 7.保存table用于提供web接口:   如: data_rape.npy
        np.save(curPath.mainPath() + "/violence/{}.npy".format(tablename[i]),
                table)
        # 3.5+4步骤中的数据static_map进行保存  data_rape_static_map
        sava_to_json.save_json(
            static_map,
            curPath.mainPath() +
            "/temp_file/{}_static_map".format(tablename[i]))
Пример #6
0
        len(table) - 2) + "{} text(1000))CHARSET=utf8;"
    sql_createTb = sql_createTb.format(position_table_name, *table)
    # print(table)
    print(sql_createTb)
    con = db.DB()
    con.chech_table_exit(position_table_name, sql_createTb)

    #6.数据写入
    data_arr = []
    # print(len(table))
    # print(flag_map)
    for key in data:
        adata = data[key]
        sql_insert = "insert into {} values(default,0," + "'{}'," * (
            len(adata)) + "'{}');"
        try:
            sql_insert = sql_insert.format(position_table_name, *adata,
                                           join(flag_map[key]))
        except:
            sql_insert = sql_insert.format(position_table_name, *adata, "无")
        print(sql_insert)
        # con.insert(sql_insert)
    # print(data)  #{key(编号),value:数据}
    # print(len(table))  #144条

    # 7.保存table用于提供web接口
    np.save(curPath.mainPath() + "/position_zw/position.npy", table)
    # 3.5+4步骤中的数据static_map进行保存
    sava_to_json.save_json(
        static_map,
        curPath.mainPath() + "/temp_file/position_static_map")