当前位置: 首页 > news >正文

山东大学项目实训-创新实训-法律文书专家系统-项目报告(三)

项目简介

法律文书专家系统是一个 Web 应用,提供法律文书摘要提取、法律预测报告生成和法律考试问题答疑三大核心功能。用户需要登录或注册后,进入主页面选择所需功能,进行相应的操作

用户群体

律师:需要快速提取法律文书摘要,提高办案效率。

法务人员:需要根据案件输入生成法律预测报告,辅助决策。

法学生:需要练习法律考试题,获取答案与解析。

进度说明:

法律文书摘要功能,法律文书预测报告的大致功能基本完成.

完成效果:

界面效果:

开发技术:

前端使用了vue+JavaScript的技术,同时还使用了element组件库。后端使用了Java+SpringBoot。前后端交互使用了axios技术。

前后端的交互:

axios:Axios 是一个基于 promise 网络请求库,作用于node.js 和浏览器中。 它是 isomorphic 的(即同一套代码可以运行在浏览器和node.js中)。

我在前端使用axios技术封装了一个request拦截器,可以自发请求发送前对请求做一些处理.

import axios from 'axios'const request = axios.create({baseURL: 'http://localhost:9090',  // 这里是全局统一加上了 '/api' 前缀,也就是说所有接口都会加上'/api'前缀在,页面里面写接口的时候就不要加 '/api'了,否则会出现2个'/api',类似 '/api/api/user'这样的报错,切记!!!timeout: 60000
})// request 拦截器
// 可以自请求发送前对请求做一些处理
// 比如统一加token,对请求参数统一加密
request.interceptors.request.use(config => {//config.headers['Content-Type'] = 'application/json;charset=utf-8';if (!(config.data instanceof FormData)) {config.headers['Content-Type'] = 'application/json;charset=utf-8';}// 设置请求头let jwtToken = localStorage.getItem('jwtToken');if (jwtToken) {config.headers['jwtToken'] = jwtToken;}return config
}, error => {return Promise.reject(error)
});// response 拦截器
// 可以在接口响应后统一处理结果
request.interceptors.response.use(response => {let res = response.data;// 如果是返回的文件if (response.config.responseType === 'blob') {return res}// 兼容服务端返回的字符串数据if (typeof res === 'string') {res = res ? JSON.parse(res) : res}return res;},error => {console.log('err' + error) // for debugreturn Promise.reject(error)}
)export default request

使用时可以直接这么使用:

(文书摘要功能中上传文件的代码)

import request from "@/axios/request";const response = await request.post("/wenshu/upload", formData, {headers: {"Content-Type": "multipart/form-data",},

(法律预测功能中上传的代码) 

import request from "@/axios/request";
const response = await request.post('/yuce/send', this.inputQuestion);
    // 处理文件上传成功的事件handleUploadSuccess(response, files, fileList) {console.log("文件上传成功,后端响应:", response);if (response.code == 200) {this.inputQuestion = response.msg} else {this.$message({type: 'error', message: response.msg})}}

 后端文书摘要功能对应的接收方法:它接收一个文件(txt,pdf,docx)并将其中的文字信息提取,然后与训练好的模型进行交互.

@PostMapping("/upload")public Result handleFileUpload(@RequestParam("file") MultipartFile file) {String filename = file.getOriginalFilename();if (filename == null) {return Result.error("空文件");}try {String textContent = extractTextFromFile(file);// 构建请求ObjectMapper mapper = new ObjectMapper();Map<String, Object> data = new HashMap<>();data.put("document", textContent);String jsonBody = mapper.writeValueAsString(data);HttpRequest request = HttpRequest.newBuilder().uri(URI.create("http://localhost:7860/summarize")).header("Content-Type", "application/json").POST(HttpRequest.BodyPublishers.ofString(jsonBody)).build();// 发送请求并处理响应HttpClient client = HttpClient.newHttpClient();HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());System.out.println("Status code: " + response.statusCode());System.out.println("Response body: " + response.body());//返回结果return Result.success(response.body());} catch (UnsupportedOperationException e) {return Result.error("不支持的文件类型");} catch (Exception e) {e.printStackTrace();return Result.error("文件解析失败");}}

 后端文书摘要功能对应的接收方法:

public class YuceController {@PostMapping("/upload")public Result handleFileUpload(@RequestParam("file") MultipartFile file) {String filename = file.getOriginalFilename();if (filename == null) {return Result.error("空文件");}try {String textContent = extractTextFromFile(file);System.out.println(textContent);return Result.success(textContent);} catch (UnsupportedOperationException e) {return Result.error("不支持的文件类型");} catch (Exception e) {e.printStackTrace();return Result.error("文件解析失败");}}@PostMapping("/send")public Result handleRequest(@RequestBody String requestData) {System.out.println("接收到的字符串: " + requestData);// 构建请求try {ObjectMapper mapper = new ObjectMapper();Map<String, Object> data = new HashMap<>();data.put("fact", requestData);String jsonBody = mapper.writeValueAsString(data);HttpRequest request = HttpRequest.newBuilder().uri(URI.create("http://localhost:7860/prediction")).header("Content-Type", "application/json").POST(HttpRequest.BodyPublishers.ofString(jsonBody)).build();// 发送请求并处理响应HttpClient client = HttpClient.newHttpClient();HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());System.out.println("Status code: " + response.statusCode());System.out.println("Response body: " + response.body());//返回结果return Result.success(response.body());} catch (Exception e) {e.printStackTrace();return Result.error("错误");}}

 其中,第一个方法是接受前端上传的文件,然后将其文字信息提取出来,返回给前端,第二个则是接受前端发送来的信息,与模型交互后返回前端.

相关文章:

  • Linux常用命令31——groupmod更改群组属性
  • 分析 Docker 磁盘占用
  • 浙大:基于内在偏好的LLM个性化对齐
  • 基于EFISH-SCB-RK3576/SAIL-RK3576的自助服务终端技术方案‌(国产化替代J1900的全场景技术解析)
  • 神经网络在专家系统中的应用:从符号逻辑到连接主义的融合创新
  • Git 第一讲---基础篇 git基础概念与操作
  • Kdump 收集器及使用方式
  • 对ubuntu的简单介绍
  • WebRTC 服务器之SRS服务器概述和环境搭建
  • Qwen2_5-Omni-3B:支持视频、音频、图像和文本的全能AI,可在本地运行
  • Linux的时间同步服务器(附加详细实验案例)
  • OpenCV进阶操作:图像直方图、直方图均衡化
  • 【最新Python包管理工具UV的介绍和安装】
  • yolov11 epoch100轮 训练笔记5 kaggle comet
  • HarmonyOS Device Connector(hdc)
  • 基于 HTML 和 CSS 实现的 3D 翻转卡片效果
  • 数据存储——高级存储之PV和PVC
  • 力扣面试150题-- 翻转二叉树
  • ThreadLocal源码深度剖析:内存管理与哈希机制
  • GisWeb实战笔记(1)基于 Vue 3 + Vite + CesiumJS搭建gis开发环境
  • 黄道炫:南京102天——黄镇球的防空日记
  • “五一”假期国内出游3.14亿人次,同比增长6.4%
  • 解放军仪仗司礼大队仪仗分队参加纪念苏联伟大卫国战争胜利80周年阅兵活动
  • 长线游、县域游、主题游等持续升温,假期文旅市场供需两旺
  • 5月1日,全社会跨区域人员流动量完成33271.4万人次
  • “网约摩托”在部分县城上线:起步价五六元,专家建议纳入监管