修复好了查重前端逻辑。
This commit is contained in:
parent
4522512654
commit
3794933261
|
|
@ -137,11 +137,13 @@ const checkPlagiarism = async () => {
|
||||||
const submitReport = {//只需要附件信息
|
const submitReport = {//只需要附件信息
|
||||||
attachment
|
attachment
|
||||||
};
|
};
|
||||||
// 调用查重接口
|
console.log(submitReport);
|
||||||
const response = await api.runPlagiarism(submitReport);
|
|
||||||
const result = response.data;
|
// 调用查重接口
|
||||||
console.log('查重结果:', result);
|
const res = await api.runPlagiarism(submitReport);
|
||||||
// 处理查重结果,例如显示最高相似度的文章名和相似度
|
console.log('查重结果:', res);
|
||||||
|
ElMessage.success('查重成功!');
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
ElMessage.error('查重过程中发生错误!');
|
ElMessage.error('查重过程中发生错误!');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,20 +44,24 @@ public class PlagiarismController {
|
||||||
private PlagiarismServiceI plagiarismServiceI;
|
private PlagiarismServiceI plagiarismServiceI;
|
||||||
|
|
||||||
@PostMapping("/runPlagiarism")
|
@PostMapping("/runPlagiarism")
|
||||||
public ResponseEntity runPlagiarism(@RequestBody SubmitReport submitReport) {
|
public RespBean runPlagiarism(@RequestBody SubmitReport submitReport) {
|
||||||
// 构建文件路径
|
// 构建文件路径
|
||||||
String uploadDirectory = System.getProperty("user.dir") + File.separator + "upload";
|
String uploadDirectory = System.getProperty("user.dir") + File.separator + "upload";
|
||||||
Path filePath = Paths.get(uploadDirectory,submitReport.getAttachment());
|
Path filePath = Paths.get(uploadDirectory,submitReport.getAttachment());
|
||||||
|
|
||||||
// 检查文件是否存在
|
// 检查文件是否存在
|
||||||
if (!Files.exists(filePath)) {
|
if (!Files.exists(filePath)) {
|
||||||
return ResponseEntity.badRequest().body("文件不存在");
|
return RespBean.error("文件不存在");
|
||||||
}
|
}
|
||||||
// 调用Service层进行查重
|
// 调用Service层进行查重
|
||||||
PlagiarismResult result = plagiarismServiceI.checkPlagiarism(filePath.toString(), uploadDirectory);
|
PlagiarismResult result = plagiarismServiceI.checkPlagiarism(filePath.toString(), uploadDirectory);
|
||||||
|
|
||||||
// 返回查重结果
|
// 返回查重结果
|
||||||
return ResponseEntity.ok(result);
|
if (result != null) {
|
||||||
|
return RespBean.ok("查重成功",result);
|
||||||
|
} else {
|
||||||
|
return RespBean.error("查重失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,6 @@ public class PlagiarismServiceImpl implements PlagiarismServiceI {
|
||||||
@Override
|
@Override
|
||||||
public PlagiarismResult checkPlagiarism(String fileName, String uploadDirectory) {
|
public PlagiarismResult checkPlagiarism(String fileName, String uploadDirectory) {
|
||||||
|
|
||||||
// 清理文件名
|
|
||||||
String cleanedFileName = cleanFileName(fileName);
|
|
||||||
|
|
||||||
// 构建文件路径
|
// 构建文件路径
|
||||||
Path filePath = Paths.get(fileName);
|
Path filePath = Paths.get(fileName);
|
||||||
|
|
||||||
|
|
@ -116,7 +113,7 @@ public class PlagiarismServiceImpl implements PlagiarismServiceI {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new PlagiarismResult(similarFileName,highestSimilarity );
|
return new PlagiarismResult(similarFileName,highestSimilarity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************///读取文件部分
|
/**********************************///读取文件部分
|
||||||
|
|
@ -207,10 +204,6 @@ public class PlagiarismServiceImpl implements PlagiarismServiceI {
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
//文件格式清理
|
|
||||||
public static String cleanFileName(String fileName) {
|
|
||||||
return fileName.replaceAll("[<>:\"/\\\\|?*]", "_");
|
|
||||||
}
|
|
||||||
/**********************************///数据清洗部分
|
/**********************************///数据清洗部分
|
||||||
|
|
||||||
// 添加一个静态的停用词集合
|
// 添加一个静态的停用词集合
|
||||||
|
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
智能手机在当代社会的作用不可小觑,它不仅使得人们的通讯变得极为便捷,还提供了多样化的娱乐和工作功能。在我国,智能手机的普及率不断上升,几乎成了每个人生活中的必需品。它的多功能性和便携性,使其成为了现代科技的一个标志性产物。无论是通讯、娱乐还是学习,都离不开这款电子设备。
|
|
||||||
在城市边缘的那所著名大学的操场上,一场几千人参加的批斗会已经进行了近两个小时。
|
|
||||||
“爱因斯坦是反动的学术权威,他有奶便是娘,跑去为美帝国主义造原子弹!要建立起革命的科学,就要打倒以相对论为代表的资产阶级理论黑旗!”
|
|
||||||
然后在法文词下列出同义的上海方言词语,再尽可能详尽地列出近义的上海方言词语、短语或句子。这种编写方式,对中法两国学习者或词典使用者尽可能多地掌握法汉词汇,显然是很有意义的。
|
|
||||||
Loading…
Reference in New Issue