创新实训记录15--可视化补充/高亮展示

目录

    • 可视化
    • 规格选择框逻辑处理:
    • 高亮显示

可视化

1.队友重新爬取的引用数据,做的可视化展示,将其适配到web网站上:
创新实训记录15--可视化补充/高亮展示_第1张图片
创新实训记录15--可视化补充/高亮展示_第2张图片
2.增加了词云的可视化(增加了停用词的选项):
创新实训记录15--可视化补充/高亮展示_第3张图片
代码:

//第三张柱形图
        var line_txt= {{ line_txt | safe }};
            var chart_1 = echarts.init(
                document.getElementById('line_txt'), 'roma', { renderer: 'canvas' });
            var option_1 = line_txt
            chart_1.setOption(option_1);
        //第四张柱形图
        var venue_pie_txt= {{venue_pie_txt | safe }};
            var chart_1 = echarts.init(
                document.getElementById('venue_pie_txt'), 'roma', { renderer: 'canvas' });
            var option_1 = venue_pie_txt
            chart_1.setOption(option_1);
#---------------------------------------------------------------------------------------
# 不同会议的平均被引用数统计
# 读取venues.txt,将不同会议对应的论文数放入一个字典

    file_venues = 'choose_paper/data/venues.txt'
    fvenues = open(file_venues,'r')
    venues_dic = { }
    for line in fvenues:
        venue = line.strip()
        if venue in venues_dic.keys() and venue is not '':
            venues_dic[venue]+=1
        elif venue is not '':
            temp = {}
            temp[venue] = 1
            venues_dic.update(temp)
        else:
            continue
    fvenues.close()

    f= open(file_venues,'r')
# 获取不同会议论文的总被引用量
    quote_dic = {}
    index = 0
    for line in f:
        venue = line.strip()
        if venue in quote_dic.keys() and venue is not '':
            if innum[index] is not ' 'and innum[index] is not '':
                quote_dic[venue]+=int(innum[index])
        elif venue is not '':
            temp = {}
            if innum[index] is ' 'or  innum[index] is '':
                temp[venue] =0
            else:
                temp[venue] = int(innum[index])
            quote_dic.update(temp)
        else:
            index+=1
            continue
        index +=1

# 数据预处理:获取不同会议论文的平均引用量
    avg_dic = {}
    for k in quote_dic:
        temp = {}
        temp[k] = round(quote_dic[k] / venues_dic[k], 2)
    # print(num_dic[k],years_dic[k],temp[k])
        avg_dic[k] = temp[k]

# 对数据进行筛选,选出排名前60的会议
    data_list = [{k: v} for k, v in avg_dic.items()]
    f = lambda x: list(x.values())[0]
    l=sorted(data_list, key=f, reverse=True)
    filter_l = l[:60]
# 构造x,y数据
    x_data1 = []
    y_data1 = []
    for item in filter_l:
        for k in item:
            x_data1.append(k)
            y_data1.append(item[k])

#绘制饼图
    venue_pie=Pie()\
    .add("会议/期刊", [list(z) for z in zip(x_data1, y_data1)],
        label_opts=opts.LabelOpts(is_show=False),
        radius=[40, 120])\
    .set_colors(["blue", "green", "yellow", "red", "pink", "orange", "purple","grey"])\
    .set_global_opts(title_opts=opts.TitleOpts(
                               title="不同会议/期刊的论文平均被引用量(排名前60)",),
                    legend_opts=opts.LegendOpts(is_show=False))\
    .set_series_opts(tooltip_opts=opts.TooltipOpts(
             formatter="{a} 
{b}: {c} ({d}%)"
),) venue_pie.render(path="choose_paper/data/graph/venue_pie.txt") # 显示图表 venue_pie_txt = "{" with open('choose_paper/data/graph/venue_pie.txt', 'r', encoding='utf-8') as f: line = f.readlines() for i in range(15, len(line)-4): venue_pie_txt += line[i] context = { 'paper_list': paper_list, 'graph_year_num_txt': graph_year_num_txt, 'graph_avg_txt': graph_avg_txt, 'line_txt':line_txt, 'venue_pie_txt':venue_pie_txt }

规格选择框逻辑处理:

通过前端的选择,进行后端数据的传递:

if('check' in request.POST):#有规则的(记得是五个!!)
                finalresult=predmodel("choose_paper/PaperCompare/model/model0.h5",articals,dict0,0)
            else:#无规则的
                finalresult=predmodel("choose_paper/PaperCompare/model/model0.h5",articals,dict0,0)

高亮显示

将结果的子空间信息以高亮的形式输出:

你可能感兴趣的:(创新实训记录15--可视化补充/高亮展示)