예제 #1
0
def get_r2_data():
    data = utils.get_r2_data()
    contents = []
    for i in data:
        k = i[0].rstrip(string.digits)  # 移除热搜词数字
        v = i[0][len(k):]  # 获取数字
        ks = extract_tags(k)
        for j in ks:
            if not j.isdigit():
                contents.append({'name': j, 'value': v})

    return jsonify({'kws': contents})
예제 #2
0
def get_r2():
    data = get_r2_data()
    d = []
    for i in data:
        k = i[0].rstrip(string.digits)  #去除权重数字
        v = i[0][len(k):]  #获取热搜数字
        ks = extract_tags(k)  #使用jieba提取关键字
        for j in ks:
            if not j.isdigit():
                d.append({'name': j, 'value': v})

    return jsonify({'kws': d})
예제 #3
0
파일: app.py 프로젝트: kleinlsl/nCov
def get_r2_data():
    data = utils.get_r2_data()
    # print(data)
    d = []
    for i in data:
        k = i[0].rstrip(string.digits)
        v = i[0][len(k):]
        ks = extract_tags(k)
        for j in ks:
            if not j.isdigit():
                d.append({"name": j, "value": v})
    # print(d)
    return jsonify({"kws": d})
예제 #4
0
def get_r2_data():
    data = utils.get_r2_data()
    d = []
    for i in data:
        # 删除字符串末尾热搜指数的数字,提取纯文字
        k = i[0].rstrip(string.digits)
        # 将末尾数字作为权重
        v = i[0][len(k):]
        ks = extract_tags(k)
        for j in ks:
            if not j.isdigit():
                d.append({"name": j, "value": v})
    return jsonify({"kws": d})
예제 #5
0
파일: app.py 프로젝트: xqd0924/cov
def get_r2_data():
    from jieba.analyse import extract_tags
    import string
    data = utils.get_r2_data()
    d = []
    for i in data:
        k = i[0].rstrip(string.digits)
        v = i[0][len(k):]
        ks = extract_tags(k)
        for j in ks:
            if not j.isdigit():
                d.append({'name': j, 'value': v})
    return jsonify({'kws': d})
예제 #6
0
파일: app.py 프로젝트: QiuBai-CN/Project
def get_r2_data():
    data = utils.get_r2_data(
    )  #格式 (('民警抗疫一线奋战16天牺牲1037364',), ('四川再派两批医疗队1537382',)
    d = []
    for i in data:
        k = i[0].rstrip(string.digits)  # 移除热搜数字
        v = i[0][len(k):]  # 获取热搜数字
        ks = extract_tags(k)  # 使用jieba 提取关键字
        print(k, v, ks)
        for j in ks:
            if not j.isdigit():
                d.append({"name": j, "value": v})
    return jsonify({"kws": d})
예제 #7
0
def get_r2_data():
    data = utils.get_r2_data()
    date, alberta, ontario, quebec = [], [], [], []
    for dt, a, o, q in data:
        date.append(dt.strftime("%Y-%m-%d"))
        alberta.append(float(a))
        ontario.append(float(o))
        quebec.append(float(q))
    return jsonify({
        "date": date,
        "alberta": alberta,
        "ontario": ontario,
        "quebec": quebec
    })
예제 #8
0
def get_r2():
    data = utils.get_r2_data()
    d = []
    for i in data:
        k = i[0].rstrip(string.digits)
        v = i[0][len(k):]
        ks = extract_tags(k)
        for j in ks:
            if not j.isdigit():
                d.append({'name': j, 'value': v})

    return jsonify({
        'code': 200,
        'message': 'ok',
        "kws": d

    })
예제 #9
0
def get_r2_data():
    res = []
    for tup in utils.get_r2_data():
        # print(tup)
        res.append({"name": tup[0], "value": int(tup[1])})
    return jsonify({"data": res})