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
57ebb542
Commit
57ebb542
authored
Jul 28, 2020
by
wyy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
文本导出优化
parent
78bb1298
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
66 additions
and
4 deletions
+66
-4
SelectText.vue
...atform-front/src/components/textAnnotation/SelectText.vue
+1
-0
SelectedCheck.vue
...orm-front/src/components/textAnnotation/SelectedCheck.vue
+1
-0
SelectedText.vue
...form-front/src/components/textAnnotation/SelectedText.vue
+1
-0
Table.vue
DAPlatform-front/src/components/textAnnotation/Table.vue
+1
-0
Tabled.vue
DAPlatform-front/src/components/textAnnotation/Tabled.vue
+1
-0
TabledCheck.vue
...tform-front/src/components/textAnnotation/TabledCheck.vue
+1
-0
textAnnotation.py
DAPlatform/views/textAnnotation.py
+5
-4
uploadDownload.py
DAPlatform/views/uploadDownload.py
+55
-0
文本标注接口列表.docx
文档/文本标注接口列表.docx
+0
-0
No files found.
DAPlatform-front/src/components/textAnnotation/SelectText.vue
View file @
57ebb542
...
@@ -131,6 +131,7 @@ export default {
...
@@ -131,6 +131,7 @@ export default {
templateId
:
this
.
piece
.
template
,
// TODO 模板id
templateId
:
this
.
piece
.
template
,
// TODO 模板id
annotatorId
:
this
.
$store
.
state
.
userInfo
.
userId
,
annotatorId
:
this
.
$store
.
state
.
userInfo
.
userId
,
creatorId
:
this
.
task
.
creator_id
,
creatorId
:
this
.
task
.
creator_id
,
relationId
:
this
.
relationId
,
textUrl
:
this
.
file
.
url
,
textUrl
:
this
.
file
.
url
,
type
:
"text"
,
type
:
"text"
,
fileId
:
this
.
file
.
id
fileId
:
this
.
file
.
id
...
...
DAPlatform-front/src/components/textAnnotation/SelectedCheck.vue
View file @
57ebb542
...
@@ -122,6 +122,7 @@ export default {
...
@@ -122,6 +122,7 @@ export default {
templateId
:
this
.
piece
.
template
,
// TODO 模板id
templateId
:
this
.
piece
.
template
,
// TODO 模板id
annotatorId
:
this
.
$store
.
state
.
userInfo
.
userId
,
annotatorId
:
this
.
$store
.
state
.
userInfo
.
userId
,
creatorId
:
this
.
task
.
creator_id
,
creatorId
:
this
.
task
.
creator_id
,
relationId
:
this
.
relationId
,
textUrl
:
this
.
file
.
url
,
textUrl
:
this
.
file
.
url
,
type
:
"text"
,
type
:
"text"
,
fileId
:
this
.
file
.
id
fileId
:
this
.
file
.
id
...
...
DAPlatform-front/src/components/textAnnotation/SelectedText.vue
View file @
57ebb542
...
@@ -107,6 +107,7 @@ export default {
...
@@ -107,6 +107,7 @@ export default {
templateId
:
this
.
piece
.
template
,
// TODO 模板id
templateId
:
this
.
piece
.
template
,
// TODO 模板id
annotatorId
:
this
.
$store
.
state
.
userInfo
.
userId
,
annotatorId
:
this
.
$store
.
state
.
userInfo
.
userId
,
creatorId
:
this
.
task
.
creator_id
,
creatorId
:
this
.
task
.
creator_id
,
relationId
:
this
.
relationId
,
textUrl
:
this
.
file
.
url
,
textUrl
:
this
.
file
.
url
,
type
:
"text"
,
type
:
"text"
,
fileId
:
this
.
file
.
id
fileId
:
this
.
file
.
id
...
...
DAPlatform-front/src/components/textAnnotation/Table.vue
View file @
57ebb542
...
@@ -178,6 +178,7 @@ export default {
...
@@ -178,6 +178,7 @@ export default {
templateId
:
this
.
piece
.
template
,
// TODO 模板id
templateId
:
this
.
piece
.
template
,
// TODO 模板id
annotatorId
:
this
.
$store
.
state
.
userInfo
.
userId
,
annotatorId
:
this
.
$store
.
state
.
userInfo
.
userId
,
creatorId
:
this
.
task
.
creator_id
,
creatorId
:
this
.
task
.
creator_id
,
relationId
:
this
.
relationId
,
textUrl
:
this
.
file
.
url
,
textUrl
:
this
.
file
.
url
,
type
:
"xlsx"
,
type
:
"xlsx"
,
fileId
:
this
.
file
.
id
fileId
:
this
.
file
.
id
...
...
DAPlatform-front/src/components/textAnnotation/Tabled.vue
View file @
57ebb542
...
@@ -166,6 +166,7 @@ export default {
...
@@ -166,6 +166,7 @@ export default {
templateId
:
this
.
piece
.
template
,
// TODO 模板id
templateId
:
this
.
piece
.
template
,
// TODO 模板id
annotatorId
:
this
.
$store
.
state
.
userInfo
.
userId
,
annotatorId
:
this
.
$store
.
state
.
userInfo
.
userId
,
creatorId
:
this
.
task
.
creator_id
,
creatorId
:
this
.
task
.
creator_id
,
relationId
:
this
.
relationId
,
textUrl
:
this
.
file
.
url
,
textUrl
:
this
.
file
.
url
,
type
:
"xlsx"
,
type
:
"xlsx"
,
fileId
:
this
.
file
.
id
fileId
:
this
.
file
.
id
...
...
DAPlatform-front/src/components/textAnnotation/TabledCheck.vue
View file @
57ebb542
...
@@ -178,6 +178,7 @@ export default {
...
@@ -178,6 +178,7 @@ export default {
templateId
:
this
.
piece
.
template
,
// TODO 模板id
templateId
:
this
.
piece
.
template
,
// TODO 模板id
annotatorId
:
this
.
$store
.
state
.
userInfo
.
userId
,
annotatorId
:
this
.
$store
.
state
.
userInfo
.
userId
,
creatorId
:
this
.
task
.
creator_id
,
creatorId
:
this
.
task
.
creator_id
,
relationId
:
this
.
relationId
,
textUrl
:
this
.
file
.
url
,
textUrl
:
this
.
file
.
url
,
type
:
"xlsx"
,
type
:
"xlsx"
,
fileId
:
this
.
file
.
id
fileId
:
this
.
file
.
id
...
...
DAPlatform/views/textAnnotation.py
View file @
57ebb542
...
@@ -181,17 +181,18 @@ def insertDocument():
...
@@ -181,17 +181,18 @@ def insertDocument():
templateId
=
get_Data
.
get
(
'templateId'
,
None
)
templateId
=
get_Data
.
get
(
'templateId'
,
None
)
creatorId
=
get_Data
.
get
(
'creatorId'
,
None
)
creatorId
=
get_Data
.
get
(
'creatorId'
,
None
)
annotatorId
=
get_Data
.
get
(
'annotatorId'
,
None
)
annotatorId
=
get_Data
.
get
(
'annotatorId'
,
None
)
relationId
=
get_Data
.
get
(
'relationId'
,
None
)
fileId
=
get_Data
.
get
(
'fileId'
,
None
)
fileId
=
get_Data
.
get
(
'fileId'
,
None
)
textUrl
=
get_Data
.
get
(
'textUrl'
,
None
)
textUrl
=
get_Data
.
get
(
'textUrl'
,
None
)
type
=
get_Data
.
get
(
'type'
,
None
)
type
=
get_Data
.
get
(
'type'
,
None
)
if
templateId
is
None
or
creatorId
is
None
or
annotatorId
is
None
or
fileId
is
None
or
textUrl
is
None
or
type
is
None
:
if
templateId
is
None
or
creatorId
is
None
or
annotatorId
is
None
or
relationId
is
None
or
fileId
is
None
or
textUrl
is
None
or
type
is
None
:
return_dict
[
'return_code'
]
=
'201'
return_dict
[
'return_code'
]
=
'201'
return_dict
[
'return_info'
]
=
'请求参数有误'
return_dict
[
'return_info'
]
=
'请求参数有误'
return
json
.
dumps
(
return_dict
,
ensure_ascii
=
False
)
return
json
.
dumps
(
return_dict
,
ensure_ascii
=
False
)
result
=
mongodbApi
.
findOne
(
collectionTest
,
{
"templateId"
:
templateId
,
"creatorId"
:
creatorId
,
"annotatorId"
:
annotatorId
,
"fileId"
:
fileId
,
result
=
mongodbApi
.
findOne
(
collectionTest
,
{
"templateId"
:
templateId
,
"creatorId"
:
creatorId
,
"annotatorId"
:
annotatorId
,
"textUrl"
:
textUrl
,
"type"
:
type
})
"
relationId"
:
relationId
,
"fileId"
:
fileId
,
"
textUrl"
:
textUrl
,
"type"
:
type
})
if
result
is
not
None
:
if
result
is
not
None
:
return_dict
[
'result'
]
=
result
.
get
(
"documentId"
,
None
)
return_dict
[
'result'
]
=
result
.
get
(
"documentId"
,
None
)
...
@@ -200,7 +201,7 @@ def insertDocument():
...
@@ -200,7 +201,7 @@ def insertDocument():
documentId
=
str
(
uuid
.
uuid1
())
.
replace
(
'-'
,
''
)
documentId
=
str
(
uuid
.
uuid1
())
.
replace
(
'-'
,
''
)
result
=
mongodbApi
.
insert
(
collectionTest
,
{
"documentId"
:
documentId
,
"templateId"
:
templateId
,
"creatorId"
:
creatorId
,
result
=
mongodbApi
.
insert
(
collectionTest
,
{
"documentId"
:
documentId
,
"templateId"
:
templateId
,
"creatorId"
:
creatorId
,
"annotatorId"
:
annotatorId
,
"fileId"
:
fileId
,
"textUrl"
:
textUrl
,
"state"
:
"0"
,
"annotatorId"
:
annotatorId
,
"
relationId"
:
relationId
,
"
fileId"
:
fileId
,
"textUrl"
:
textUrl
,
"state"
:
"0"
,
"type"
:
type
,
"tokenList"
:
[]})
"type"
:
type
,
"tokenList"
:
[]})
if
result
is
None
:
if
result
is
None
:
...
...
DAPlatform/views/uploadDownload.py
View file @
57ebb542
...
@@ -7,9 +7,11 @@ import PIL.Image
...
@@ -7,9 +7,11 @@ import PIL.Image
from
datetime
import
datetime
from
datetime
import
datetime
import
xlrd
import
xlrd
import
zipfile
from
flask
import
Blueprint
from
flask
import
Blueprint
from
xlrd
import
xldate_as_tuple
from
xlrd
import
xldate_as_tuple
from
werkzeug.utils
import
secure_filename
from
dao
import
mongodbApi
from
dao
import
mongodbApi
from
support
import
basedir
from
support
import
basedir
...
@@ -19,6 +21,7 @@ from views.textAnnotation import collectionTest
...
@@ -19,6 +21,7 @@ from views.textAnnotation import collectionTest
uploadDownload
=
Blueprint
(
"uploadDownload"
,
__name__
,
url_prefix
=
"/api/files"
)
uploadDownload
=
Blueprint
(
"uploadDownload"
,
__name__
,
url_prefix
=
"/api/files"
)
UPLOAD_FOLDER
=
'upload'
# 用于保存上传文件的文件夹名称
UPLOAD_FOLDER
=
'upload'
# 用于保存上传文件的文件夹名称
ZIP_FOLDER
=
'zip'
# 用于保存zip文件的文件夹名称
ALLOWED_EXTENSIONS
=
{
'txt'
,
'xls'
,
'xlsx'
,
'png'
,
'jpg'
,
'bmp'
,
'gif'
}
# 允许上传的文件格式
ALLOWED_EXTENSIONS
=
{
'txt'
,
'xls'
,
'xlsx'
,
'png'
,
'jpg'
,
'bmp'
,
'gif'
}
# 允许上传的文件格式
...
@@ -268,3 +271,55 @@ def downloadContent():
...
@@ -268,3 +271,55 @@ def downloadContent():
file_dir
=
os
.
path
.
join
(
basedir
,
UPLOAD_FOLDER
,
url
)
file_dir
=
os
.
path
.
join
(
basedir
,
UPLOAD_FOLDER
,
url
)
return
send_file
(
file_dir
,
as_attachment
=
True
,
attachment_filename
=
url
)
return
send_file
(
file_dir
,
as_attachment
=
True
,
attachment_filename
=
url
)
# 打包下载
@uploadDownload.route
(
'/downloadFile'
,
methods
=
[
'POST'
])
def
downloadFile
():
get_Data
=
request
.
get_data
()
get_Data
=
json
.
loads
(
get_Data
)
relationId
=
get_Data
.
get
(
'relationId'
)
result
=
mongodbApi
.
findOne
(
collectionTest
,
{
"relationId"
:
relationId
})
url
=
result
.
get
(
'textUrl'
)
file_dir
=
os
.
path
.
join
(
basedir
,
UPLOAD_FOLDER
,
url
)
return
send_file
(
file_dir
,
as_attachment
=
True
,
attachment_filename
=
url
)
# 下载压缩包接口
@uploadDownload.route
(
'/downloadZip'
,
methods
=
[
'POST'
])
def
downloadZip
():
get_Data
=
request
.
get_data
()
get_Data
=
json
.
loads
(
get_Data
)
relationId
=
get_Data
.
get
(
'relationId'
)
result
=
mongodbApi
.
findOne
(
collectionTest
,
{
"relationId"
:
relationId
})
url
=
result
.
get
(
'textUrl'
)
file_dir
=
os
.
path
.
join
(
basedir
,
UPLOAD_FOLDER
)
# 被压缩的文件所在文件夹路径 如 D:\learn\python-project\demo\upload
zip_dir
=
os
.
path
.
join
(
basedir
,
ZIP_FOLDER
)
# 压缩后的文件所在文件夹路径 如 D:\learn\python-project\demo\zip
portion
=
os
.
path
.
splitext
(
url
)
# 获取文件前缀名 如1590310217.txt portion[0]则为1590310217
new_name
=
portion
[
0
]
+
'.zip'
# 新的文件名字 如1590310217.zip
zipname
=
os
.
path
.
join
(
zip_dir
,
new_name
)
# 压缩的文件夹名字及路径 如 D:\learn\python-project\demo\zip\1590310217.zip (这是我电脑上的路径)
f
=
zipfile
.
ZipFile
(
zipname
,
'w'
,
zipfile
.
ZIP_DEFLATED
)
#创建压缩文件 'w':写模式 ZIP_DEFLATED:设置压缩格式
basename
=
url
#压缩后文件的根目录叫啥
fpath
=
os
.
path
.
join
(
file_dir
,
url
)
# fpath就是被压缩的文件的路径的集合 file_dir代表被压缩的文件的路径 name是被压缩的文件的名字
arcname
=
os
.
path
.
join
(
basename
,
url
)
# 这个不用管 是为了让压缩后的文件的根目录只有一层 不然会套娃n个文件夹(一层路径一个文件夹)
f
.
write
(
fpath
,
arcname
=
arcname
)
#写进去 压缩!
json_name
=
portion
[
0
]
+
'result.json'
# 新的文件名字 如1590310217result.txt
full_path
=
os
.
path
.
join
(
file_dir
,
json_name
)
# 标注结果文件保存位置 + 标注结果文件名
file
=
open
(
full_path
,
'w'
,
encoding
=
'utf8'
)
#打开文件
file
.
write
(
str
(
result
.
get
(
'tokenList'
)))
#写入标注结果字符串
file
.
close
()
#关闭文件
fpath
=
os
.
path
.
join
(
file_dir
,
json_name
)
# fpath就是被压缩的文件的路径的集合 file_dir代表被压缩的文件的路径 name是被压缩的文件的名字
arcname
=
os
.
path
.
join
(
basename
,
json_name
)
# 这个不用管 是为了让压缩后的文件的根目录只有一层 不然会套娃n个文件夹(一层路径一个文件夹)
f
.
write
(
fpath
,
arcname
=
arcname
)
# 写进去 压缩!
f
.
close
()
#关闭
return
send_file
(
zipname
,
as_attachment
=
True
,
attachment_filename
=
new_name
)
文档/文本标注接口列表.docx
View file @
57ebb542
No preview for this file type
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