|
@@ -92,12 +92,73 @@ function getEntityPredict(){
|
|
const entryList = result&&result.outputs&&result.outputs.annotation['T']
|
|
const entryList = result&&result.outputs&&result.outputs.annotation['T']
|
|
const relationList = result&&result.outputs&&result.outputs.annotation['R']
|
|
const relationList = result&&result.outputs&&result.outputs.annotation['R']
|
|
let content = result.content
|
|
let content = result.content
|
|
- getSchema(content,entryList)
|
|
|
|
- getRelationList(relationList,entryList)
|
|
|
|
|
|
+ // getSchema(content,entryList)
|
|
|
|
+ if((JSON.stringify(entryList)!='[""]')&&(JSON.stringify(relationList)!='[""]')){
|
|
|
|
+ getRelationList(relationList,entryList)
|
|
|
|
+ let enter = chageEnter(entryList)
|
|
|
|
+ let rela = chageRelation(relationList)
|
|
|
|
+ let svgData = Object.assign(enter,rela,{"content":content})
|
|
|
|
+ showSvg(svgData)
|
|
|
|
+ $('#analy').removeClass('disabled')
|
|
|
|
+ }else{
|
|
|
|
+ $('#analy').addClass('disabled')
|
|
|
|
+ $('.resultBoxInfo').html('')
|
|
|
|
+ $('.empty').css("display","block");
|
|
|
|
+ $('.analying').css("display","none")
|
|
|
|
+ $('table').css("display","none")
|
|
|
|
+ }
|
|
}
|
|
}
|
|
})
|
|
})
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+function chageEnter(data){
|
|
|
|
+ var keyMap = {
|
|
|
|
+ "name" : "text",
|
|
|
|
+ "start" : "startIndex",
|
|
|
|
+ "end" : "endIndex",
|
|
|
|
+ "id" : "categoryId",
|
|
|
|
+ };
|
|
|
|
+ for(let i = 0;i < data.length;i++){
|
|
|
|
+ let obj = data[i];
|
|
|
|
+ for(let key in obj){
|
|
|
|
+ let newKey = keyMap[key];
|
|
|
|
+ if(newKey){
|
|
|
|
+ obj[newKey] = obj[key];
|
|
|
|
+ // delete obj[key];
|
|
|
|
+ }
|
|
|
|
+ obj.color = "red"
|
|
|
|
+ obj.borderColor = "#5A8EEE"
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ data.splice(0,1)
|
|
|
|
+ return {
|
|
|
|
+ "labelCategories":data,
|
|
|
|
+ "labels":data
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+function chageRelation(data){
|
|
|
|
+ var keyMap = {
|
|
|
|
+ "name" : "text",
|
|
|
|
+ "from" : "fromId",
|
|
|
|
+ "to" : "toId",
|
|
|
|
+ "id" : "categoryId",
|
|
|
|
+ };
|
|
|
|
+ for(let i = 0;i < data.length;i++){
|
|
|
|
+ let obj = data[i];
|
|
|
|
+ for(let key in obj){
|
|
|
|
+ let newKey = keyMap[key];
|
|
|
|
+ if(newKey){
|
|
|
|
+ obj[newKey] = obj[key];
|
|
|
|
+ }
|
|
|
|
+ obj.id = i
|
|
|
|
+ obj.categoryId = i
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ data.splice(0,1)
|
|
|
|
+ return {
|
|
|
|
+ "connectionCategories":data,
|
|
|
|
+ "connections":data,
|
|
|
|
+ }
|
|
|
|
+}
|
|
function getSchema(content, entryList){
|
|
function getSchema(content, entryList){
|
|
let addNum = 0
|
|
let addNum = 0
|
|
for(let i = 1; i < entryList.length; i++){
|
|
for(let i = 1; i < entryList.length; i++){
|
|
@@ -110,7 +171,6 @@ function getSchema(content, entryList){
|
|
content = insertStr(content, entryList[i].end+addNum, '</span><span class="star">*</span>')
|
|
content = insertStr(content, entryList[i].end+addNum, '</span><span class="star">*</span>')
|
|
addNum += 34
|
|
addNum += 34
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
$('.resultBoxInfo').html(content)
|
|
$('.resultBoxInfo').html(content)
|
|
}
|
|
}
|
|
@@ -171,3 +231,17 @@ $("#infoTxt").bind("input propertychange",function(event){
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+function showSvg(data){
|
|
|
|
+ $("#svg").html("")//防止页面不渲染
|
|
|
|
+ const poplar = require('poplar-annotation');
|
|
|
|
+ const {Annotator} = poplar;
|
|
|
|
+ const elm = document.getElementById("svg");
|
|
|
|
+ new Annotator(data,elm,{
|
|
|
|
+ contentEditable:false,
|
|
|
|
+ unconnectedLineStyle:"none",
|
|
|
|
+ labelPadding:3,
|
|
|
|
+ topContextMargin:-4,
|
|
|
|
+ bracketWidth:5,
|
|
|
|
+ labelWidthCalcMethod:'label'
|
|
|
|
+ });
|
|
|
|
+}
|