|
@@ -0,0 +1,95 @@
|
|
|
+const $ = require("jquery");
|
|
|
+require("babel-polyfill");
|
|
|
+require("./../css/participle.less");
|
|
|
+require("./../css/common.css");
|
|
|
+const { post, api } = require('./api.js');
|
|
|
+require('./../resources/images/empty2.png');
|
|
|
+
|
|
|
+
|
|
|
+function insertStr(soure, start, newStr){
|
|
|
+
|
|
|
+ return soure.slice(0, start) + newStr + soure.slice(start);
|
|
|
+ }
|
|
|
+function getEntityPredict(){
|
|
|
+ const val = $('#infoTxt').val()
|
|
|
+ const param ={
|
|
|
+ data:[
|
|
|
+ {"medical_text_type": "chief_present",
|
|
|
+ "content": val,
|
|
|
+ "title": "自定义添加的属性",
|
|
|
+ "detail_title": "自定义添加的属性"
|
|
|
+ }
|
|
|
+
|
|
|
+ ]
|
|
|
+
|
|
|
+ }
|
|
|
+ post(api.entity_predict, param).then(res =>{
|
|
|
+ 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']
|
|
|
+ let content = result.content
|
|
|
+ getSchema(content,entryList)
|
|
|
+ getRelationList(relationList,entryList)
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+function getSchema(content, entryList){
|
|
|
+ let addNum = 0
|
|
|
+ for(let i = 1; i < entryList.length; i++){
|
|
|
+ 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 += 107 + 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)
|
|
|
+}
|
|
|
+function getRelationList(relationList,entryList){
|
|
|
+ let str = ''
|
|
|
+ for(let i = 1; i < relationList.length; i++){
|
|
|
+ const relationItem = relationList[i]
|
|
|
+ const relationName = relationList[i].name
|
|
|
+ const entry1 = entryList.find(item => item.id === relationList[i].from).value
|
|
|
+ const entry2 = entryList.find(item => item.id === relationList[i].to).value
|
|
|
+ str += `<tr>
|
|
|
+ <td class="entry1">${entry1}</td>
|
|
|
+ <td class="relationType">${relationName}</td>
|
|
|
+ <td class="entry2">${entry2}</td>
|
|
|
+ </tr>`
|
|
|
+ }
|
|
|
+ if(str){
|
|
|
+ $('.empty').css("display","none");
|
|
|
+ $('table').css("display","table")
|
|
|
+ }
|
|
|
+ $('.relationBody').html(str)
|
|
|
+}
|
|
|
+
|
|
|
+$("#analy").click(function(){
|
|
|
+ const val = $("#infoTxt").val().trim()
|
|
|
+ if(val){
|
|
|
+ getEntityPredict()
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+$("#infoTxt").bind("input propertychange",function(event){
|
|
|
+ const val = $("#infoTxt").val().trim()
|
|
|
+ if(!val){
|
|
|
+ $('#analy').addClass('disabled')
|
|
|
+ $('.resultBoxInfo').html('')
|
|
|
+ $('.empty').css("display","block");
|
|
|
+ $('table').css("display","none")
|
|
|
+ }else{
|
|
|
+ $('#analy').removeClass('disabled')
|
|
|
+ }
|
|
|
+});
|
|
|
+
|