Browse Source

停用词

lrf 6 tháng trước cách đây
mục cha
commit
c272cc9930
2 tập tin đã thay đổi với 24 bổ sung0 xóa
  1. 23 0
      src/controller/dict.controller.ts
  2. 1 0
      stop_dict.txt

+ 23 - 0
src/controller/dict.controller.ts

@@ -4,6 +4,7 @@ import * as path from 'path';
 @Controller('/dict')
 export class DictController {
   fileName = 'dict.txt';
+  stopFileName = 'stop_dict.txt'
   @Get('/')
   async getDict() {
     const filePath = path.resolve(process.cwd(), this.fileName);
@@ -25,4 +26,26 @@ export class DictController {
     const fileData = fs.readFileSync(filePath, 'utf-8');
     return fileData;
   }
+
+  @Get('/stop')
+  async getStopDict() {
+    const filePath = path.resolve(process.cwd(), this.stopFileName);
+    const fileData = fs.readFileSync(filePath, 'utf-8');
+    const list = fileData.split('\n');
+    return list;
+  }
+
+  @Post('/stop')
+  async updateStopDict(@Body('data') data: Array<string>) {
+    const filePath = path.resolve(process.cwd(), this.stopFileName);
+    const fileData = data.join('\n');
+    fs.writeFileSync(filePath, fileData, 'utf-8');
+  }
+
+  @Get('/stop/remote')
+  async remoteStopDict() {
+    const filePath = path.resolve(process.cwd(), this.stopFileName);
+    const fileData = fs.readFileSync(filePath, 'utf-8');
+    return fileData;
+  }
 }

+ 1 - 0
stop_dict.txt

@@ -0,0 +1 @@
+分析