可视化展示——查询论文

实现输入论文名,查询论文的相关信息:

在这里插入图片描述
在这里插入图片描述

代码:
views.py文件:

def choose_detail(request):
    node= request.POST['node']
    artical=""
    author=""
    abstract=""
    affiliation=""
    IndexTerm=""
    keyword=""
    inlink=""
    outlink=""
    GeneralTerm=""
    num=0
    kk=""
    with open('choose_paper/data/nodes2.txt','r',encoding='utf-8') as f:
        line=f.readlines()
        for j in range(len(line)):
            line=line[j].split() 
            node_sp=node.split()          
            flag=False
            if(len(node_sp)==(len(line)-1)):
                for i in range(len(node_sp)):
                    if(node_sp[i]!=line[i+1]):
                        flag=False
                        break
                    else:
                        flag=True
            if flag==True:
                artical=line[0]
                num=j
                break
    with open('choose_paper/data/abstracts.txt','r',encoding='utf-8') as f:
        lines=f.readlines()
        abstract=lines[num]
    with open('choose_paper/data/affiliations.txt','r',encoding='utf-8') as f:
        lines=f.readlines()
        affiliation=lines[num]
    with open('choose_paper/data/articles.txt','r',encoding='utf-8') as f:
        lines=f.readlines()
        artical=lines[num]
    with open('choose_paper/data/authors.txt','r',encoding='utf-8') as f:
        lines=f.readlines()
        author=lines[num]
    with open('choose_paper/data/GeneralTerms.txt','r',encoding='utf-8') as f:
        lines=f.readlines()
        GeneralTerm=lines[num]
    with open('choose_paper/data/IndexTerms.txt','r',encoding='utf-8') as f:
        lines=f.readlines()
        IndexTerm=lines[num]
    with open('choose_paper/data/inlinks_nodes.txt','r',encoding='utf-8') as f:
        lines=f.readlines()
        inlink=lines[num]
    with open('choose_paper/data/keywords.txt','r',encoding='utf-8') as f:
        lines=f.readlines()
        keyword=lines[num]
    with open('choose_paper/data/outlinks_nodes.txt','r',encoding='utf-8') as f:
        lines=f.readlines()
        outlink=lines[num]
        # kk=abstract
    context = {
        'articals': artical,
        'authors ': author,
        'abstracts': abstract,
        'affiliations': affiliation,
        'IndexTerms ': IndexTerm,
        'keywords': keyword,
        'nodes': node,
        'inlinks': inlink,
        'outlinks':outlink,
        'GeneralTerms': GeneralTerm,
    }
    return render(request, 'choose_paper/paper_detail.html', context)

数据处理(论文id/论文year/论文venue 形式):

在这里插入图片描述
代码:

#用来生成id year venue 文件
with open('./articles.txt', 'r', encoding='utf-8') as f1:
        with open('./years.txt', 'r', encoding='utf-8') as f2:
            with open('./venues.txt', 'r', encoding="ISO-8859-1") as f3:
                ids=f1.readlines()
                years=f2.readlines()
                venues=f3.readlines()
                with open('./id_year_venue.txt', 'a', encoding='utf-8') as f4:
                    for i in range(len(ids)):
                        f4.write(ids[i])
                        f4.write(years[i])
                        f4.write(venues[i])
                        f4.write("\n")

获取满足条件的(年份&会议)的论文集合(id):

在这里插入图片描述
简单的输出:
在这里插入图片描述
代码:

 if  'paper_set' in request.POST:
            year = request.POST['datetimepicker']
            venue = request.POST['venue']
            articals=""
            with open("choose_paper/data/id_year_venue.txt",'r',encoding='utf-8') as f:
                lines=f.readlines()
                i=0
                while i< len(lines)-3:
                    a=lines[i].strip()
                    b=lines[i+1].strip()
                    c=lines[i+2].strip()
                    if(b==year and c==venue):
                        articals+=a
                        articals+=" "
                    i+=4
            context = {
                'articles':articals#获取满足年份,会议的论文id
            }

上述内容详见:

https://blog.csdn.net/qq_41798302/article/details/106744591
https://blog.csdn.net/qq_41798302/article/details/106819799

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值