浏览代码

分词词性校对

natasha 1 年之前
父节点
当前提交
1d038ab1c7
共有 1 个文件被更改,包括 14 次插入4 次删除
  1. 14 4
      src/views/Textanalysis/CheckWord.vue

+ 14 - 4
src/views/Textanalysis/CheckWord.vue

@@ -12,12 +12,12 @@
             <p class="tips">分词:在需要分开的内容中间插入两个空格;分句:将句子另起一行;分段:两段中间加入空行。</p>
         </div>
         <div class="btn-box">
-            <el-switch
+            <!-- <el-switch
                 class="show-pos"
                 v-model="showPos"
                 active-text="显示词性"
                 inactive-text="">
-            </el-switch>
+            </el-switch> -->
             <el-button type="info" @click="$router.go(-1)">取消</el-button>
             <el-button type="primary" @click="saveWord(id)">保存</el-button>
         </div>
@@ -45,9 +45,10 @@ export default {
       loading: false,
       id: '',
       ArticelData: null,
-      showPos: false,
+      showPos: true,
       noPosContent: '',
-      hasPosContent: ''
+      hasPosContent: '',
+      posList: ['NR','NN','JJ','AD','PU','VV','CC','SP','FW','DEC','ETC','AS']
     };
   },
   // 生命周期 - 创建完成(可以访问当前this实例)
@@ -107,6 +108,7 @@ export default {
       let arr = this.showPos?this.hasPosContent.split('\n'):this.noPosContent.split('\n')
       let indexP = 0 // 段落索引
       let indexS = 0 // 句子索引
+      let flag = true
       arr.forEach(item=>{
         if(item===''){
             saveArr.push([])
@@ -120,6 +122,10 @@ export default {
             let arrs = item.trim().split('  ')
             let saveItem = []
             arrs.forEach((items,indexs)=>{
+                if(items.lastIndexOf('_')===-1||this.posList.indexOf(items.substring(items.lastIndexOf('_')+1).trim())==-1){
+                    flag = false
+                    return
+                }
                 let obj = {
                     word: items.lastIndexOf('_')>-1?items.substring(0,items.lastIndexOf('_')).trim():items,
                     pos: this.showPos?items.lastIndexOf('_')>-1?items.substring(items.lastIndexOf('_')+1).trim():'':this.ArticelData[indexP]&&this.ArticelData[indexP][indexS]&&this.ArticelData[indexP][indexS][indexs]&&this.ArticelData[indexP][indexS][indexs].pos?this.ArticelData[indexP][indexS][indexs].pos:''
@@ -130,6 +136,10 @@ export default {
             indexS++
         }
       })
+      if(!flag){
+        this.$message.warning('词性有错误请检查')
+        return
+      }
       this.loading = true;
       publicMethods('/TeachingServer/TextAnalyser/SetFCProofreadForAnalyseRecord',{
             analyse_record_id: this.id,