分享一个基于Python的文献检索与查询系统flask毕设文献分享交流系统(源码、调试、LW、开题、PPT)

本文主要是介绍分享一个基于Python的文献检索与查询系统flask毕设文献分享交流系统(源码、调试、LW、开题、PPT),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

💕💕作者:计算机源码社
💕💕个人简介:本人 八年开发经验,擅长Java、Python、PHP、.NET、Node.js、Android、微信小程序、爬虫、大数据、机器学习等,大家有这一块的问题可以一起交流!
💕💕学习资料、程序开发、技术解答、文档报告
💕💕如需要源码,可以扫取文章下方二维码联系咨询

💕💕Java项目
💕💕微信小程序项目
💕💕Android项目
💕💕Python项目
💕💕PHP项目
💕💕ASP.NET项目
💕💕Node.js项目
💕💕选题推荐

项目实战|基于python的智能文献管理系统文献搜索查询系统

文章目录

  • 1、研究背景
  • 2、研究目的和意义
  • 3、系统研究内容
  • 4、系统页面设计
  • 5、参考文献
  • 6、核心代码

1、研究背景

  随着学术研究的日益深入和信息量的不断增加,如何高效地检索和管理大量的文献信息成为研究者面临的重大挑战。传统的文献检索方式已经难以满足当前的需求,尤其是在数据存储和查询效率方面。基于Python的文献检索与查询系统应运而生,旨在通过现代化技术手段,提升文献管理和检索的便捷性和效率。借助Django框架和MySQL数据库,系统能够支持大规模数据的快速存储与查询,为学术研究提供强有力的技术支持。

2、研究目的和意义

  开发基于Python的文献检索与查询系统,主要目的是为研究者提供一个便捷、高效的文献管理和检索平台。通过该系统,用户不仅可以轻松查找和管理文献信息,还可以通过个性化推荐功能获取与自己研究方向相关的文献资源。系统还集成了在线论坛功能,促进研究者之间的学术交流和思想碰撞,从而为研究的深入开展提供支持。管理员则可以通过系统高效管理用户和文献信息,确保平台的平稳运行和数据的有效利用。

  开发此系统的意义在于它解决了传统文献管理和检索方式的诸多不足之处,极大地提升了研究者获取和利用文献资源的效率。通过个性化推荐,系统可以为用户提供更为精准的文献资源,帮助研究者在浩瀚的学术资料中快速找到与自己研究相关的内容。在线论坛的集成使得学术交流更加便捷,用户可以在平台上讨论、分享和注释文献。系统的管理功能保障了文献信息的有序管理,避免了信息的冗余和混乱,为学术研究提供了一个高效、可靠的平台。

3、系统研究内容

基于Python的文献检索与查询系统的研究内容主要围绕以下几个方面展开:

系统的用户管理模块是核心部分之一,旨在为管理员提供便捷的用户信息管理功能。通过该模块,管理员可以添加、删除、修改用户信息,设置用户权限,并监控用户的活动。这为系统的安全性和稳定性提供了保障。此外,文献类型管理和文献信息管理模块允许管理员对系统中的文献资源进行分类管理和维护,确保文献数据的准确性和完整性。文献注释管理功能使用户能够对文献进行注释和标记,为用户提供更为个性化的文献管理体验。

系统的文献检索与查询功能是研究的重点之一。该功能基于Python和Django框架构建,结合MySQL数据库,实现了高效的文献查询和检索。用户可以通过关键字、文献类型、作者等多种条件进行精准搜索,快速找到所需的文献信息。系统的个性化推荐模块基于用户的搜索历史和偏好,智能推荐相关文献资源,帮助用户更高效地获取有价值的学术资料。

系统还集成了在线论坛和公告管理模块,以促进用户之间的学术交流。在线论坛模块提供了一个开放的讨论平台,用户可以就某一文献或研究主题进行深入交流和讨论。同时,公告管理模块允许管理员发布最新的系统更新、学术资源或研究活动等重要信息,确保用户能够及时获取到最新的学术动态。通过这些功能的实现,系统不仅提供了一个强大的文献检索平台,还为用户打造了一个便捷的学术交流和资源共享的环境。

4、系统页面设计

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

如需要源码,可以扫取文章下方二维码联系咨询

5、参考文献

[1]左学斌,李芯,刘浩红,等.面向国家标准内容的印刷检测管理系统设计[J].北京印刷学院学报,2023,31(06):1-6.DOI:10.19461/j.cnki.1004-8626.2023.06.001.
[2]刘乾.基于云计算的图书馆文献资源信息化管理系统设计[J].信息与电脑(理论版),2023,35(08):54-56.
[3]赵俊逸.基于Web的影像科智能信息管理系统研究与设计[D].郑州大学,2022. DOI:10.27466/d.cnki.gzzdu.2022.003715.
[4]张云.汽车发动机零部件试验管理系统研究与开发[D].武汉理工大学,2021. DOI:10.27381/d.cnki.gwlgu.2021.000800.
[5]李研研.基于SQLserver的地质文献管理系统的设计与实现[J].吉林地质,2021,40(01):69-81.
[6]王长君,王军华,金涛,等.《机动车电子标识密钥管理系统技术要求》(GB/T 37985-2019)国家标准解读[J].中国标准化,2021,(05):165-171.
[7]吴鑫.基于Web的狂蝇科物种数据管理系统设计[D].北京林业大学,2020. DOI:10.26949/d.cnki.gblyu.2020.001398.
[8]姚晓娜,祝忠明,刘巍,等.机构知识库在科研评价服务中的应用及实现[J].数字图书馆论坛,2020,(06):22-27.
[9]黄薇,于静,张慧琴.基于新一代统一资源管理系统Alma的文献清点实践研究[J].图书馆理论与实践,2020,(03):58-61+72.DOI:10.14064/j.cnki.issn1005-8214.2020.03.015.
[10]陈彦海.高校图书馆管理系统数据分析——以西安培华学院为例[J].传媒论坛,2020,3(09):101-102.
[11]胡雪聪,鄢万斌,杜孰道.基于云存储的会议纪要管理系统设计和实现[J].信息与电脑(理论版),2020,32(07):82-85.
[12]苏建华.基于RFID的低利用率文献集中存储研究[J].兰台内外,2019,(22):47-48.
[13]逄丽东.东北抗联数字文献档案集中管理模式[J].边疆经济与文化,2019,(05):117-118.
[14]薛健.基于数据挖掘技术的高校图书信息化管理研究[J].信息技术,2019,(02):75-78+83.DOI:10.13274/j.cnki.hdzj.2019.02.017.
[15]翟中会,陈伟,蔡琴.基于EndNote的文献管理系统评价流程优化策略[J].图书馆研究与工作,2019,(02):36-39.
[16]张宇飞,王伟.上海市“智慧交通安全管理系统”构建内容[J].交通与运输,2018,34(06):59-60.
[17]乔雅,刘洋,张文都.基于RFID技术的图书馆文献智能管理系统研究[J].微型电脑应用,2018,34(11):18-20.
[18]李倩.C程序设计实践教学中课程设计的实施与研究[J].现代信息科技,2018,2(10):145-146+148.
[19]谭明杰,余娉.透视我国远程高等教育研究图景:主题、热点与趋势——基于8本CSSCI期刊2017年度文献的系统分析[J].现代远程教育研究,2018,(05):39-48.
[20]严雪.大数据背景下科研档案文献数字化趋势[J].兰台世界,2018,(08):81-84.DOI:10.16565/j.cnki.1006-7744.2018.08.22.

6、核心代码

# coding:utf-8
__author__ = "ila"import logging, os, json, configparser
import time
from datetime import datetimeimport xlrd
from flask import request, jsonify,session
from sqlalchemy.sql import func,and_,or_,case
from sqlalchemy import cast, Integer,Float
from api.models.brush_model import *
from . import main_bp
from utils.codes import *
from utils.jwt_auth import Auth
from configs import configs
from utils.helper import *
import random
import smtplib
from email.mime.text import MIMEText
from email.utils import formataddr
from email.header import Header
from utils.baidubce_api import BaiDuBce
from api.models.config_model import config# 注册接口
@main_bp.route("/pythonfa5876je/wenxianxinxi/register", methods=['POST'])
def pythonfa5876je_wenxianxinxi_register():if request.method == 'POST':msg = {'code': normal_code, 'message': 'success', 'data': [{}]}req_dict = session.get("req_dict")error = wenxianxinxi.createbyreq(wenxianxinxi, wenxianxinxi, req_dict)if error!=None:msg['code'] = crud_error_codemsg['msg'] = "注册用户已存在"return jsonify(msg)# 登录接口
@main_bp.route("/pythonfa5876je/wenxianxinxi/login", methods=['GET','POST'])
def pythonfa5876je_wenxianxinxi_login():if request.method == 'GET' or request.method == 'POST':msg = {"code": normal_code, "msg": "success", "data": {}}req_dict = session.get("req_dict")req_model = session.get("req_dict")try:del req_model['role']except:passdatas = wenxianxinxi.getbyparams(wenxianxinxi, wenxianxinxi, req_model)if not datas:msg['code'] = password_error_codemsg['msg']='密码错误或用户不存在'return jsonify(msg)req_dict['id'] = datas[0].get('id')try:del req_dict['mima']except:passreturn Auth.authenticate(Auth, wenxianxinxi, req_dict)# 登出接口
@main_bp.route("/pythonfa5876je/wenxianxinxi/logout", methods=['POST'])
def pythonfa5876je_wenxianxinxi_logout():if request.method == 'POST':msg = {"msg": "退出成功","code": 0}req_dict = session.get("req_dict")return jsonify(msg)# 重置密码接口
@main_bp.route("/pythonfa5876je/wenxianxinxi/resetPass", methods=['POST'])
def pythonfa5876je_wenxianxinxi_resetpass():''''''if request.method == 'POST':msg = {"code": normal_code, "msg": "success"}req_dict = session.get("req_dict")if req_dict.get('mima') != None:req_dict['mima'] = '123456'error = wenxianxinxi.updatebyparams(wenxianxinxi, wenxianxinxi, req_dict)if error != None:msg['code'] = crud_error_codemsg['msg'] = errorelse:msg['msg'] = '密码已重置为:123456'return jsonify(msg)# 获取会话信息接口
@main_bp.route("/pythonfa5876je/wenxianxinxi/session", methods=['GET'])
def pythonfa5876je_wenxianxinxi_session():''''''if request.method == 'GET':msg = {"code": normal_code, "data": {}}req_dict={"id":session.get('params').get("id")}msg['data']  = wenxianxinxi.getbyparams(wenxianxinxi, wenxianxinxi, req_dict)[0]return jsonify(msg)# 分类接口(后端)
@main_bp.route("/pythonfa5876je/wenxianxinxi/page", methods=['GET'])
def pythonfa5876je_wenxianxinxi_page():''''''if request.method == 'GET':msg = {"code": normal_code, "msg": "success",  "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":10,"list":[]}}req_dict = session.get("req_dict")userinfo = session.get("params")try:__hasMessage__=wenxianxinxi.__hasMessage__except:__hasMessage__=Noneif __hasMessage__ and __hasMessage__!="否":tablename=session.get("tablename")if tablename!="users" and session.get("params")!=None and wenxianxinxi!='chat':req_dict["userid"]=session.get("params").get("id")tablename=session.get("tablename")if tablename=="users" :try:passexcept:passelse:mapping_str_to_object = {}for model in Base_model._decl_class_registry.values():if hasattr(model, '__tablename__'):mapping_str_to_object[model.__tablename__] = modeltry:__isAdmin__=mapping_str_to_object[tablename].__isAdmin__except:__isAdmin__=Noneif __isAdmin__!="是" and session.get("params")!=None:req_dict["userid"]=session.get("params").get("id")else:try:del req_dict["userid"]except:passclause_args = []or_clauses = or_(*clause_args)msg['data']['list'], msg['data']['currPage'], msg['data']['totalPage'], msg['data']['total'], \msg['data']['pageSize']  = wenxianxinxi.page(wenxianxinxi, wenxianxinxi, req_dict, or_clauses)return jsonify(msg)# 排序接口
@main_bp.route("/pythonfa5876je/wenxianxinxi/autoSort", methods=['GET'])
def pythonfa5876je_wenxianxinxi_autosort():''''''if request.method == 'GET':msg = {"code": normal_code, "msg": "success",  "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":10,"list":[]}}req_dict = session.get("req_dict")req_dict['sort']='clicktime'req_dict['order']='desc'try:__browseClick__= wenxianxinxi.__browseClick__except:__browseClick__=Noneif __browseClick__ =='是':req_dict['sort']='clicknum'elif __browseClick__ =='时长':req_dict['sort']='browseduration'else:req_dict['sort']='clicktime'msg['data']['list'], msg['data']['currPage'], msg['data']['totalPage'], msg['data']['total'], \msg['data']['pageSize']  = wenxianxinxi.page(wenxianxinxi, wenxianxinxi, req_dict)return jsonify(msg)# 分页接口(前端)
@main_bp.route("/pythonfa5876je/wenxianxinxi/list", methods=['GET'])
def pythonfa5876je_wenxianxinxi_list():''''''if request.method == 'GET':msg = {"code": normal_code, "msg": "success",  "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":10,"list":[]}}req_dict = session.get("req_dict")if req_dict.__contains__('vipread'):del req_dict['vipread']userinfo = session.get("params")try:__foreEndList__=wenxianxinxi.__foreEndList__except:__foreEndList__=Noneif __foreEndList__ and __foreEndList__!="否":tablename=session.get("tablename")if tablename!="users" and session.get("params")!=None:req_dict['userid']=session.get("params").get("id")try:__foreEndListAuth__=wenxianxinxi.__foreEndListAuth__except:__foreEndListAuth__=Noneif __foreEndListAuth__ and __foreEndListAuth__!="否":tablename=session.get("tablename")if tablename!="users" and session.get("params")!=None:req_dict['userid']=session.get("params").get("id")tablename=session.get("tablename")if tablename=="users" :try:del req_dict["userid"]except:passelse:mapping_str_to_object = {}for model in Base_model._decl_class_registry.values():if hasattr(model, '__tablename__'):mapping_str_to_object[model.__tablename__] = modeltry:__isAdmin__=mapping_str_to_object[tablename].__isAdmin__except:__isAdmin__=Noneif __isAdmin__!="是" and session.get("params")!=None:req_dict["userid"]=session.get("params").get("id")else:try:del req_dict["userid"]except:passif 'luntan' in 'wenxianxinxi':if 'userid' in req_dict.keys():del req_dict["userid"]if 'discuss' in 'wenxianxinxi':if 'userid' in req_dict.keys():del req_dict["userid"]msg['data']['list'], msg['data']['currPage'], msg['data']['totalPage'], msg['data']['total'], \msg['data']['pageSize']  = wenxianxinxi.page(wenxianxinxi, wenxianxinxi, req_dict)return jsonify(msg)# 保存接口(后端)
@main_bp.route("/pythonfa5876je/wenxianxinxi/save", methods=['POST'])
def pythonfa5876je_wenxianxinxi_save():''''''request.operation = "新增文献信息"if request.method == 'POST':msg = {"code": normal_code, "msg": "success", "data": {}}req_dict = session.get("req_dict")for key in req_dict:if req_dict[key] == '':req_dict[key] = Noneerror= wenxianxinxi.createbyreq(wenxianxinxi, wenxianxinxi, req_dict)if error!=None:msg['code'] = crud_error_codemsg['msg'] = errorreturn jsonify(msg)# 添加接口(前端)
@main_bp.route("/pythonfa5876je/wenxianxinxi/add", methods=['POST'])
def pythonfa5876je_wenxianxinxi_add():''''''request.operation = "新增文献信息"if request.method == 'POST':msg = {"code": normal_code, "msg": "success", "data": {}}req_dict = session.get("req_dict")try:__foreEndListAuth__=wenxianxinxi.__foreEndListAuth__except:__foreEndListAuth__=Noneif __foreEndListAuth__ and __foreEndListAuth__!="否":tablename=session.get("tablename")if tablename!="users":req_dict['userid']=session.get("params").get("id")error= wenxianxinxi.createbyreq(wenxianxinxi, wenxianxinxi, req_dict)if error!=None:msg['code'] = crud_error_codemsg['msg'] = errorreturn jsonify(msg)# 踩、赞接口
@main_bp.route("/pythonfa5876je/wenxianxinxi/thumbsup/<id_>", methods=['GET'])
def pythonfa5876je_wenxianxinxi_thumbsup(id_):''''''if request.method == 'GET':msg = {"code": normal_code, "msg": "success", "data": {}}req_dict = session.get("req_dict")id_=int(id_)type_=int(req_dict.get("type",0))rets=wenxianxinxi.getbyid(wenxianxinxi, wenxianxinxi,id_)update_dict={"id":id_,}if type_==1:#赞update_dict["thumbsupnum"]=int(rets[0].get('thumbsupnum'))+1elif type_==2:#踩update_dict["crazilynum"]=int(rets[0].get('crazilynum'))+1error = wenxianxinxi.updatebyparams(wenxianxinxi, wenxianxinxi, update_dict)if error!=None:msg['code'] = crud_error_codemsg['msg'] = errorreturn jsonify(msg)# 获取详情信息(后端)
@main_bp.route("/pythonfa5876je/wenxianxinxi/info/<id_>", methods=['GET'])
def pythonfa5876je_wenxianxinxi_info(id_):''''''if request.method == 'GET':msg = {"code": normal_code, "msg": "success", "data": {}}data = wenxianxinxi.getbyid(wenxianxinxi, wenxianxinxi, int(id_))if len(data)>0:msg['data']=data[0]#浏览点击次数try:__browseClick__= wenxianxinxi.__browseClick__except:__browseClick__=Noneif __browseClick__  and  "clicknum"  in wenxianxinxi.__table__.columns:click_dict={"id":int(id_),"clicknum":str(int(data[0].get("clicknum") or 0)+1)}ret=wenxianxinxi.updatebyparams(wenxianxinxi,wenxianxinxi,click_dict)if ret!=None:msg['code'] = crud_error_codemsg['msg'] = retreturn jsonify(msg)# 获取详情信息(前端)
@main_bp.route("/pythonfa5876je/wenxianxinxi/detail/<id_>", methods=['GET'])
def pythonfa5876je_wenxianxinxi_detail(id_):''''''if request.method == 'GET':msg = {"code": normal_code, "msg": "success", "data": {}}data = wenxianxinxi.getbyid(wenxianxinxi, wenxianxinxi, int(id_))if len(data)>0:msg['data']=data[0]#浏览点击次数try:__browseClick__= wenxianxinxi.__browseClick__except:__browseClick__=Noneif __browseClick__ and "clicknum" in wenxianxinxi.__table__.columns:click_dict={"id":int(id_),"clicknum":str(int(data[0].get("clicknum") or 0)+1)}ret=wenxianxinxi.updatebyparams(wenxianxinxi,wenxianxinxi,click_dict)if ret!=None:msg['code'] = crud_error_codemsg['msg'] = retreturn jsonify(msg)# 更新接口
@main_bp.route("/pythonfa5876je/wenxianxinxi/update", methods=['POST'])
def pythonfa5876je_wenxianxinxi_update():''''''request.operation = "更新文献信息"if request.method == 'POST':msg = {"code": normal_code, "msg": "success", "data": {}}req_dict = session.get("req_dict")if req_dict.get("mima") and "mima" not in wenxianxinxi.__table__.columns :del req_dict["mima"]if req_dict.get("password") and "password" not in wenxianxinxi.__table__.columns :del req_dict["password"]try:del req_dict["clicknum"]except:passerror = wenxianxinxi.updatebyparams(wenxianxinxi, wenxianxinxi, req_dict)if error!=None:msg['code'] = crud_error_codemsg['msg'] = errorreturn jsonify(msg)# 删除接口
@main_bp.route("/pythonfa5876je/wenxianxinxi/delete", methods=['POST'])
def pythonfa5876je_wenxianxinxi_delete():''''''request.operation = "删除文献信息"if request.method == 'POST':msg = {"code": normal_code, "msg": "success", "data": {}}req_dict = session.get("req_dict")error=wenxianxinxi.delete(wenxianxinxi,req_dict)if error!=None:msg['code'] = crud_error_codemsg['msg'] = errorreturn jsonify(msg)# 投票接口
@main_bp.route("/pythonfa5876je/wenxianxinxi/vote/<int:id_>", methods=['POST'])
def pythonfa5876je_wenxianxinxi_vote(id_):''''''if request.method == 'POST':msg = {"code": normal_code, "msg": "success"}data= wenxianxinxi.getbyid(wenxianxinxi, wenxianxinxi, int(id_))for i in data:votenum=i.get('votenum')if votenum!=None:params={"id":int(id_),"votenum":votenum+1}error=wenxianxinxi.updatebyparams(wenxianxinxi,wenxianxinxi,params)if error!=None:msg['code'] = crud_error_codemsg['msg'] = errorreturn jsonify(msg)# 分组统计接口
@main_bp.route("/pythonfa5876je/wenxianxinxi/group/<columnName>", methods=['GET'])
def pythonfa5876je_wenxianxinxi_group(columnName):'''分组统计接口'''if request.method == 'GET':msg = {"code": normal_code, "msg": "success", "data": {}}req_dict = session.get("req_dict")userinfo = session.get("params")msg['data'] = wenxianxinxi.groupbycolumnname(wenxianxinxi,wenxianxinxi,columnName,req_dict)msg['data'] = msg['data'][:10]json_filename='wenxianxinxi'+f'_group_{columnName}.json'where = ' where 1 = 1 'sql = "SELECT COUNT(*) AS total, " + columnName + " FROM wenxianxinxi " + where + " GROUP BY " + columnNamereturn jsonify(msg)# 按值统计接口
@main_bp.route("/pythonfa5876je/wenxianxinxi/value/<xColumnName>/<yColumnName>", methods=['GET'])
def pythonfa5876je_wenxianxinxi_value(xColumnName, yColumnName):'''按值统计接口,{"code": 0,"data": [{"total": 10.0,"shangpinleibie": "aa"},{"total": 20.0,"shangpinleibie": "bb"},{"total": 15.0,"shangpinleibie": "cc"}]}'''if request.method == 'GET':msg = {"code": normal_code, "msg": "success", "data": {}}req_dict = session.get("req_dict")userinfo = session.get("params")msg['data'] = wenxianxinxi.getvaluebyxycolumnname(wenxianxinxi,wenxianxinxi,xColumnName,yColumnName,req_dict)msg['data'] = msg['data'][:10]return jsonify(msg)# 按日期统计接口
@main_bp.route("/pythonfa5876je/wenxianxinxi/value/<xColumnName>/<yColumnName>/<timeStatType>", methods=['GET'])
def pythonfa5876je_wenxianxinxi_value_riqi(xColumnName, yColumnName, timeStatType):'''按日期统计接口'''if request.method == 'GET':msg = {"code": normal_code, "msg": "success", "data": {}}userinfo = session.get("params")where = ' where 1 = 1 'sql = ''if timeStatType == '日':sql = "SELECT DATE_FORMAT({0}, '%Y-%m-%d') {0}, sum({1}) total FROM wenxianxinxi {2} GROUP BY DATE_FORMAT({0}, '%Y-%m-%d')".format(xColumnName, yColumnName, where, '%Y-%m-%d')if timeStatType == '月':sql = "SELECT DATE_FORMAT({0}, '%Y-%m') {0}, sum({1}) total FROM wenxianxinxi {2} GROUP BY DATE_FORMAT({0}, '%Y-%m')".format(xColumnName, yColumnName, where, '%Y-%m')if timeStatType == '年':sql = "SELECT DATE_FORMAT({0}, '%Y') {0}, sum({1}) total FROM wenxianxinxi {2} GROUP BY DATE_FORMAT({0}, '%Y')".format(xColumnName, yColumnName, where, '%Y')data = db.session.execute(sql)data = data.fetchall()results = []for i in range(len(data)):result = {xColumnName: decimalEncoder(data[i][0]),'total': decimalEncoder(data[i][1])}results.append(result)msg['data'] = resultsjson_filename='wenxianxinxi'+f'_value_{xColumnName}_{yColumnName}.json'return jsonify(msg)# 按值统计(多)
@main_bp.route("/pythonfa5876je/wenxianxinxi/valueMul/<xColumnName>", methods=['GET'])
def pythonfa5876je_wenxianxinxi_valueMul(xColumnName):if request.method == 'GET':msg = {"code": normal_code, "msg": "success", "data": []}req_dict = session.get("req_dict")userinfo = session.get("params")where = ' where 1 = 1 'for item in req_dict['yColumnNameMul'].split(','):sql = "SELECT {0}, sum({1}) AS total FROM wenxianxinxi {2} GROUP BY {0} LIMIT 10".format(xColumnName, item, where)L = []data = db.session.execute(sql)data = data.fetchall() for i in range(len(data)):result = {xColumnName: decimalEncoder(data[i][0]),'total': decimalEncoder(data[i][1])}L.append(result)msg['data'].append(L)return jsonify(msg)# 按值统计(多)
@main_bp.route("/pythonfa5876je/wenxianxinxi/valueMul/<xColumnName>/<timeStatType>", methods=['GET'])
def pythonfa5876je_wenxianxinxi_valueMul_time(xColumnName):if request.method == 'GET':msg = {"code": normal_code, "msg": "success", "data": []}req_dict = session.get("req_dict")userinfo = session.get("params")timeStatType = req_dict['timeStatType']where = ' where 1 = 1 'for item in req_dict['yColumnNameMul'].split(','):sql = ''if timeStatType == '日':sql = "SELECT DATE_FORMAT({0}, '%Y-%m-%d') {0}, sum({1}) total FROM wenxianxinxi {2} GROUP BY DATE_FORMAT({0}, '%Y-%m-%d') LIMIT 10".format(xColumnName, item, where, '%Y-%m-%d')if timeStatType == '月':sql = "SELECT DATE_FORMAT({0}, '%Y-%m') {0}, sum({1}) total FROM wenxianxinxi {2} GROUP BY DATE_FORMAT({0}, '%Y-%m') LIMIT 10".format(xColumnName, item, where, '%Y-%m')if timeStatType == '年':sql = "SELECT DATE_FORMAT({0}, '%Y') {0}, sum({1}) total FROM wenxianxinxi {2} GROUP BY DATE_FORMAT({0}, '%Y') LIMIT 10".format(xColumnName, item, where, '%Y')L = []data = db.session.execute(sql)data = data.fetchall() for i in range(len(data)):result = {xColumnName: decimalEncoder(data[i][0]),'total': decimalEncoder(data[i][1])}L.append(result)msg['data'].append(L)return jsonify(msg)import math
def cosine_similarity(a, b):numerator = sum([a[key] * b[key] for key in a if key in b])denominator = math.sqrt(sum([a[key]**2 for key in a])) * math.sqrt(sum([b[key]**2 for key in b]))return numerator / denominator#收藏协同算法
@main_bp.route("/pythonfa5876je/wenxianxinxi/autoSort2", methods=['GET'])
def pythonfa5876je_wenxianxinxi_autoSort2():if request.method == 'GET':user_ratings = {}req_dict = session.get("req_dict")userinfo = session.get("params")sql = "select * from storeup where type = 1 and tablename = 'wenxianxinxi' order by addtime desc"data = db.session.execute(sql)data_dict = [dict(zip(result.keys(), result)) for result in data.fetchall()]for item in data_dict:if user_ratings.__contains__(item["userid"]):ratings_dict = user_ratings[item["userid"]]if ratings_dict.__contains__(item["refid"]):ratings_dict[str(item["refid"])]+=1else:ratings_dict[str(item["refid"])] =1else:user_ratings[item["userid"]] = {str(item["refid"]):1}sorted_recommended_goods=[]try:# 计算目标用户与其他用户的相似度similarities = {other_user: cosine_similarity(user_ratings[userinfo.get("id")], user_ratings[other_user])for other_user in user_ratings if other_user != userinfo.get("id")}# 找到与目标用户最相似的用户most_similar_user = sorted(similarities, key=similarities.get, reverse=True)[0]# 找到最相似但目标用户未购买过的商品recommended_goods = {goods: rating for goods, rating in user_ratings[most_similar_user].items() ifgoods not in user_ratings[userinfo.get("id")]}# 按评分降序排列推荐sorted_recommended_goods = sorted(recommended_goods, key=recommended_goods.get, reverse=True)except:passL = []where = " AND ".join([f"{key} = '{value}'" for key, value in req_dict.items() if key!="page" and key!="limit"])if where:sql = f'''SELECT * FROM (SELECT * FROM wenxianxinxi WHERE {where}) AS table1 WHERE id IN ('{"','".join(sorted_recommended_goods)}') union all SELECT * FROM (SELECT * FROM wenxianxinxi WHERE {where}) AS table1 WHERE id NOT IN ('{"','".join(sorted_recommended_goods)}')'''else:sql ="select * from wenxianxinxi where id in ('%s"%("','").join(sorted_recommended_goods)+"') union all select * from wenxianxinxi where id not in('%s"%("','").join(sorted_recommended_goods)+"')"data = db.session.execute(sql)data_dict = [dict(zip(result.keys(), result)) for result in data.fetchall()]for online_dict in data_dict:for key in online_dict:if 'datetime.datetime' in str(type(online_dict[key])):online_dict[key] = online_dict[key].strftime("%Y-%m-%d %H:%M:%S")elif 'datetime' in str(type(online_dict[key])):online_dict[key] = online_dict[key].strftime("%Y-%m-%d %H:%M:%S")else:passL.append(online_dict)return jsonify({"code": 0, "msg": '',  "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":5,"list": L[0:int(req_dict['limit'])]}})# 总数量
@main_bp.route("/pythonfa5876je/wenxianxinxi/count", methods=['GET'])
def pythonfa5876je_wenxianxinxi_count():''''''if request.method == 'GET':msg = {"code": normal_code, "msg": "success",  "data": 0}req_dict = session.get("req_dict")userinfo = session.get("params")msg['data']  = wenxianxinxi.count(wenxianxinxi, wenxianxinxi, req_dict)return jsonify(msg)# 导入
@main_bp.route("/pythonfa5876je/wenxianxinxi/importExcel", methods=['GET','POST'])
def pythonfa5876je_wenxianxinxi_importExcel():''''''request.operation = "导入{comments}"if request.method == 'GET' or request.method == 'POST':msg = {"code": normal_code, "msg": "success", "data": {}}excel_file = request.files.get("file")filename=excel_file.filenamefilesuffix=filename.split(".")[-1]if filesuffix in ['xlsx', 'xls']:data = xlrd.open_workbook(filename=None, file_contents=excel_file.read())table = data.sheets()[0]rows = table.nrowstry:for row in range(1, rows):row_values = table.row_values(row)req_dict = {}if '.0' in str(row_values[0]):req_dict['wenxianbiaoti'] = str(row_values[0]).split('.')[0]elif str(row_values[0]) != '':req_dict['wenxianbiaoti'] = row_values[0]else:req_dict['wenxianbiaoti'] = Noneif '.0' in str(row_values[1]):req_dict['wenxianleixing'] = str(row_values[1]).split('.')[0]elif str(row_values[1]) != '':req_dict['wenxianleixing'] = row_values[1]else:req_dict['wenxianleixing'] = Noneif '.0' in str(row_values[2]):req_dict['wenxianzhaiyao'] = str(row_values[2]).split('.')[0]elif str(row_values[2]) != '':req_dict['wenxianzhaiyao'] = row_values[2]else:req_dict['wenxianzhaiyao'] = Noneif '.0' in str(row_values[3]):req_dict['zuozhe'] = str(row_values[3]).split('.')[0]elif str(row_values[3]) != '':req_dict['zuozhe'] = row_values[3]else:req_dict['zuozhe'] = Noneif '.0' in str(row_values[4]):req_dict['wenxianneirong'] = str(row_values[4]).split('.')[0]elif str(row_values[4]) != '':req_dict['wenxianneirong'] = row_values[4]else:req_dict['wenxianneirong'] = Noneif str(row_values[5]) != '':date_tuple = xlrd.xldate_as_tuple(row_values[5], 0)date_str = '-'.join([str(i) for i in date_tuple[:-3]])req_dict['shangchuanriqi'] = datetime.strptime(date_str, '%Y-%m-%d').strftime('%Y-%m-%d')wenxianxinxi.createbyreq(wenxianxinxi, wenxianxinxi, req_dict)except:passelse:msg.code = 500msg.msg = "文件类型错误"return jsonify(msg)# 统计接口
@main_bp.route("/pythonfa5876je/wenxianxinxi/remind/<columnName>/<type>", methods=['GET'])  #
def pythonfa5876je_wenxianxinxi_remind(columnName,type):''''''if request.method == 'GET':msg = {"code": normal_code, 'count': 0}# 组合查询参数params = session.get("req_dict")remindstart = 0remindend =9999990if int(type)==1:#数字if params.get('remindstart') == None and params.get('remindend') != None:remindstart = 0remindend = int(params['remindend'])elif params.get('remindstart') != None and params.get('remindend') == None:remindstart = int(params['remindstart'])remindend = 999999elif params.get('remindstart') == None and params.get('remindend') == None:remindstart = 0remindend = 999999else:remindstart = params.get('remindstart')remindend =  params.get('remindend')elif int(type)==2:#日期current_time=int(time.time())if params.get('remindstart') == None and params.get('remindend') != None:starttime=current_time-60*60*24*365*2params['remindstart'] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(starttime))endtime=current_time+60*60*24*params.get('remindend')params['remindend'] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(endtime))elif params.get('remindstart') != None and params.get('remindend') == None:starttime= current_time - 60 * 60 * 24 * params.get('remindstart')params['remindstart']=time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(starttime))endtime=current_time+60*60*24*365*2params['remindend'] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(endtime))elif params.get('remindstart') == None and params.get('remindend') == None:starttime = current_time - 60 * 60 * 24 * 365 * 2params['remindstart'] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(starttime))endtime = current_time + 60 * 60 * 24 * 365 * 2params['remindend'] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(endtime))data = wenxianxinxi.getbetweenparams(wenxianxinxi,wenxianxinxi,columnName,{"remindStart": remindstart,"remindEnd": remindend})msg['count'] = len(data)return jsonify(msg)#分类列表
@main_bp.route("/pythonfa5876je/wenxianxinxi/lists", methods=['GET'])
def pythonfa5876je_wenxianxinxi_lists():if request.method == 'GET':msg = {"code": normal_code, "msg": "success", "data": []}list,_,_,_,_ = wenxianxinxi.page(wenxianxinxi,wenxianxinxi,{})msg['data'] = listreturn jsonify(msg)

💕💕作者:计算机源码社
💕💕个人简介:本人 八年开发经验,擅长Java、Python、PHP、.NET、Node.js、Android、微信小程序、爬虫、大数据、机器学习等,大家有这一块的问题可以一起交流!
💕💕学习资料、程序开发、技术解答、文档报告
💕💕如需要源码,可以扫取文章下方二维码联系咨询

这篇关于分享一个基于Python的文献检索与查询系统flask毕设文献分享交流系统(源码、调试、LW、开题、PPT)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1109678

相关文章

Ilya-AI分享的他在OpenAI学习到的15个提示工程技巧

Ilya(不是本人,claude AI)在社交媒体上分享了他在OpenAI学习到的15个Prompt撰写技巧。 以下是详细的内容: 提示精确化:在编写提示时,力求表达清晰准确。清楚地阐述任务需求和概念定义至关重要。例:不用"分析文本",而用"判断这段话的情感倾向:积极、消极还是中性"。 快速迭代:善于快速连续调整提示。熟练的提示工程师能够灵活地进行多轮优化。例:从"总结文章"到"用

不懂推荐算法也能设计推荐系统

本文以商业化应用推荐为例,告诉我们不懂推荐算法的产品,也能从产品侧出发, 设计出一款不错的推荐系统。 相信很多新手产品,看到算法二字,多是懵圈的。 什么排序算法、最短路径等都是相对传统的算法(注:传统是指科班出身的产品都会接触过)。但对于推荐算法,多数产品对着网上搜到的资源,都会无从下手。特别当某些推荐算法 和 “AI”扯上关系后,更是加大了理解的难度。 但,不了解推荐算法,就无法做推荐系

基于人工智能的图像分类系统

目录 引言项目背景环境准备 硬件要求软件安装与配置系统设计 系统架构关键技术代码示例 数据预处理模型训练模型预测应用场景结论 1. 引言 图像分类是计算机视觉中的一个重要任务,目标是自动识别图像中的对象类别。通过卷积神经网络(CNN)等深度学习技术,我们可以构建高效的图像分类系统,广泛应用于自动驾驶、医疗影像诊断、监控分析等领域。本文将介绍如何构建一个基于人工智能的图像分类系统,包括环境

水位雨量在线监测系统概述及应用介绍

在当今社会,随着科技的飞速发展,各种智能监测系统已成为保障公共安全、促进资源管理和环境保护的重要工具。其中,水位雨量在线监测系统作为自然灾害预警、水资源管理及水利工程运行的关键技术,其重要性不言而喻。 一、水位雨量在线监测系统的基本原理 水位雨量在线监测系统主要由数据采集单元、数据传输网络、数据处理中心及用户终端四大部分构成,形成了一个完整的闭环系统。 数据采集单元:这是系统的“眼睛”,

python: 多模块(.py)中全局变量的导入

文章目录 global关键字可变类型和不可变类型数据的内存地址单模块(单个py文件)的全局变量示例总结 多模块(多个py文件)的全局变量from x import x导入全局变量示例 import x导入全局变量示例 总结 global关键字 global 的作用范围是模块(.py)级别: 当你在一个模块(文件)中使用 global 声明变量时,这个变量只在该模块的全局命名空

AI一键生成 PPT

AI一键生成 PPT 操作步骤 作为一名打工人,是不是经常需要制作各种PPT来分享我的生活和想法。但是,你们知道,有时候灵感来了,时间却不够用了!😩直到我发现了Kimi AI——一个能够自动生成PPT的神奇助手!🌟 什么是Kimi? 一款月之暗面科技有限公司开发的AI办公工具,帮助用户快速生成高质量的演示文稿。 无论你是职场人士、学生还是教师,Kimi都能够为你的办公文

嵌入式QT开发:构建高效智能的嵌入式系统

摘要: 本文深入探讨了嵌入式 QT 相关的各个方面。从 QT 框架的基础架构和核心概念出发,详细阐述了其在嵌入式环境中的优势与特点。文中分析了嵌入式 QT 的开发环境搭建过程,包括交叉编译工具链的配置等关键步骤。进一步探讨了嵌入式 QT 的界面设计与开发,涵盖了从基本控件的使用到复杂界面布局的构建。同时也深入研究了信号与槽机制在嵌入式系统中的应用,以及嵌入式 QT 与硬件设备的交互,包括输入输出设

JAVA智听未来一站式有声阅读平台听书系统小程序源码

智听未来,一站式有声阅读平台听书系统 🌟&nbsp;开篇:遇见未来,从“智听”开始 在这个快节奏的时代,你是否渴望在忙碌的间隙,找到一片属于自己的宁静角落?是否梦想着能随时随地,沉浸在知识的海洋,或是故事的奇幻世界里?今天,就让我带你一起探索“智听未来”——这一站式有声阅读平台听书系统,它正悄悄改变着我们的阅读方式,让未来触手可及! 📚&nbsp;第一站:海量资源,应有尽有 走进“智听

【专题】2024飞行汽车技术全景报告合集PDF分享(附原数据表)

原文链接: https://tecdat.cn/?p=37628 6月16日,小鹏汇天旅航者X2在北京大兴国际机场临空经济区完成首飞,这也是小鹏汇天的产品在京津冀地区进行的首次飞行。小鹏汇天方面还表示,公司准备量产,并计划今年四季度开启预售小鹏汇天分体式飞行汽车,探索分体式飞行汽车城际通勤。阅读原文,获取专题报告合集全文,解锁文末271份飞行汽车相关行业研究报告。 据悉,业内人士对飞行汽车行业