Bladeren bron

关系抽取

zhangxc 5 jaren geleden
bovenliggende
commit
36480abf24
6 gewijzigde bestanden met toevoegingen van 173 en 5 verwijderingen
  1. 70 0
      src/css/participle.less
  2. 31 0
      src/html/participle.html
  3. 5 3
      src/js/api.js
  4. 0 1
      src/js/index.js
  5. 51 0
      src/js/participle.js
  6. 16 1
      webpack.config.js

+ 70 - 0
src/css/participle.less

@@ -0,0 +1,70 @@
+.content{
+    position: relative;
+    background: #fff;
+    border: 1px solid #f4f4f4;
+    padding: 20px;
+    margin: 10px 25px;  
+    .title{
+        margin: 10px 0 20px 0;
+        font-size: 22px;
+        padding-bottom: 9px;
+        margin: 40px 0 20px;
+        border-bottom: 1px solid #eee;
+    }
+    .infoBox{
+        display: block;
+    }
+    textarea{
+      
+        width: calc(100% - 30px);
+        padding: 6px 12px;
+        font-size: 14px;
+        line-height: 1.42857143;
+        color: #555;
+        background-color: #fff;
+        background-image: none;
+        border: 1px solid #ccc;
+        border-radius: 4px;
+        -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
+        box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
+        -webkit-transition: border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;
+        -o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
+        transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
+    }
+    .btnBox{
+        margin: 20px 0;
+    }
+    .btn{
+        background-color: #00a65a;
+        border-color: #008d4c;
+        color: #fff;
+        padding: 10px;
+        float: right;
+    }
+    .resultBox{
+        white-space: pre-wrap;
+        // css保留换行符
+        // white-space: pre-line;
+    }
+    .entryItem{
+        color: blue;
+        position: relative;
+    }
+    .type{
+        position: absolute;
+        top: -20px;
+        white-space: nowrap;
+        left: 50%;
+        transform: translateX(-50%);
+        display: inline-block;
+        background: #abcdef;
+        color: #000;
+        display: none;
+    }
+    .entryItem:hover{
+        span{
+            display: inline-block;
+        }
+    }
+   
+}

+ 31 - 0
src/html/participle.html

@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="UTF-8">
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
+  <meta http-equiv="X-UA-Compatible" content="ie=edge">
+  <title><%= htmlWebpackPlugin.options.title %></title>
+</head>
+<body>
+  <div>
+      <div class="content">
+        <p class="title">病例</p>
+        <div class="infoBox">
+            <textarea name="" id="infoTxt" cols="30" rows="10"></textarea>
+        </div>
+        <div class="btnBox clearfix">
+            <span class="btn" id="analy">开始分析</span>
+        </div>
+        <p  class="title">结构化</p>
+        <div class="resultBox"></div>
+        <table>
+            <tr></tr>
+        </table>
+      </div>
+      
+  </div>
+  
+</body>
+
+</html>
+

+ 5 - 3
src/js/api.js

@@ -3,9 +3,11 @@ const api = {
   getGraph:'/api/ltkg/kg/getGraph',
   getNode:'/api/ltkg/kg/getNode',
   getSchema:'/api/ltkg/kg/getSchema',
-  getTree:'/api/ltkg/kg/getTree'
+  getTree:'/api/ltkg/kg/getTree',
+  entity_predict:'http://192.168.3.150:3456/api/mr_info_ex/entity_predict'
 }
 
+
 const post = function (url, data) {
     return new Promise((resolve, reject) => {
       $.ajax({
@@ -14,8 +16,8 @@ const post = function (url, data) {
         data: JSON.stringify(data),
         contentType: "application/json; charset=UTF-8",
         beforeSend: function (xmlHttp) {
-          xmlHttp.setRequestHeader("If-Modified-Since", "0");
-          xmlHttp.setRequestHeader("Cache-Control", "no-cache");
+          // xmlHttp.setRequestHeader("If-Modified-Since", "0");
+          // xmlHttp.setRequestHeader("Cache-Control", "no-cache");
         },
         success: function (res) {
           resolve({ data: res });

+ 0 - 1
src/js/index.js

@@ -17,7 +17,6 @@ require('./../resources/images/logo.png');
 require('./../resources/zTree/js/jquery.ztree.core.min.js');
 require('./../resources/zTree/js/jquery.ztree.excheck.min.js')
 require('./../resources/zTree/css/zTreeStyle/zTreeStyle.css');
-// document.write("aaaa");
 const { post, api } = require('./api.js');
 const { mapData, zTreeData,mapData3,zTreeData3 } = require('./data.js');
 const { drawGraph,updateTree,getGraph,getTree,getNode } = require('./graphMap.js');

+ 51 - 0
src/js/participle.js

@@ -0,0 +1,51 @@
+const $ = require("jquery");
+require("babel-polyfill");
+require("./../css/participle.less");
+require("./../css/common.css");
+const { post, api } = require('./api.js');
+
+
+function insertStr(soure, start, newStr){   
+
+    return soure.slice(0, start) + newStr + soure.slice(start);
+ }
+function getEntityPredict(){
+    const val = $('#infoTxt').val()
+    console.log(val)
+    const param ={
+        data:[
+            {"medical_text_type": "chief_present",
+             "content": val,
+             "title": "自定义添加的属性",
+             "detail_title": "自定义添加的属性"
+             }
+    
+        ]
+
+    }
+    post(api.entity_predict, param).then(res =>{
+        const data = JSON.parse(res.data)
+        console.log('res', data)
+        if(data.status){
+            const result = data.data[0].entity_relation_object
+            const entryList  = result.outputs.annotation['T']
+            let content = result.content
+            let addNum = 0
+            console.log('entryList',entryList)
+            for(let i = 1; i < entryList.length; i++){
+                content = insertStr(content, entryList[i].start+addNum, `<span class="entryItem"><span class="type">${entryList[i].name}</span>`)
+                addNum += 50 + entryList[i].name.length
+                content = insertStr(content, entryList[i].end+addNum, '</span>')
+                addNum += 7
+            }
+            console.log('content',content)
+            $('.resultBox').html(content)
+        }
+    })
+}
+
+
+$("#analy").click(function(){
+    getEntityPredict()
+})
+

+ 16 - 1
webpack.config.js

@@ -5,11 +5,13 @@ 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.2.236:5050";
+const proxyHost = "http://192.168.3.150:3456";
 module.exports = {
   entry: {
     index: path.resolve(__dirname, 'src/js', 'index.js'),
     knowledgeTree: path.resolve(__dirname, 'src/js', 'knowledgeTree.js'),
+    participle: path.resolve(__dirname,'src/js', 'participle.js'),
     vendor: 'lodash'// 多个页面所需的公共库文件,防止重复打包带入
   },
   output: {
@@ -48,6 +50,19 @@ module.exports = {
           collapseWhitespace: true //删除空白符与换行符
         }
       }),
+      new HtmlWebpackPlugin({
+        title: 'participle',
+        template: path.resolve(__dirname, 'src/html', 'participle.html'),
+        filename: 'participle.html',
+        chunks: ['participle', 'vendor', 'common'],
+        inject: true,
+        hash: true, //防止缓存
+        minify: {
+          removeAttributeQuotes: true, //压缩 去掉引号
+          removeComments: true, //移除HTML中的注释
+          collapseWhitespace: true //删除空白符与换行符
+        }
+      }),
     new MiniCssExtractPlugin({
       filename: 'css/[name].css',
       chunkFilename: '[id].css'