把停用词集合存放在了根目录下,修改了算法获取停用词集合的寻址方法

This commit is contained in:
musteven 2025-04-28 12:40:14 +08:00
parent 10d180e7f2
commit 14658c8b39
1 changed files with 4 additions and 1 deletions

View File

@ -210,7 +210,10 @@ public class PlagiarismServiceImpl implements PlagiarismServiceI {
private static final Set<String> STOP_WORDS = new HashSet<>();//过滤停用词
static {
try {
String stopwordsFilePath = "C:/Users/86186/Desktop/停用词.txt";
// 获取项目根目录路径
String projectRootDirectory = System.getProperty("user.dir");
// 构建停用词文件的路径
String stopwordsFilePath = projectRootDirectory + File.separator + "停用词.txt";
// 读取文件中的每一行
Files.readAllLines(Paths.get(stopwordsFilePath), StandardCharsets.UTF_8)
.forEach(STOP_WORDS::add);