欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

可视化展示——查询论文

程序员文章站 2022-03-22 20:22:11
...

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

可视化展示——查询论文
可视化展示——查询论文

代码:
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

相关标签: 可视化 python