From a594b620f157d97de1d73de685b26438b82289d4 Mon Sep 17 00:00:00 2001 From: maxmon <541182180@qq.com> Date: Sun, 16 Apr 2023 19:35:42 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=8C=E6=88=90=E5=85=B3=E7=B3=BB?= =?UTF-8?q?=E6=A0=87=E6=B3=A8=E6=8E=A5=E5=8F=A3=E8=81=94=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- be/app/api/v1/anno.py | 7 ++++--- be/app/entities/entities.py | 1 + fe/src/components/NER/index.vue | 8 +++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/be/app/api/v1/anno.py b/be/app/api/v1/anno.py index b82f03f..72ac7ca 100644 --- a/be/app/api/v1/anno.py +++ b/be/app/api/v1/anno.py @@ -41,13 +41,14 @@ def query_anno(): file_content = read_file(file_path) anno_output_path = ANNO_OUTPUT_PATH.format(project_name, file_name) - anno_details = [] + j = {} if os.path.exists(anno_output_path): - anno_details = json.loads(read_file(anno_output_path))['annoDetails'] + j = json.loads(read_file(anno_output_path)) query_anno = QueryAnno() query_anno.fileContent = file_content - query_anno.annoDetails = anno_details + query_anno.annoDetails = j.get('annoDetails', []) + query_anno.relDetails = j.get('relDetails', []) ret_info.info = query_anno ret_info.errCode = 0 diff --git a/be/app/entities/entities.py b/be/app/entities/entities.py index 9b13883..b9f3f4e 100644 --- a/be/app/entities/entities.py +++ b/be/app/entities/entities.py @@ -15,6 +15,7 @@ class ReturnInfo: class QueryAnno: def __init__(self): self.annoDetails = [] + self.relDetails = [] self.fileContent = '' # self.isAnno = False diff --git a/fe/src/components/NER/index.vue b/fe/src/components/NER/index.vue index 28003c5..bf218ea 100644 --- a/fe/src/components/NER/index.vue +++ b/fe/src/components/NER/index.vue @@ -349,8 +349,9 @@ export default { const hasCache = !!that.nersCache[newFile] that.$set(that, 'ners', that.nersCache[newFile] ? [...that.nersCache[newFile]] : []) that.flushWordsType() - if (that.nowText) { + if (that.nowText && that.projectType !== '关系标注') { delete window.isLoadingNowText + return } else { get(`/v1/anno/query?projectName=${that.projectName}&fileName=${newFile}`, function (info) { delete window.isLoadingNowText @@ -364,6 +365,10 @@ export default { // 更新文件的标注缓存 that.$set(that.nersCache, newFile, info.annoDetails) } + if (that.projectType === '关系标注' && newFile === that.nowFile) { + console.log('relDetails', info.relDetails) + that.$set(that, 'relDetails', info.relDetails || []) + } // 更新文件的文本缓存 that.$set(that.textDic, newFile, info.fileContent) if (newFile === that.nowFile) { @@ -577,6 +582,7 @@ export default { type: this.nowType }) this.$set(this, 'relStartIdx', undefined) + this.save() } else { this.$set(this, 'relStartIdx', idx) }