Parcourir la source

文本分析添加名称

natasha il y a 1 an
Parent
commit
2dd70a5b67

+ 10 - 8
src/views/Textanalysis/WordTable.vue

@@ -69,7 +69,7 @@
                 v-if="(item.name === '拼音' && typeIndex !== 0) || item.name !== '拼音'"
                 :key="i"
                 :style="{ width: item.width }"
-                :class="[i === tableHeader.length - 1 ? 'bz' : '', item.name === '级别' ? 'jb' : '']"
+                :class="[i === tableHeader.length - 1 ? 'bz' : '']"
               >
                 <div>
                   <span>
@@ -106,7 +106,7 @@
             </template>
           </tr>
           <tr v-for="(item, index) in dataList.word_list" :key="index + 'td'">
-            <td class="sort-td">{{ item.number }}</td>
+            <td class="sort-td" style="text-align: center">{{ item.number }}</td>
             <td :class="['sort-td', typeIndex === 0 ? 'pinyin' : 'hanzi']">
               <span
                 :style="{
@@ -120,7 +120,7 @@
                 >{{ item.word }}</span
               >
             </td>
-            <td v-if="typeIndex !== 0" class="sort-td" style="font-family: 'League'; text-align: left">
+            <td v-if="typeIndex !== 0" class="sort-td" style="font-family: 'League'">
               {{ item.pinyin }}
             </td>
             <td class="sort-td">
@@ -133,7 +133,7 @@
                 >{{ item.grade_name }}</span
               >
             </td>
-            <td class="sort-td jb" style="text-align: right">
+            <td class="sort-td">
               <span
                 :style="{
                   fontFamily: '楷体',
@@ -857,14 +857,17 @@ export default {
           > div {
             display: flex;
             align-items: center;
-            justify-content: space-between;
+            // justify-content: space-between;
             height: 48px;
             padding: 0 8px;
 
             .sort {
               cursor: pointer;
+              margin-left: 4px;
 
               > div {
+                // height: 11px;
+                font-size: 0;
                 img {
                   width: 11px;
                   height: 11px;
@@ -874,14 +877,14 @@ export default {
               > :nth-child(1) {
                 > img {
                   position: relative;
-                  top: 3px;
+                  top: 0px;
                 }
               }
 
               > :nth-child(2) {
                 > img {
                   position: relative;
-                  bottom: 7px;
+                  bottom: 0px;
                 }
               }
             }
@@ -899,7 +902,6 @@ export default {
 
         .sort-td {
           padding: 0 9px;
-          text-align: center;
         }
       }
     }

+ 220 - 56
src/views/Textanalysis/index.vue

@@ -153,19 +153,19 @@
           </div>
           <div class="btn_set">
             <div class="btn">
-              <div class="btn_dv" style="margin-right: 16px" @click="ciyunEvent">
+              <div class="btn_dv" style="margin-right: 12px" @click="ciyunEvent">
                 <img src="../../assets/teacherdev/icon-ciyun.png" alt="" />
                 词云
               </div>
-              <div class="btn_dv" style="margin-right: 16px" @click="gowordTable">
+              <div class="btn_dv" style="margin-right: 12px" @click="gowordTable">
                 <img src="../../assets/teacherdev/icon-cibiao.png" alt="" />
                 词表
               </div>
-              <div class="btn_dv" style="margin-right: 24px" @click="downArticle">
+              <div class="btn_dv" style="margin-right: 12px" @click="downArticle">
                 <img src="../../assets/teacherdev/icon-down.png" alt="" />
                 下载
               </div>
-              <div class="btn_dv" style="margin-right: 24px" @click="checkArticle">
+              <div class="btn_dv" style="margin-right: 12px" @click="checkArticle">
                 <img src="../../assets/teacherdev/pencil-ruler-line.png" alt="" />
                 校对
               </div>
@@ -191,64 +191,81 @@
             </div>
             <div class="set">
               <el-switch
-                v-model="fenci"
+                v-model="pinyinShow"
                 active-color="#735CFF"
+                style="margin-right: 12px"
                 :width="26"
-                style="margin-right: 24px"
-                inactive-text="分词"
+                inactive-text="拼音"
               />
-              <el-switch v-model="pinyinShow" active-color="#735CFF" :width="26" inactive-text="显示拼音" />
               <el-switch
                 v-if="pinyinShow"
                 v-model="pinyinBottom"
                 active-color="#735CFF"
                 :width="26"
                 inactive-text="拼音在下"
-                style="margin-left: 24px"
+                style="margin-right: 12px"
                 @change="changePinyinPosition"
               />
+              <el-switch
+                v-model="fenci"
+                active-color="#735CFF"
+                :width="26"
+                style="margin-right: 12px"
+                inactive-text="分词"
+              />
+              <el-switch
+                v-if="fenci"
+                v-model="cixing"
+                active-color="#735CFF"
+                :width="26"
+                style="margin-right: 12px"
+                inactive-text="词性"
+              />
             </div>
           </div>
           <div class="right_main">
-            <div class="right_main_top">
-              <div title="采用TTR公式衡量文本丰富度,TTR指不同音节数量与总数量的比值。">
-                <span
-                  >音节丰富度
-                  <span style="margin-left: 5px">
-                    {{ (difficulty.pinyinDifficulty * 1).toFixed(2) }}
+            <div style="display: flex">
+              <div class="right_main_top">
+                <div title="采用TTR公式衡量文本丰富度,音节丰富度指不同音节数量与总数量的比值。">
+                  <span
+                    >音节丰富度
+                    <span style="margin-left: 5px">
+                      {{ (difficulty.pinyinDifficulty * 1).toFixed(2) }}
+                    </span>
                   </span>
-                </span>
-                <span class="line"></span>
-                <span>{{ base.pinyinCount }} / {{ base.pinyinTextCount }}</span>
-              </div>
-              <div class="twoline">
-                <span class="line"></span>
-                <span class="line"></span>
-              </div>
-              <div title="采用TTR公式衡量文本丰富度,TTR指不同汉字数量与总数量的比值。">
-                <span
-                  >汉字丰富度
-                  <span style="margin-left: 5px">
-                    {{ (difficulty.wordDifficulty * 1).toFixed(2) }}
+                  <span class="line"></span>
+                  <span>{{ base.pinyinCount }} / {{ base.pinyinTextCount }}</span>
+                </div>
+                <div class="twoline">
+                  <span class="line"></span>
+                  <span class="line"></span>
+                </div>
+                <div title="采用TTR公式衡量文本丰富度,汉字丰富度指不同汉字数量与总数量的比值。">
+                  <span
+                    >汉字丰富度
+                    <span style="margin-left: 5px">
+                      {{ (difficulty.wordDifficulty * 1).toFixed(2) }}
+                    </span>
                   </span>
-                </span>
-                <span class="line"></span>
-                <span>{{ base.wordCount }} / {{ base.wordTextCount }}</span>
-              </div>
-              <div class="twoline">
-                <span class="line"></span>
-                <span class="line"></span>
-              </div>
-              <div title="采用TTR公式衡量文本丰富度,TTR指不同词汇数量与总数量的比值。">
-                <span
-                  >词汇丰富度
-                  <span style="margin-left: 5px">
-                    {{ (difficulty.vocabularyDifficulty * 1).toFixed(2) }}
+                  <span class="line"></span>
+                  <span>{{ base.wordCount }} / {{ base.wordTextCount }}</span>
+                </div>
+                <div class="twoline">
+                  <span class="line"></span>
+                  <span class="line"></span>
+                </div>
+                <div title="采用TTR公式衡量文本丰富度,词汇丰富度指不同词汇数量与总数量的比值。">
+                  <span
+                    >词汇丰富度
+                    <span style="margin-left: 5px">
+                      {{ (difficulty.vocabularyDifficulty * 1).toFixed(2) }}
+                    </span>
                   </span>
-                </span>
-                <span class="line"></span>
-                <span>{{ base.vocabularyCount }} / {{ base.vocabularyTextCount }}</span>
+                  <span class="line"></span>
+                  <span>{{ base.vocabularyCount }} / {{ base.vocabularyTextCount }}</span>
+                </div>
               </div>
+              <span class="edit-btn" @click="editArticle()"><i class="el-icon-edit"></i>修改文本</span>
             </div>
             <div class="articel">
               <div v-for="(items, index) in ArticelData" :key="index + 'paragraph'" class="paragraph">
@@ -472,6 +489,15 @@
                                 >{{ word.word }}</span
                               >
                             </template>
+                            <span
+                              v-if="cixing"
+                              class="hanzi"
+                              :style="{
+                                fontSize: wordFontsize - 4 + 'px',
+                                lineHeight: wordLineHeight + 'px',
+                              }"
+                              >{{ '_' + itemss.pos }}</span
+                            >
                           </span>
                           <br v-if="pinyinShow" />
                           <template v-if="pinyinShow && pinyinBottom">
@@ -870,6 +896,29 @@
     <div id="echarts_none_1" style="display: none; width: 592px; height: 568px"></div>
     <div id="echarts_none_2" style="display: none; width: 592px; height: 568px"></div>
     <div id="echarts_none_3" style="display: none; width: 592px; height: 568px"></div>
+    <el-dialog
+      :show-close="false"
+      :visible.sync="editArticleFlag"
+      width="800px"
+      :before-close="handleClose"
+      :modal="false"
+      class="edit-dialog"
+    >
+      <el-input
+        v-model="noPosContent"
+        type="textarea"
+        placeholder="请输入文本"
+        :autosize="{ minRows: 9 }"
+        :maxlength="3000"
+      />
+      <span slot="footer" class="dialog-footer">
+        <span class="left">{{ noPosContent.length }}/{{ 3000 }}</span>
+        <div>
+          <el-button @click="handleClose">取 消</el-button>
+          <el-button type="primary" @click="saveWord(id)">确 定</el-button>
+        </div>
+      </span>
+    </el-dialog>
   </div>
 </template>
 
@@ -957,22 +1006,14 @@ export default {
       routerData: null,
       id: null,
       userID: this.$route.query.userID,
+      cixing: false, // 词性开关
+      editArticleFlag: false, // 修改文本
+      noPosContent: '',
     };
   },
   created() {
     this.routerData = this.$route.query;
     if (!this.routerData) return;
-    // this.partitionKey = Number(this.routerData.partition_key);
-    // this.subjectWords = JSON.parse(this.routerData.subject_words || '[]');
-    // this.base.wordTextCount = Number(this.routerData.word_text_count);
-    // this.base.wordCount = Number(this.routerData.word_count);
-    // this.base.vocabularyTextCount = Number(this.routerData.vocabulary_text_count);
-    // this.base.vocabularyCount = Number(this.routerData.vocabulary_count);
-    // this.base.pinyinCount = Number(this.routerData.pinyin_count);
-    // this.base.pinyinTextCount = Number(this.routerData.pinyin_text_count);
-    // this.difficulty.pinyinDifficulty = this.routerData.pinyin_difficulty;
-    // this.difficulty.vocabularyDifficulty = this.routerData.vocabulary_difficulty;
-    // this.difficulty.wordDifficulty = this.routerData.word_difficulty;
     this.id = this.routerData.id;
     this.getstatistics();
   },
@@ -1755,6 +1796,7 @@ export default {
     // 获取分析结果
     getArticleData() {
       this.loading = true;
+      let posStr = '';
       publicMethods('/TeachingServer/TextAnalyser/GetParsedTextInfo', {
         analyse_record_id: this.id,
       })
@@ -1863,6 +1905,22 @@ export default {
             this.difficulty.vocabularyDifficulty = res.record.vocabulary_ttr;
             this.difficulty.wordDifficulty = res.record.word_ttr;
             this.pinyinBottom = res.record.pinyin_mark_position !== 0;
+            newdata.forEach((item, index) => {
+              item.forEach((items, indexs) => {
+                items.forEach((itemss, indexss) => {
+                  let strWord = '';
+                  itemss.text.forEach((itemT, indexT) => {
+                    strWord += itemT.word;
+                  });
+                  posStr += strWord; //如果是英文 需要加空格
+                });
+                posStr += '\n';
+              });
+              if (index !== newdata.length - 1) {
+                posStr += '\n';
+              }
+            });
+            this.noPosContent = posStr;
             this.loading = false;
           }
         })
@@ -1905,6 +1963,75 @@ export default {
         path: '/TextAnalysis',
       });
     },
+    // 修改文本
+    editArticle() {
+      this.editArticleFlag = true;
+    },
+    handleClose() {
+      this.editArticleFlag = false;
+    },
+    saveWord(analyse_record_id) {
+      let saveArr = [];
+      let arr = this.noPosContent.split('\n');
+      let indexP = 0; // 段落索引
+      let indexS = 0; // 句子索引
+      let flag = true;
+      arr.forEach((item) => {
+        if (item === '') {
+          saveArr.push([]);
+        }
+      });
+      arr.forEach((item, index) => {
+        if (item === '') {
+          indexP++;
+          indexS = 0;
+        } else {
+          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: '',
+            };
+            saveItem.push(obj);
+          });
+          saveArr[indexP].push(saveItem);
+          indexS++;
+        }
+      });
+      //   if(!flag){
+      //     this.$message.warning('词性有错误请检查')
+      //     return
+      //   }
+      this.loading = true;
+      publicMethods('/TeachingServer/TextAnalyser/SetFCProofreadForAnalyseRecord', {
+        analyse_record_id: this.id,
+        proofread_text: {
+          paragraph_list: saveArr,
+        },
+        is_proofread_cx: 'false',
+      })
+        .then((res) => {
+          if (res.status === 1) {
+            this.$message.success('保存成功');
+            this.editArticleFlag = false;
+            reparse({ analyse_record_id })
+              .then(({ record }) => {
+                this.getArticleData();
+              })
+              .finally(() => {
+                this.loading = false;
+              });
+          }
+        })
+        .catch(() => {
+          this.loading = false;
+        });
+    },
   },
 };
 </script>
@@ -2409,6 +2536,7 @@ export default {
             font-weight: 600;
             line-height: 22px;
             color: #a5a5a5;
+            flex: 1;
 
             .twoline {
               margin: 0 20px;
@@ -2429,7 +2557,16 @@ export default {
               background: #525252;
             }
           }
-
+          .edit-btn {
+            color: #000;
+            font-size: 14px;
+            font-weight: 600;
+            line-height: 22px;
+            cursor: pointer;
+            .el-icon-edit {
+              margin-right: 8px;
+            }
+          }
           .articel {
             width: 640px;
             margin: 0 auto;
@@ -2507,4 +2644,31 @@ export default {
     height: 8px;
   }
 }
+.edit-dialog {
+  .el-dialog__header {
+    padding: 0;
+  }
+  .el-dialog__body {
+    padding: 16px;
+  }
+  .el-dialog__footer {
+    padding-top: 0;
+  }
+  .dialog-footer {
+    display: flex;
+    justify-content: space-between;
+    .el-button {
+      border-radius: 4px;
+      border: 1px solid rgba(0, 0, 0, 0.15);
+      background: #f8f8f8;
+      box-shadow: 0px 2px 0px 0px rgba(0, 0, 0, 0.04);
+      width: 124px;
+      padding: 8px;
+      color: #000;
+      &.el-button--primary {
+        background: #ffc600;
+      }
+    }
+  }
+}
 </style>

+ 90 - 5
src/views/teacher-dev/TextAnalysis.vue

@@ -4,6 +4,7 @@
     <div v-if="showPage" class="main">
       <div class="title">文本分析</div>
       <div class="input_main">
+        <el-input v-model="name" placeholder="请输入名称" />
         <el-input
           v-model="txt"
           type="textarea"
@@ -34,14 +35,24 @@
       <div v-if="data" class="list_main">
         <div class="title">
           <span style="margin-right: 16px">文本列表:</span>
+          <el-input v-model="searchInput" placeholder="检索" @keyup.enter.native="pageQueryMyTextAnalyseRecordList" />
         </div>
         <div v-loading="recordLoading" class="list">
+          <div class="list-th">
+            <div class="number"></div>
+            <div class="name">名称</div>
+            <div class="txt">内容预览</div>
+            <div class="time">创建时间</div>
+          </div>
           <div
             v-for="(item, i) in data.record_list"
             :key="`${i}one`"
             :style="{ backgroundColor: item.analysis_status === 0 ? '#FAF6EB' : '' }"
           >
             <div class="number">{{ pageSize * (data.cur_page - 1) + i + 1 }}</div>
+            <div class="name" @click="handleJump(item)">
+              {{ item.name }}
+            </div>
             <div class="txt" @click="handleJump(item)">
               {{ item.first_sentence }}
             </div>
@@ -54,10 +65,15 @@
             >
               {{ item.analysis_status === 3 ? '重新解析' : '解析' }}
             </div>
+            <span class="edit-btn" @click="editName(item)"><i class="el-icon-edit"></i></span>
             <el-popconfirm title="确定删除这一条记录吗?" @confirm="deleteTextAnalyseRecord(item.id)">
               <img slot="reference" src="../../assets/teacherdev/delete-one.png" alt="删除" />
             </el-popconfirm>
           </div>
+          <p v-if="data.record_list.length == 0" style="background-color: #fff; text-align: center; line-height: 200px">
+            <!-- <img src="../../assets/teacherdev/nodata.png" style="width: 1200px" /> -->
+            暂无数据
+          </p>
         </div>
         <el-pagination
           :current-page.sync="data.cur_page"
@@ -68,6 +84,13 @@
         />
       </div>
     </div>
+    <el-dialog title="编辑名称" :visible.sync="saveShow" width="30%" :before-close="handleClose" :modal="false">
+      <el-input placeholder="请输入" v-model="saveName"> </el-input>
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="handleClose">取 消</el-button>
+        <el-button type="primary" @click="save" :loading="loading">确 定</el-button>
+      </span>
+    </el-dialog>
   </div>
 </template>
 
@@ -80,6 +103,7 @@ import {
   reparse,
   DeleteTextAnalyseRecord,
   getStaticContent,
+  publicMethods,
 } from '@/api/api';
 import { getToken, setToken } from '@/utils/auth';
 import { getConfigInfor } from '@/utils/index';
@@ -111,6 +135,11 @@ export default {
       AppID: this.$route.query.AppID,
       showPage: false,
       userID: this.$route.query.UserID ? this.$route.query.UserID : '',
+      name: '',
+      saveShow: false,
+      saveName: '',
+      activeItem: null,
+      searchInput: '',
     };
   },
   computed: {
@@ -227,7 +256,7 @@ export default {
       reparse({ analyse_record_id })
         .then(({ record }) => {
           this.jumpResult(record);
-          this.pageQueryMyTextAnalyseRecordList(true);
+          // this.pageQueryMyTextAnalyseRecordList(true);
         })
         .finally(() => {
           this.loading = false;
@@ -237,6 +266,9 @@ export default {
      * 分析
      */
     submit() {
+      if (!this.name.trim()) {
+        return this.$message.warning('请先输入名称');
+      }
       if (this.txt === '') {
         return this.$message.warning('请先输入内容');
       }
@@ -246,12 +278,13 @@ export default {
       this.loading = true;
       analyse({
         text: this.txt,
+        name: this.name.trim(),
         app_user_id: this.userID,
       })
         .then(({ record }) => {
           //   this.txt = '';
           this.jumpResult(record);
-          this.pageQueryMyTextAnalyseRecordList(true);
+          // this.pageQueryMyTextAnalyseRecordList(true);
         })
         .finally(() => {
           this.loading = false;
@@ -278,6 +311,7 @@ export default {
         page_capacity: this.pageSize,
         cur_page: this.data?.cur_page ?? 1,
         app_user_id: this.userID,
+        search_content: this.searchInput.trim(),
       })
         .then((data) => {
           this.data = data;
@@ -293,6 +327,36 @@ export default {
       this.data.cur_page = val;
       this.pageQueryMyTextAnalyseRecordList();
     },
+    // 编辑名称
+    editName(item) {
+      this.saveShow = true;
+      this.saveName = item.name;
+      this.activeItem = item;
+    },
+    handleClose() {
+      this.saveShow = false;
+      this.activeItem = null;
+    },
+    // 保存
+    save() {
+      this.loading = true;
+      // 编辑
+      let Mname = '/TeachingServer/TextAnalyser/UpdateTextAnalyseRecordName';
+      publicMethods(Mname, {
+        id: this.activeItem.id,
+        name: this.saveName,
+      })
+        .then((res) => {
+          this.loading = false;
+          this.saveShow = false;
+          this.activeItem = null;
+          this.$message.success('保存成功');
+          this.pageQueryMyTextAnalyseRecordList();
+        })
+        .catch((res) => {
+          this.loading = false;
+        });
+    },
   },
 };
 </script>
@@ -326,7 +390,9 @@ export default {
       margin-top: 17px;
       background: #fff;
       border-radius: 4px;
-
+      .el-input {
+        margin-bottom: 16px;
+      }
       .text_btn {
         display: flex;
         align-items: center;
@@ -383,6 +449,12 @@ export default {
         font-weight: 400;
         line-height: 24px;
         color: #000;
+        display: flex;
+        justify-content: space-between;
+        align-items: center;
+        .el-input {
+          width: 220px;
+        }
       }
 
       .list {
@@ -404,9 +476,16 @@ export default {
             width: 20px;
             text-align: right;
           }
+          .name {
+            width: 150px;
+            overflow: hidden;
+            text-overflow: ellipsis;
+            white-space: nowrap;
+            cursor: pointer;
+          }
 
           .txt {
-            width: 740px;
+            width: 550px;
             overflow: hidden;
             text-overflow: ellipsis;
             white-space: nowrap;
@@ -416,7 +495,13 @@ export default {
           .time {
             width: 135px;
           }
-
+          .edit-btn {
+            width: 24px;
+            height: 24px;
+            font-size: 24px;
+            margin-top: -6px;
+            cursor: pointer;
+          }
           .cxjx {
             cursor: pointer;
           }