const $ = require("jquery"); require("babel-polyfill"); require("./../css/participle.less"); require("./../css/common.less"); const { post, api,getUrlArgObject,ifHideLogo,typeLis,typeLisName } = require('./api.js'); require('./../resources/images/empty2.png'); require('./../resources/images/iconUp.png'); require('./../resources/images/iconDown.png'); require('./../resources/images/syflogo.png'); require('./../resources/images/iconClose3.png'); require('./../css/img/icon_tu.png'); require('./../css/img/icon_wenzi.png'); const {currentIIData} = require('./data.js') ifHideLogo(); function appendCurrentII(currentIIList){ for(let i = 0; i < currentIIList.length; i++){ let str = `
${currentIIList[i].title} 引用
正在分析...
`); $("#svg").html(`正在分析...
`); $(".analying").css('display','block'); $('table').css("display","none") $('.empty').hide(); post(api.entity_predict, param).then(res =>{ if(res.data.code == '0'){ const data = JSON.parse(res.data.data) const result = data.data[0].entity_relation_object const entryList = result&&result.outputs&&result.outputs.annotation['T'] const relationList = result&&result.outputs&&result.outputs.annotation['R'] let content = result.content if((JSON.stringify(entryList)!='[""]')&&(JSON.stringify(relationList)!='[""]')){ // getRelationList(relationList,entryList) const relationListCopy = JSON.parse(JSON.stringify(relationList)) let enter = chageEnter(entryList) let rela = chageRelation(relationList) svgData = Object.assign(enter,rela,{"content":content}) if($("#svg").css("display") == "block"){ showSvg(svgData) } getSchema(content,entryList) getRelationList(relationListCopy,entryList) $('#analy').removeClass('disabled') }else{ // $('#analy').addClass('disabled') $('#resultBoxInfo').html('') $('.empty').css("display","block"); $('.analying').css("display","none"); $('.tableTitle').css("display","none"); $('table').css("display","none"); } } }) } $("#toggleImg").click(()=>{ $("#resultBoxInfo").css("display","block") $("#svg").css("display","none") $("#toggleImgs").removeClass("activeBtn") $("#toggleImg").addClass('activeBtn') // $("#toggleImg").css("display","none"); // $("#toggleImgs").css("display","block"); }) $("#toggleImgs").click(()=>{ $("#resultBoxInfo").css("display","none"); $("#svg").css("display","block") $("#svg").html(`正在生成,请稍后~
`); $("#toggleImg").removeClass("activeBtn") $("#toggleImgs").addClass("activeBtn") setTimeout(()=>{ showSvg(svgData) }) // $("#toggleImgs").css("display","none"); // $("#toggleImg").css("display","block"); }) 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 insertStr(soure, start, newStr){ return soure.slice(0, start) + newStr + soure.slice(start); } function getSchema(content, entryList){ let addNum = 0 for(let i = 1; i < entryList.length; i++){ content = insertStr(content, entryList[i].start+addNum, `* ${entryList[i].name}`) 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, '') addNum += 7 } else{ content = insertStr(content, entryList[i].end+addNum, '*') addNum += 34 } } $('#resultBoxInfo').html(content) $("#toggleImgs").css("display","block"); $("#toggleImg").css("display","block"); $(".entryItem").click(function(){ let hasCheck = getUrlArgObject("num"); if(!hasCheck){return} let txt = ($(this).html()).replace(/]*>(.|\n)*<\/span>/gi,"") let curType = $(this).find(".type").text() post(api.check, { "number": hasCheck, "word": txt, "word_type": typeLis[curType]||"transfusion" }).then(res =>{ if(res.data.code == '0'){ let result = res.data.data.standard_words||[] if(result.length == 0){ $(".showCheck").css("display","none") return } let str = '',head=`