zhangxc 5 роки тому
батько
коміт
d6e369e3fa
4 змінених файлів з 21 додано та 11 видалено
  1. 5 2
      src/css/participle.less
  2. 1 1
      src/js/api.js
  3. 14 6
      src/js/participle.js
  4. 1 2
      webpack.config.js

+ 5 - 2
src/css/participle.less

@@ -111,6 +111,9 @@
             // css保留换行符
             // white-space: pre-line;
         }
+        .star{
+            color: #000;
+        }
         .entryItem{
             display: inline-block;
             color: blue;
@@ -124,10 +127,9 @@
             left: 50%;
             transform: translateX(-50%);
             display: inline-block;
-            background: #000;
+            background: #7F7F7F;
             padding: 5px;
             font-size: 14px;
-            opacity: .8;
             color: #fff;
             display: none;
             border-radius:4px;
@@ -143,6 +145,7 @@
             border-style: solid;
             border-color:#000 transparent transparent transparent;
         }
+     
         .entryItem:hover{
             span{
                 display: inline-block;

+ 1 - 1
src/js/api.js

@@ -4,7 +4,7 @@ const api = {
   getNode:'/api/ltkg/kg/getNode',
   getSchema:'/api/ltkg/kg/getSchema',
   getTree:'/api/ltkg/kg/getTree',
-  entity_predict:'http://192.168.3.150:3456/api/mr_info_ex/entity_predict'
+  entity_predict:'api/ltkg/nlp/getNlp'
 };
 
 const getUrlArgObject = function(name) {//

+ 14 - 6
src/js/participle.js

@@ -24,8 +24,10 @@ function getEntityPredict(){
 
     }
     post(api.entity_predict, param).then(res =>{
-        const data = JSON.parse(res.data)
-        if(data.status){
+        console.log(res,'res')
+      
+        if(res.data.code == '0'){
+            const data = JSON.parse(res.data.data)
             const result = data.data[0].entity_relation_object
             const entryList  = result.outputs.annotation['T']
             const relationList = result.outputs.annotation['R']
@@ -39,10 +41,16 @@ function getEntityPredict(){
 function getSchema(content, entryList){
     let addNum = 0
     for(let i = 1; i < entryList.length; i++){
-        content = insertStr(content, entryList[i].start+addNum, `<span class="entryItem"><span class="type"><span class="trangle"></span>${entryList[i].name}</span>`)
-        addNum += 50 + entryList[i].name.length + 29
-        content = insertStr(content, entryList[i].end+addNum, '</span>')
-        addNum += 7
+        content = insertStr(content, entryList[i].start+addNum, `<span class="star">*</span><span class="entryItem"><span class="type"><span class="trangle"></span>${entryList[i].name}</span>`)
+        addNum += 106 + entryList[i].name.length
+        if(i < entryList.length-1&&(entryList[i].end ===entryList[i+1].start)){
+            content = insertStr(content, entryList[i].end+addNum, '</span>')
+            addNum += 7
+        } else{
+            content = insertStr(content, entryList[i].end+addNum, '</span><span class="star">*</span>')
+            addNum += 34
+        }
+        
     }
     $('.resultBoxInfo').html(content)
 }

+ 1 - 2
webpack.config.js

@@ -5,8 +5,7 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
 const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
 const ExtractTextPlugin = require("extract-text-webpack-plugin");
 const webpack = require('webpack');
-// const proxyHost = "http://192.168.2.236:5050";
-const proxyHost = "http://192.168.3.150:3456";
+const proxyHost = "http://192.168.2.236:5050";
 module.exports = {
   entry: {
     index: path.resolve(__dirname, 'src/js', 'index.js'),