Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
DA-Platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
文档服务地址:
http://47.92.0.57:3000/
周报索引地址:
http://47.92.0.57:3000/s/NruNXRYmV
Open sidebar
Berlin
DA-Platform
Commits
340ec3ec
Commit
340ec3ec
authored
Jul 06, 2020
by
郭婉茹
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
文本标注
parent
95703c75
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
156 additions
and
42 deletions
+156
-42
SelectText.vue
...atform-front/src/components/textAnnotation/SelectText.vue
+144
-39
SelectedText.vue
...form-front/src/components/textAnnotation/SelectedText.vue
+12
-3
Table.vue
DAPlatform-front/src/components/textAnnotation/Table.vue
+0
-0
Tabled.vue
DAPlatform-front/src/components/textAnnotation/Tabled.vue
+0
-0
No files found.
DAPlatform-front/src/components/textAnnotation/SelectText.vue
View file @
340ec3ec
...
...
@@ -13,7 +13,7 @@
<div
class=
"tokenList"
v-for=
"it in tokenList"
:key=
"it
.message
"
:key=
"it"
style=
"user-select:none; float: left;"
>
<el-tag
...
...
@@ -23,7 +23,7 @@
:disable-transitions=
"false"
@
close=
"handleTokenClose(it)"
>
<a
class=
"token"
v-html=
"it"
></a>
<a
class=
"token"
v-html=
"it
.word
"
></a>
</el-tag>
<br
/>
</div>
...
...
@@ -307,9 +307,14 @@ export default {
label
:
"时间"
}
],
value
:
""
,
search
:
""
,
tokenId
:
1
,
token
:{
entityId
:
""
,
word
:
""
,
begin
:
0
,
end
:
0
,
attribute
:
""
,
tokenId
:
""
},
tokenList
:
[]
};
},
...
...
@@ -317,10 +322,30 @@ export default {
handleNodeClick
(
data
)
{
console
.
log
(
data
);
},
//获取文本
getContent
(){
this
.
axios
({
method
:
"post"
,
url
:
"http://127.0.0.1:9100/uploadDownload/getFileContent"
,
data
:
{
documentId
:
"a55a28d4a25811ea93c354e1ad87433a"
//改成通用跳转传过来的documentId
}
}).
then
(
res
=>
{
if
(
res
.
return_code
==
200
)
console
.
log
(
"123"
+
res
.
result
);
//res.result就是文本的内容
else
{
this
.
$message
({
message
:
res
.
return_info
,
type
:
"error"
});
}
});
},
// 暂时没用
handleOption
()
{
console
.
log
(
this
.
value
);
if
(
this
.
value
)
{
console
.
log
(
this
.
token
.
entityId
);
if
(
this
.
token
.
entityId
)
{
this
.
$message
({
message
:
"创建成功!"
,
type
:
"success"
...
...
@@ -333,46 +358,61 @@ export default {
this
.
ifAlert
=
0
;
let
res
=
this
.
$refs
.
tree
.
getCheckedNodes
();
let
arr
=
[];
let
token
=
{};
res
.
forEach
(
item
=>
{
arr
.
push
(
item
.
label
);
});
console
.
log
(
"111"
+
arr
);
this
.
token
List
.
push
(
this
.
search
)
;
this
.
token
.
attribute
=
arr
[
0
]
;
this
.
msg
=
this
.
msg
.
map
(
item
=>
{
let
replaceReg
=
new
RegExp
(
this
.
search
,
"g"
);
// 匹配关键字正则
let
replaceReg
=
new
RegExp
(
this
.
token
.
word
,
"g"
);
// 匹配关键字正则
let
replaceString
=
'<span class="highlights-text">'
+
this
.
search
+
this
.
token
.
word
+
"</span>"
+
'<span class="mark">'
+
"(实体:"
+
this
.
value
+
this
.
token
.
entityId
+
";属性:"
+
arr
+
")"
+
"</span>"
;
// 高亮替换v-html值
// 保存实体
if
(
this
.
value
==
""
&&
this
.
arr
==
[])
{
if
(
this
.
token
.
entityId
==
""
&&
arr
==
[])
{
return
;
}
this
.
axios
({
method
:
"post"
,
url
:
"/textAnnotation/addToken"
,
url
:
"
http://127.0.0.1:9100
/textAnnotation/addToken"
,
data
:
{
entityId
:
this
.
value
,
// 这里类型似乎是string
word
:
this
.
search
,
attribute
:
this
.
arr
,
// 修改实体时待改正
tokenId
:
this
.
tokenId
+
1
documentId
:
"a55a28d4a25811ea93c354e1ad87433a"
,
//改成通用跳转传过来的documentId
token
:{
entityId
:
this
.
token
.
entityId
,
// 这里类型似乎是string
word
:
this
.
token
.
word
,
begin
:
this
.
token
.
begin
,
end
:
this
.
token
.
end
,
attribute
:
arr
[
0
],
}
}
}).
then
(
res
=>
{
if
(
res
.
return_code
==
200
){
this
.
token
.
tokenId
=
res
.
result
token
=
this
.
token
this
.
token
=
{};
this
.
tokenList
.
push
(
token
);
}
else
{
this
.
$message
({
message
:
res
.
return_info
,
type
:
"error"
});
}
}).
then
(
res
=>
{
console
.
log
(
"123"
+
res
);
});
// 不知道为啥有缓存不能清除
this
.
$nextTick
(()
=>
{
this
.
$refs
.
tree
.
setCheckedKeys
([]);
});
this
.
value
=
""
;
this
.
token
.
entityId
=
""
;
return
item
.
replace
(
replaceReg
,
replaceString
);
});
this
.
$message
({
...
...
@@ -380,43 +420,96 @@ export default {
type
:
"success"
});
},
// 修改实体属性
// 修改实体属性
=删除+添加(如果选择属性弹窗没有点提交直接关掉的话会删除)
handleTokenChange
(
tag
)
{
console
.
log
(
"123"
+
tag
);
this
.
ifAlert
=
true
;
this
.
token
=
tag
;
this
.
tokenList
.
splice
(
this
.
tokenList
.
indexOf
(
tag
),
1
);
this
.
axios
({
method
:
"post"
,
url
:
"http://127.0.0.1:9100/textAnnotation/deleteToken"
,
//改成通用跳转传过来的documentId
data
:
{
documentId
:
"a55a28d4a25811ea93c354e1ad87433a"
,
tokenId
:
this
.
token
.
tokenId
}
}).
then
(
res
=>
{
if
(
res
.
return_code
==
200
)
console
.
log
(
"123"
+
res
.
return_info
);
else
{
this
.
$message
({
message
:
res
.
return_info
,
type
:
"error"
});
}
});
},
// 直接调用修改接口(因为选择属性弹窗的提交会触发保存标注操作所以会再次产生一个标注,修改也不会成功)
// handleTokenChange(tag) {
// this.ifAlert = true;
// let token = tag;
// this.token = tag;
// tag = {};
// this.axios({
// method: "post",
// url: "http://127.0.0.1:9100/textAnnotation/revToken",
// data: {
// documentId: "a55a28d4a25811ea93c354e1ad87433a",//改成通用跳转传过来的documentId
// token:{
// entityId: this.token.entityId, // 这里类型似乎是string
// word: this.token.word,
// begin: this.token.begin,
// end: this.token.end,
// attribute: arr[0],
// // 修改实体时待改正
// tokenId: this.token.tokenId
// }
// }
// }).then(res => {
// if(res.return_code == 200){
// console.log("123" + res.return_info);
// this.token.attribute = arr[0];
// arr = [];
// this.tokenList.splice(this.tokenList.indexOf(token), 1);
// this.tokenList.push(this.token);
// }
// });
// },
// 删除实体属性
handleTokenClose
(
tag
)
{
this
.
tokenList
.
splice
(
this
.
tokenList
.
indexOf
(
tag
),
1
);
this
.
search
=
tag
;
console
.
log
(
"123"
+
tag
);
this
.
token
=
tag
;
this
.
msg
=
this
.
msg
.
map
(
item
=>
{
let
replaceReg
=
new
RegExp
(
'<span class="highlights-text">'
+
this
.
search
+
"</span>"
,
'<span class="highlights-text">'
+
this
.
token
.
word
+
"</span>"
,
"g"
);
// 匹配关键字正则
let
replaceString
=
this
.
search
;
//
保存实体
if
(
this
.
value
==
""
&&
this
.
arr
==
[])
{
let
replaceString
=
this
.
token
.
word
;
//
if
(
this
.
token
.
entityId
==
""
&&
this
.
token
.
attribute
==
[])
{
return
;
}
this
.
axios
({
method
:
"post"
,
url
:
"
/textAnnotation/add
Token"
,
url
:
"
http://127.0.0.1:9100/textAnnotation/delete
Token"
,
data
:
{
entityId
:
this
.
value
,
// 这里类型似乎是string
word
:
this
.
search
,
attribute
:
this
.
arr
,
tokenId
:
this
.
tokenId
+
1
documentId
:
"a55a28d4a25811ea93c354e1ad87433a"
,
//改成通用跳转传过来的documentId
tokenId
:
this
.
token
.
tokenId
}
}).
then
(
res
=>
{
console
.
log
(
"123"
+
res
);
if
(
res
.
return_code
==
200
)
console
.
log
(
"123"
+
res
.
return_info
);
else
{
this
.
$message
({
message
:
res
.
return_info
,
type
:
"error"
});
}
});
// 不知道为啥不清除
this
.
$nextTick
(()
=>
{
this
.
$refs
.
tree
.
setCheckedKeys
([]);
});
this
.
value
=
""
;
this
.
token
.
entityId
=
""
;
return
item
.
replace
(
replaceReg
,
replaceString
);
});
this
.
$message
({
...
...
@@ -440,8 +533,10 @@ export default {
if
(
window
.
getSelection
().
toString
()
!=
""
)
{
//console.log("1111"+window.getSelection().toString());
this
.
ifAlert
=
true
;
//var search;
this
.
search
=
window
.
getSelection
().
toString
();
//var word;
this
.
token
.
word
=
window
.
getSelection
().
toString
();
this
.
token
.
begin
=
window
.
getSelection
().
anchorOffset
;
//开始位置
this
.
token
.
end
=
window
.
getSelection
().
focusOffset
;
//结束位置
}
},
// 提交本次标注
...
...
@@ -461,7 +556,17 @@ export default {
documentId
:
"a55a28d4a25811ea93c354e1ad87433a"
}
}).
then
(
res
=>
{
console
.
log
(
res
.
data
);
if
(
res
.
return_code
==
200
){
res
.
result
.
forEach
(
element
=>
{
this
.
tokenList
.
push
(
element
)
});
}
else
{
this
.
$message
({
message
:
res
.
return_info
,
type
:
"error"
});
}
});
}
},
...
...
DAPlatform-front/src/components/textAnnotation/SelectedText.vue
View file @
340ec3ec
...
...
@@ -18,7 +18,7 @@
style=
"user-select:none; float: left;"
>
<el-tag
size=
"small"
>
<a
class=
"token"
v-html=
"it"
></a>
<a
class=
"token"
v-html=
"it
.word
"
></a>
</el-tag>
<br
/>
</div>
...
...
@@ -121,7 +121,8 @@ export default {
score
:
""
},
formLabelWidth
:
"120px"
,
tokenList
:
[
"2020-05-06"
,
"2019年7月"
,
"雪山"
]
// tokenList: ["2020-05-06", "2019年7月", "雪山"]
tokenList
:
[]
};
},
methods
:
{
...
...
@@ -142,7 +143,15 @@ export default {
documentId
:
"a55a28d4a25811ea93c354e1ad87433a"
}
}).
then
(
res
=>
{
console
.
log
(
res
.
data
);
if
(
res
.
return_code
==
200
){
this
.
tokenList
=
res
.
result
}
else
{
this
.
$message
({
message
:
res
.
return_info
,
type
:
"error"
});
}
});
},
addScore
()
{
...
...
DAPlatform-front/src/components/textAnnotation/Table.vue
View file @
340ec3ec
This diff is collapsed.
Click to expand it.
DAPlatform-front/src/components/textAnnotation/Tabled.vue
0 → 100644
View file @
340ec3ec
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment