add be by TheSliceOfLife
This commit is contained in:
parent
8e41a2d3e1
commit
212b273c23
|
@ -0,0 +1,2 @@
|
|||
.idea
|
||||
__pycache__
|
|
@ -0,0 +1,12 @@
|
|||
[[source]]
|
||||
url = "https://pypi.org/simple"
|
||||
verify_ssl = true
|
||||
name = "pypi"
|
||||
|
||||
[packages]
|
||||
flask = "*"
|
||||
|
||||
[dev-packages]
|
||||
|
||||
[requires]
|
||||
python_version = "3.8"
|
|
@ -0,0 +1,119 @@
|
|||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "8684575dc2e2ee3ef130963dade592c67e470b510ee5ccd3a60920b144ac8e32"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {
|
||||
"python_version": "3.8"
|
||||
},
|
||||
"sources": [
|
||||
{
|
||||
"name": "pypi",
|
||||
"url": "https://pypi.org/simple",
|
||||
"verify_ssl": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"default": {
|
||||
"click": {
|
||||
"hashes": [
|
||||
"sha256:d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a",
|
||||
"sha256:dacca89f4bfadd5de3d7489b7c8a566eee0d3676333fbb50030263894c38c0dc"
|
||||
],
|
||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'",
|
||||
"version": "==7.1.2"
|
||||
},
|
||||
"flask": {
|
||||
"hashes": [
|
||||
"sha256:4efa1ae2d7c9865af48986de8aeb8504bf32c7f3d6fdc9353d34b21f4b127060",
|
||||
"sha256:8a4fdd8936eba2512e9c85df320a37e694c93945b33ef33c89946a340a238557"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==1.1.2"
|
||||
},
|
||||
"itsdangerous": {
|
||||
"hashes": [
|
||||
"sha256:321b033d07f2a4136d3ec762eac9f16a10ccd60f53c0c91af90217ace7ba1f19",
|
||||
"sha256:b12271b2047cb23eeb98c8b5622e2e5c5e9abd9784a153e9d8ef9cb4dd09d749"
|
||||
],
|
||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
|
||||
"version": "==1.1.0"
|
||||
},
|
||||
"jinja2": {
|
||||
"hashes": [
|
||||
"sha256:03e47ad063331dd6a3f04a43eddca8a966a26ba0c5b7207a9a9e4e08f1b29419",
|
||||
"sha256:a6d58433de0ae800347cab1fa3043cebbabe8baa9d29e668f1c768cb87a333c6"
|
||||
],
|
||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'",
|
||||
"version": "==2.11.3"
|
||||
},
|
||||
"markupsafe": {
|
||||
"hashes": [
|
||||
"sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473",
|
||||
"sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161",
|
||||
"sha256:09c4b7f37d6c648cb13f9230d847adf22f8171b1ccc4d5682398e77f40309235",
|
||||
"sha256:1027c282dad077d0bae18be6794e6b6b8c91d58ed8a8d89a89d59693b9131db5",
|
||||
"sha256:13d3144e1e340870b25e7b10b98d779608c02016d5184cfb9927a9f10c689f42",
|
||||
"sha256:195d7d2c4fbb0ee8139a6cf67194f3973a6b3042d742ebe0a9ed36d8b6f0c07f",
|
||||
"sha256:22c178a091fc6630d0d045bdb5992d2dfe14e3259760e713c490da5323866c39",
|
||||
"sha256:24982cc2533820871eba85ba648cd53d8623687ff11cbb805be4ff7b4c971aff",
|
||||
"sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b",
|
||||
"sha256:2beec1e0de6924ea551859edb9e7679da6e4870d32cb766240ce17e0a0ba2014",
|
||||
"sha256:3b8a6499709d29c2e2399569d96719a1b21dcd94410a586a18526b143ec8470f",
|
||||
"sha256:43a55c2930bbc139570ac2452adf3d70cdbb3cfe5912c71cdce1c2c6bbd9c5d1",
|
||||
"sha256:46c99d2de99945ec5cb54f23c8cd5689f6d7177305ebff350a58ce5f8de1669e",
|
||||
"sha256:500d4957e52ddc3351cabf489e79c91c17f6e0899158447047588650b5e69183",
|
||||
"sha256:535f6fc4d397c1563d08b88e485c3496cf5784e927af890fb3c3aac7f933ec66",
|
||||
"sha256:596510de112c685489095da617b5bcbbac7dd6384aeebeda4df6025d0256a81b",
|
||||
"sha256:62fe6c95e3ec8a7fad637b7f3d372c15ec1caa01ab47926cfdf7a75b40e0eac1",
|
||||
"sha256:6788b695d50a51edb699cb55e35487e430fa21f1ed838122d722e0ff0ac5ba15",
|
||||
"sha256:6dd73240d2af64df90aa7c4e7481e23825ea70af4b4922f8ede5b9e35f78a3b1",
|
||||
"sha256:6f1e273a344928347c1290119b493a1f0303c52f5a5eae5f16d74f48c15d4a85",
|
||||
"sha256:6fffc775d90dcc9aed1b89219549b329a9250d918fd0b8fa8d93d154918422e1",
|
||||
"sha256:717ba8fe3ae9cc0006d7c451f0bb265ee07739daf76355d06366154ee68d221e",
|
||||
"sha256:79855e1c5b8da654cf486b830bd42c06e8780cea587384cf6545b7d9ac013a0b",
|
||||
"sha256:7c1699dfe0cf8ff607dbdcc1e9b9af1755371f92a68f706051cc8c37d447c905",
|
||||
"sha256:7fed13866cf14bba33e7176717346713881f56d9d2bcebab207f7a036f41b850",
|
||||
"sha256:84dee80c15f1b560d55bcfe6d47b27d070b4681c699c572af2e3c7cc90a3b8e0",
|
||||
"sha256:88e5fcfb52ee7b911e8bb6d6aa2fd21fbecc674eadd44118a9cc3863f938e735",
|
||||
"sha256:8defac2f2ccd6805ebf65f5eeb132adcf2ab57aa11fdf4c0dd5169a004710e7d",
|
||||
"sha256:98bae9582248d6cf62321dcb52aaf5d9adf0bad3b40582925ef7c7f0ed85fceb",
|
||||
"sha256:98c7086708b163d425c67c7a91bad6e466bb99d797aa64f965e9d25c12111a5e",
|
||||
"sha256:9add70b36c5666a2ed02b43b335fe19002ee5235efd4b8a89bfcf9005bebac0d",
|
||||
"sha256:9bf40443012702a1d2070043cb6291650a0841ece432556f784f004937f0f32c",
|
||||
"sha256:a6a744282b7718a2a62d2ed9d993cad6f5f585605ad352c11de459f4108df0a1",
|
||||
"sha256:acf08ac40292838b3cbbb06cfe9b2cb9ec78fce8baca31ddb87aaac2e2dc3bc2",
|
||||
"sha256:ade5e387d2ad0d7ebf59146cc00c8044acbd863725f887353a10df825fc8ae21",
|
||||
"sha256:b00c1de48212e4cc9603895652c5c410df699856a2853135b3967591e4beebc2",
|
||||
"sha256:b1282f8c00509d99fef04d8ba936b156d419be841854fe901d8ae224c59f0be5",
|
||||
"sha256:b1dba4527182c95a0db8b6060cc98ac49b9e2f5e64320e2b56e47cb2831978c7",
|
||||
"sha256:b2051432115498d3562c084a49bba65d97cf251f5a331c64a12ee7e04dacc51b",
|
||||
"sha256:b7d644ddb4dbd407d31ffb699f1d140bc35478da613b441c582aeb7c43838dd8",
|
||||
"sha256:ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6",
|
||||
"sha256:bf5aa3cbcfdf57fa2ee9cd1822c862ef23037f5c832ad09cfea57fa846dec193",
|
||||
"sha256:c8716a48d94b06bb3b2524c2b77e055fb313aeb4ea620c8dd03a105574ba704f",
|
||||
"sha256:caabedc8323f1e93231b52fc32bdcde6db817623d33e100708d9a68e1f53b26b",
|
||||
"sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f",
|
||||
"sha256:cdb132fc825c38e1aeec2c8aa9338310d29d337bebbd7baa06889d09a60a1fa2",
|
||||
"sha256:d53bc011414228441014aa71dbec320c66468c1030aae3a6e29778a3382d96e5",
|
||||
"sha256:d73a845f227b0bfe8a7455ee623525ee656a9e2e749e4742706d80a6065d5e2c",
|
||||
"sha256:d9be0ba6c527163cbed5e0857c451fcd092ce83947944d6c14bc95441203f032",
|
||||
"sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7",
|
||||
"sha256:e8313f01ba26fbbe36c7be1966a7b7424942f670f38e666995b88d012765b9be",
|
||||
"sha256:feb7b34d6325451ef96bc0e36e1a6c0c1c64bc1fbec4b854f4529e51887b1621"
|
||||
],
|
||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
|
||||
"version": "==1.1.1"
|
||||
},
|
||||
"werkzeug": {
|
||||
"hashes": [
|
||||
"sha256:2de2a5db0baeae7b2d2664949077c2ac63fbd16d98da0ff71837f7d1dea3fd43",
|
||||
"sha256:6c80b1e5ad3665290ea39320b91e1be1e0d5f60652b964a3070216de83d2e47c"
|
||||
],
|
||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'",
|
||||
"version": "==1.0.1"
|
||||
}
|
||||
},
|
||||
"develop": {}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
from flask import Blueprint
|
||||
from app.api.v1 import index, project, files, anno
|
||||
|
||||
|
||||
def create_blueprint_v1():
|
||||
bp_v1 = Blueprint('v1', __name__)
|
||||
|
||||
index.api.register(bp_v1, url_prefix='/index')
|
||||
project.api.register(bp_v1, url_prefix='/project')
|
||||
anno.api.register(bp_v1, url_prefix='/anno')
|
||||
files.api.register(bp_v1, url_prefix='/files')
|
||||
|
||||
return bp_v1
|
|
@ -0,0 +1,73 @@
|
|||
from app.config.setting import PROJECT_NAME, FILE_NAME, PROJECTS, ANNO_OUTPUT_PATH
|
||||
from app.entities.entities import ReturnInfo, AnnoContents, OutputAnno, QueryAnno
|
||||
from app.libs.redprint import RedPrint
|
||||
|
||||
from flask import request
|
||||
import json
|
||||
import os
|
||||
|
||||
from app.libs.tools import read_txt_file, write_json, read_json_file, make_dir
|
||||
|
||||
api = RedPrint('anno')
|
||||
|
||||
|
||||
@api.route('/create', methods=['POST'])
|
||||
def create_anno():
|
||||
ret_info = ReturnInfo()
|
||||
try:
|
||||
param = request.get_json()
|
||||
project_name = param.get(PROJECT_NAME)
|
||||
file_name = param.get(FILE_NAME)
|
||||
anno_details = param.get('annoDetails')
|
||||
|
||||
anno_cont = AnnoContents()
|
||||
anno_cont.fileName = file_name
|
||||
anno_cont.annoDetails = anno_details
|
||||
anno_cont.isAnno = True
|
||||
|
||||
anno_output_path = ANNO_OUTPUT_PATH.format(project_name)
|
||||
|
||||
# 判断路径是否存在
|
||||
if not os.path.exists(anno_output_path):
|
||||
write_json(anno_output_path, [anno_cont])
|
||||
ret_info.errCode = 0
|
||||
else:
|
||||
output_anno = OutputAnno()
|
||||
output_anno.all_anno = read_json_file(anno_output_path)
|
||||
output_anno.add_anno(anno_cont)
|
||||
|
||||
write_json(anno_output_path, output_anno.all_anno)
|
||||
ret_info.errCode = 0
|
||||
|
||||
except Exception as e:
|
||||
ret_info.errCode = 404
|
||||
ret_info.errMsg = str(e)
|
||||
|
||||
return json.dumps(ret_info, default=lambda o: o.__dict__)
|
||||
|
||||
|
||||
@api.route('/query', methods=['GET'])
|
||||
def query_anno():
|
||||
ret_info = ReturnInfo()
|
||||
try:
|
||||
project_name = request.args.get("projectName").strip()
|
||||
file_name = request.args.get("fileName").strip()
|
||||
|
||||
file_path = PROJECTS + '/' + project_name + '/' + file_name
|
||||
file_content = read_txt_file(file_path)
|
||||
|
||||
anno_output_path = ANNO_OUTPUT_PATH.format(project_name)
|
||||
output_anno = OutputAnno()
|
||||
output_anno.all_anno = read_json_file(anno_output_path)
|
||||
|
||||
query_anno = QueryAnno()
|
||||
query_anno.fileContent = file_content
|
||||
query_anno.annoDetails = output_anno.get_anno(file_name)
|
||||
ret_info.info = query_anno
|
||||
|
||||
ret_info.errCode = 0
|
||||
|
||||
except Exception as e:
|
||||
ret_info.errCode = 404
|
||||
ret_info.errMsg = str(e)
|
||||
return json.dumps(ret_info, default=lambda o: o.__dict__)
|
|
@ -0,0 +1,58 @@
|
|||
from app.config.setting import PROJECT_PATH, ANNO_OUTPUT_PATH
|
||||
from app.libs.redprint import RedPrint
|
||||
|
||||
from flask import request
|
||||
import json
|
||||
import os
|
||||
|
||||
from app.entities.entities import ReturnInfo, FileInfo
|
||||
from app.libs.tools import read_json_file
|
||||
|
||||
api = RedPrint('files')
|
||||
|
||||
|
||||
@api.route('/query', methods=['GET'])
|
||||
def query_file():
|
||||
ret_info = ReturnInfo()
|
||||
try:
|
||||
project_name = request.args.get("projectName").strip()
|
||||
page_number = int(request.args.get("pageNumber"))
|
||||
page_size = int(request.args.get("pageSize"))
|
||||
|
||||
file_names = os.listdir(PROJECT_PATH.format(project_name))
|
||||
if 'config.json' in file_names:
|
||||
file_names.remove('config.json')
|
||||
if 'anno.json' in file_names:
|
||||
file_names.remove('anno.json')
|
||||
|
||||
|
||||
|
||||
anno_output_path = ANNO_OUTPUT_PATH.format(project_name)
|
||||
|
||||
# 判断路径是否存在
|
||||
if not os.path.exists(anno_output_path):
|
||||
for file_name in file_names[(page_number - 1) * page_size: (page_number - 1) * page_size + page_size]:
|
||||
file_info = FileInfo()
|
||||
file_info.fileName = file_name
|
||||
file_info.isAnno = False
|
||||
ret_info.info.append(file_info)
|
||||
print(2)
|
||||
else:
|
||||
for file_name in sorted(file_names)[(page_number - 1) * page_size: (page_number - 1) * page_size + page_size]:
|
||||
file_info = FileInfo()
|
||||
file_info.fileName = file_name
|
||||
|
||||
for anno_info in read_json_file(anno_output_path):
|
||||
if anno_info.get('fileName') == file_name:
|
||||
file_info.isAnno = anno_info.get('isAnno')
|
||||
|
||||
ret_info.info.append(file_info.__dict__)
|
||||
|
||||
ret_info.errCode = 0
|
||||
|
||||
ret_info.total = len(file_names)
|
||||
|
||||
except Exception as e:
|
||||
ret_info.errCode = 404
|
||||
ret_info.errMsg = str(e)
|
||||
return json.dumps(ret_info, default=lambda o: o.__dict__)
|
|
@ -0,0 +1,32 @@
|
|||
from app.config.setting import PROJECTS, PROJECT_CONFIG_PATH
|
||||
from app.entities.entities import ReturnInfo
|
||||
from app.libs.redprint import RedPrint
|
||||
import json
|
||||
import os
|
||||
|
||||
from app.libs.tools import read_json_file
|
||||
|
||||
api = RedPrint('index')
|
||||
|
||||
|
||||
# 访问首页 http://localhost:9060/v1/index
|
||||
# @api.route('/index')
|
||||
@api.route('', methods=['GET'])
|
||||
def index():
|
||||
# 打开项首页时,返回我的项目信息
|
||||
ret_info = ReturnInfo()
|
||||
try:
|
||||
project_config_info = []
|
||||
for project_name in os.listdir(PROJECTS):
|
||||
project_config_name = PROJECT_CONFIG_PATH.format(project_name)
|
||||
print(project_config_name)
|
||||
if os.path.exists(project_config_name):
|
||||
project_config_info.append(read_json_file(project_config_name))
|
||||
|
||||
ret_info.errCode = 0
|
||||
ret_info.info = project_config_info
|
||||
except Exception as e:
|
||||
ret_info.errCode = 404
|
||||
ret_info.errMsg = str(e)
|
||||
|
||||
return json.dumps(ret_info, default=lambda o: o.__dict__)
|
|
@ -0,0 +1,73 @@
|
|||
from app.config.setting import PROJECT_NAME, PROJECT_TYPE, ENTITY_TYPES, PROJECTS, PROJECT_PATH, PROJECT_CONFIG_PATH, \
|
||||
ANNO_OUTPUT_PATH
|
||||
from app.libs.redprint import RedPrint
|
||||
|
||||
from flask import request
|
||||
import json
|
||||
import os
|
||||
from app.libs.tools import make_dir, write_json, read_json_file
|
||||
from app.entities.entities import Project, ReturnInfo
|
||||
|
||||
api = RedPrint('project')
|
||||
|
||||
|
||||
@api.route('/create', methods=['POST'])
|
||||
def create_project():
|
||||
ret_info = ReturnInfo()
|
||||
try:
|
||||
param = request.get_json()
|
||||
project_name = param.get(PROJECT_NAME)
|
||||
|
||||
make_dir(PROJECT_PATH.format(project_name))
|
||||
write_json(PROJECT_CONFIG_PATH.format(project_name), param)
|
||||
|
||||
ret_info.errCode = 0
|
||||
|
||||
except Exception as e:
|
||||
ret_info.errCode = 404
|
||||
ret_info.errMsg = str(e)
|
||||
return json.dumps(ret_info, ensure_ascii=False, default=lambda o: o.__dict__)
|
||||
|
||||
|
||||
@api.route('/update_entity_types', methods=['POST'])
|
||||
def update_entity_types():
|
||||
ret_info = ReturnInfo()
|
||||
try:
|
||||
param = request.get_json()
|
||||
project_name = param.get(PROJECT_NAME)
|
||||
entity_types = param.get(ENTITY_TYPES)
|
||||
print(entity_types)
|
||||
|
||||
new_entity_types = []
|
||||
for entity_type in entity_types:
|
||||
new_entity_types.append(entity_type.get('type'))
|
||||
|
||||
anno_output_path = ANNO_OUTPUT_PATH.format(project_name)
|
||||
|
||||
if os.path.exists(PROJECT_CONFIG_PATH.format(project_name)): # False
|
||||
project_config_info = read_json_file(PROJECT_CONFIG_PATH.format(project_name))
|
||||
project = Project()
|
||||
project.projectName = project_config_info.get(PROJECT_NAME)
|
||||
project.projectType = project_config_info.get(PROJECT_TYPE)
|
||||
project.entityTypes = entity_types
|
||||
print(project.entityTypes)
|
||||
|
||||
if os.path.exists(anno_output_path):
|
||||
anno_details = read_json_file(anno_output_path)
|
||||
for anno_info in anno_details:
|
||||
anno_detail = json.loads(anno_info.get('annoDetails'))
|
||||
for ind, anno in enumerate(anno_detail):
|
||||
entity_type = anno.get('type')
|
||||
if entity_type not in new_entity_types:
|
||||
anno_detail.pop(ind)
|
||||
write_json(anno_output_path, anno_details)
|
||||
|
||||
write_json(PROJECT_CONFIG_PATH.format(project_name), project)
|
||||
ret_info.errMsg = 'update ok'
|
||||
|
||||
ret_info.errCode = 0
|
||||
except Exception as e:
|
||||
ret_info.errCode = 404
|
||||
ret_info.errMsg = str(e)
|
||||
|
||||
return json.dumps(ret_info, default=lambda o: o.__dict__)
|
|
@ -0,0 +1,16 @@
|
|||
from flask import Flask
|
||||
|
||||
|
||||
def create_app():
|
||||
app = Flask(__name__)
|
||||
|
||||
app.config.from_object('app.config.setting')
|
||||
app.config.from_object('app.config.secure')
|
||||
|
||||
register_blueprints(app)
|
||||
return app
|
||||
|
||||
|
||||
def register_blueprints(app):
|
||||
from app.api.v1 import create_blueprint_v1
|
||||
app.register_blueprint(create_blueprint_v1(), url_prefix='/v1')
|
|
@ -0,0 +1,4 @@
|
|||
# 配置文件 - secure 用于存放机密配置,如 数据库 信息等 (开源时,这部分信息需要删除)
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# 配置文件 - setting 用于存放一般的配置
|
||||
|
||||
# 项目名称
|
||||
PROJECT_NAME = 'projectName'
|
||||
# 项目类型
|
||||
PROJECT_TYPE = 'projectType'
|
||||
# 实体类型
|
||||
ENTITY_TYPES = 'entityTypes'
|
||||
# 文件名
|
||||
FILE_NAME = 'fileName'
|
||||
|
||||
# 项目存储路径
|
||||
PROJECTS = 'app/projects'
|
||||
|
||||
# 项目路径
|
||||
PROJECT_PATH = PROJECTS + '/' + "{}"
|
||||
PROJECT_CONFIG_PATH = PROJECTS + '/' + "{}" + '/config.json'
|
||||
|
||||
# 标注信息存储路径
|
||||
ANNO_OUTPUT_PATH = PROJECTS + '/' + '{}' + '/' + 'anno.json'
|
|
@ -0,0 +1,68 @@
|
|||
class Project:
|
||||
def __init__(self):
|
||||
self.projectName = ''
|
||||
self.projectType = ''
|
||||
self.entityTypes = ''
|
||||
|
||||
|
||||
class ReturnInfo:
|
||||
def __init__(self):
|
||||
self.errCode = 0
|
||||
self.errMsg = ''
|
||||
self.info = []
|
||||
|
||||
|
||||
class QueryAnno:
|
||||
def __init__(self):
|
||||
self.annoDetails = []
|
||||
self.fileContent = ''
|
||||
# self.isAnno = False
|
||||
|
||||
|
||||
class AnnoContents:
|
||||
def __init__(self):
|
||||
self.fileName = ''
|
||||
self.annoDetails = None
|
||||
self.isAnno = False
|
||||
|
||||
|
||||
class FileInfo:
|
||||
def __init__(self):
|
||||
self.fileName = ''
|
||||
self.isAnno = False
|
||||
|
||||
|
||||
class OutputAnno:
|
||||
def __init__(self):
|
||||
self.all_anno = []
|
||||
|
||||
def add_anno(self, anno_cont: AnnoContents):
|
||||
|
||||
isTrue = self.is_anno(anno_cont.fileName)
|
||||
if not isTrue:
|
||||
self.all_anno.append(anno_cont)
|
||||
else:
|
||||
for ind, anno_info in enumerate(self.all_anno):
|
||||
if isinstance(anno_info, dict) and anno_info.get("fileName") == anno_cont.fileName:
|
||||
self.all_anno.pop(ind)
|
||||
self.all_anno.append(anno_cont)
|
||||
|
||||
def is_anno(self, file_name):
|
||||
anno_file_names = list(k.get('fileName') for k in self.all_anno if isinstance(k, dict))
|
||||
if file_name in anno_file_names:
|
||||
return True
|
||||
return False
|
||||
|
||||
def get_anno(self, file_name):
|
||||
isTrue = self.is_anno(file_name)
|
||||
if isTrue:
|
||||
for ind, anno_info in enumerate(self.all_anno):
|
||||
if isinstance(anno_info, dict) and anno_info.get("fileName") == file_name:
|
||||
return anno_info.get("annoDetails")
|
||||
return None
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
class RedPrint:
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
self.mound = []
|
||||
|
||||
def route(self, rule, **options):
|
||||
def decorator(f):
|
||||
self.mound.append((rule, f, options))
|
||||
return f
|
||||
|
||||
return decorator
|
||||
|
||||
def register(self, bp, url_prefix=None):
|
||||
for rule, f, options in self.mound:
|
||||
endpoint = options.pop("endpoint", f.__name__)
|
||||
bp.add_url_rule(url_prefix + rule, endpoint, f, **options)
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
import os
|
||||
import json
|
||||
|
||||
|
||||
def make_dir(path):
|
||||
folder = os.path.exists(path)
|
||||
|
||||
if not folder:
|
||||
os.mkdir(path)
|
||||
|
||||
|
||||
# 将json数据写入.json文件
|
||||
def write_json(json_file_path, data):
|
||||
with open(json_file_path, 'w', encoding='utf-8') as f:
|
||||
json.dump(data, f, ensure_ascii=False, default=lambda o: o.__dict__)
|
||||
|
||||
|
||||
# 加载json文件中的json数据
|
||||
def read_json_file(json_file_name):
|
||||
with open(json_file_name, 'r', encoding='utf-8') as f:
|
||||
data = json.load(f)
|
||||
return data
|
||||
|
||||
|
||||
# 读取txt文件
|
||||
def read_txt_file(file_path):
|
||||
with open(file_path, 'r', encoding='utf-8') as f:
|
||||
data = f.read()
|
||||
return data
|
|
@ -0,0 +1 @@
|
|||
[{"fileName": "文本1 - 副本 - 副本 (3).txt", "annoDetails": "[]"}, {"fileName": "文本1 - 副本 - 副本 (4) - 副本.txt", "annoDetails": "[]"}, {"fileName": null, "annoDetails": "[]"}, {"fileName": "", "annoDetails": "[]"}]
|
|
@ -0,0 +1 @@
|
|||
{"projectName": "123", "projectType": "命名实体识别", "entityTypes": "[{\"type\":\"123\",\"color\":\"#c15892\"}]"}
|
|
@ -0,0 +1 @@
|
|||
[{"fileName": "", "annoDetails": "[]"}]
|
|
@ -0,0 +1 @@
|
|||
{"projectName": "222", "projectType": "命名实体识别", "entityTypes": "[{\"type\":\"23\",\"color\":\"#2ea5f5\"},{\"type\":\"12\",\"color\":\"#f8e817\"}]"}
|
|
@ -0,0 +1 @@
|
|||
{"projectName": "demo1", "projectType": "nlp 标注", "entityTypes": "[{\"type\":\"person1\",\"color\":\"#e61490\"},{\"type\":\"location\",\"color\":\"#0aab8a\"},{\"type\":\"organiztion\",\"color\":\"#2770cd\"},{\"type\":\"123\",\"color\":\"#1c7a82\"}]"}
|
|
@ -0,0 +1 @@
|
|||
{"projectName": "demo4", "projectType": "nlp 标注", "entityTypes": [{"type": "person1", "color": "#e61490"}, {"type": "location", "color": "#0aab8a"}, {"type": "organiztion", "color": "#2770cd"}, {"type": "123", "color": "#1c7a82"}]}
|
|
@ -0,0 +1 @@
|
|||
[{"fileName": "", "annoDetails": "[]", "isAnno": true}, {"fileName": "test2.txt", "annoDetails": "[]", "isAnno": true}, {"fileName": "test4.txt", "annoDetails": "[]", "isAnno": true}, {"fileName": "test1.txt", "annoDetails": "[]", "isAnno": true}, {"fileName": "test10.txt", "annoDetails": "[{\"name\":\"小明\",\"type\":\"person1\",\"start\":0,\"end\":2}]", "isAnno": true}]
|
|
@ -0,0 +1 @@
|
|||
{"projectName": "demo5", "projectType": "NLP标注", "entityTypes": "[{\"type\":\"person1\",\"color\":\"#e61490\"},{\"type\":\"location\",\"color\":\"#0aab8a\"},{\"type\":\"organiztion\",\"color\":\"#2770cd\"},{\"type\":\"123\",\"color\":\"#1c7a82\"}]"}
|
|
@ -0,0 +1 @@
|
|||
hello 你好啊 兄弟们 雄起
|
|
@ -0,0 +1 @@
|
|||
小明毕业于北京工业大学
|
|
@ -0,0 +1 @@
|
|||
小明毕业于北京工业大学
|
|
@ -0,0 +1 @@
|
|||
小明毕业于北京工业大学
|
|
@ -0,0 +1 @@
|
|||
小明毕业于北京工业大学
|
|
@ -0,0 +1 @@
|
|||
小明毕业于北京工业大学
|
|
@ -0,0 +1 @@
|
|||
小明毕业于北京工业大学
|
|
@ -0,0 +1 @@
|
|||
小明毕业于北京工业大学
|
|
@ -0,0 +1 @@
|
|||
小明毕业于北京工业大学
|
|
@ -0,0 +1 @@
|
|||
小明毕业于北京工业大学
|
|
@ -0,0 +1 @@
|
|||
小明毕业于北京工业大学
|
|
@ -0,0 +1 @@
|
|||
小明毕业于北京工业大学
|
|
@ -0,0 +1 @@
|
|||
{"projectName": "xixixi", "projectType": "命名实体识别", "entityTypes": "[]"}
|
|
@ -0,0 +1 @@
|
|||
[{"fileName": null, "annoDetails": "[]"}, {"fileName": "", "annoDetails": "[]"}]
|
|
@ -0,0 +1 @@
|
|||
{"projectName": "医疗", "projectType": "命名实体识别", "entityTypes": "[{\"type\":\"pos\",\"color\":\"#e67704\"}]"}
|
|
@ -0,0 +1 @@
|
|||
{"projectName": "项目", "projectType": "nlp 标注", "entityTypes": ""}
|
|
@ -0,0 +1,17 @@
|
|||
# 入口程序文件
|
||||
from app.app import create_app
|
||||
|
||||
app = create_app()
|
||||
|
||||
# host='0.0.0.0'
|
||||
# 本机访问: 将浏览器中0.0.0.0替换成127.0.0.1 或 localhost
|
||||
# 内网访问: 将浏览器中0.0.0.0替换成运行程序的ip地址
|
||||
# port='9060' 可自己指定端口
|
||||
|
||||
# 例: 访问首页 http://localhost:9060/v1/index
|
||||
# localhost是ip
|
||||
# 9060是端口
|
||||
# v1是版本
|
||||
# index是首页
|
||||
if __name__ == '__main__':
|
||||
app.run(host='0.0.0.0', port=9060, debug=True)
|
|
@ -1,6 +1,5 @@
|
|||
.DS_Store
|
||||
node_modules/
|
||||
/dist/
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
|
|
@ -12,7 +12,7 @@ module.exports = {
|
|||
assetsPublicPath: '/',
|
||||
proxyTable: {
|
||||
'/v1/': {
|
||||
target: 'http://39.102.94.103:9060/',
|
||||
target: 'http://localhost:9060/',
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -54,7 +54,7 @@ module.exports = {
|
|||
// Paths
|
||||
assetsRoot: path.resolve(__dirname, '../dist'),
|
||||
assetsSubDirectory: 'static',
|
||||
assetsPublicPath: '/dw-tool-ner/v1.2.7/',
|
||||
assetsPublicPath: '/',
|
||||
|
||||
/**
|
||||
* Source Maps
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
<!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>dw-tool-ner</title><link href=/static/css/app.4872490f1327ad4a9444be2c5054e3bd.css rel=stylesheet></head><body><div id=app></div><style>html, body {
|
||||
display: inline-block;
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}</style><script type=text/javascript src=/static/js/manifest.2ae2e69a05c33dfc65f8.js></script><script type=text/javascript src=/static/js/vendor.b6a0dabd8e467dbb8b61.js></script><script type=text/javascript src=/static/js/app.1233f1538d45804c389b.js></script></body></html>
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,2 @@
|
|||
!function(r){var n=window.webpackJsonp;window.webpackJsonp=function(e,u,c){for(var f,i,p,a=0,l=[];a<e.length;a++)i=e[a],o[i]&&l.push(o[i][0]),o[i]=0;for(f in u)Object.prototype.hasOwnProperty.call(u,f)&&(r[f]=u[f]);for(n&&n(e,u,c);l.length;)l.shift()();if(c)for(a=0;a<c.length;a++)p=t(t.s=c[a]);return p};var e={},o={2:0};function t(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return r[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}t.m=r,t.c=e,t.d=function(r,n,e){t.o(r,n)||Object.defineProperty(r,n,{configurable:!1,enumerable:!0,get:e})},t.n=function(r){var n=r&&r.__esModule?function(){return r.default}:function(){return r};return t.d(n,"a",n),n},t.o=function(r,n){return Object.prototype.hasOwnProperty.call(r,n)},t.p="/",t.oe=function(r){throw console.error(r),r}}([]);
|
||||
//# sourceMappingURL=manifest.2ae2e69a05c33dfc65f8.js.map
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"sources":["webpack:///webpack/bootstrap f3383f2c542efd14ff14"],"names":["parentJsonpFunction","window","chunkIds","moreModules","executeModules","moduleId","chunkId","result","i","resolves","length","installedChunks","push","Object","prototype","hasOwnProperty","call","modules","shift","__webpack_require__","s","installedModules","2","exports","module","l","m","c","d","name","getter","o","defineProperty","configurable","enumerable","get","n","__esModule","object","property","p","oe","err","console","error"],"mappings":"aACA,IAAAA,EAAAC,OAAA,aACAA,OAAA,sBAAAC,EAAAC,EAAAC,GAIA,IADA,IAAAC,EAAAC,EAAAC,EAAAC,EAAA,EAAAC,KACQD,EAAAN,EAAAQ,OAAoBF,IAC5BF,EAAAJ,EAAAM,GACAG,EAAAL,IACAG,EAAAG,KAAAD,EAAAL,GAAA,IAEAK,EAAAL,GAAA,EAEA,IAAAD,KAAAF,EACAU,OAAAC,UAAAC,eAAAC,KAAAb,EAAAE,KACAY,EAAAZ,GAAAF,EAAAE,IAIA,IADAL,KAAAE,EAAAC,EAAAC,GACAK,EAAAC,QACAD,EAAAS,OAAAT,GAEA,GAAAL,EACA,IAAAI,EAAA,EAAYA,EAAAJ,EAAAM,OAA2BF,IACvCD,EAAAY,IAAAC,EAAAhB,EAAAI,IAGA,OAAAD,GAIA,IAAAc,KAGAV,GACAW,EAAA,GAIA,SAAAH,EAAAd,GAGA,GAAAgB,EAAAhB,GACA,OAAAgB,EAAAhB,GAAAkB,QAGA,IAAAC,EAAAH,EAAAhB,IACAG,EAAAH,EACAoB,GAAA,EACAF,YAUA,OANAN,EAAAZ,GAAAW,KAAAQ,EAAAD,QAAAC,IAAAD,QAAAJ,GAGAK,EAAAC,GAAA,EAGAD,EAAAD,QAKAJ,EAAAO,EAAAT,EAGAE,EAAAQ,EAAAN,EAGAF,EAAAS,EAAA,SAAAL,EAAAM,EAAAC,GACAX,EAAAY,EAAAR,EAAAM,IACAhB,OAAAmB,eAAAT,EAAAM,GACAI,cAAA,EACAC,YAAA,EACAC,IAAAL,KAMAX,EAAAiB,EAAA,SAAAZ,GACA,IAAAM,EAAAN,KAAAa,WACA,WAA2B,OAAAb,EAAA,SAC3B,WAAiC,OAAAA,GAEjC,OADAL,EAAAS,EAAAE,EAAA,IAAAA,GACAA,GAIAX,EAAAY,EAAA,SAAAO,EAAAC,GAAsD,OAAA1B,OAAAC,UAAAC,eAAAC,KAAAsB,EAAAC,IAGtDpB,EAAAqB,EAAA,IAGArB,EAAAsB,GAAA,SAAAC,GAA8D,MAApBC,QAAAC,MAAAF,GAAoBA","file":"static/js/manifest.2ae2e69a05c33dfc65f8.js","sourcesContent":[" \t// install a JSONP callback for chunk loading\n \tvar parentJsonpFunction = window[\"webpackJsonp\"];\n \twindow[\"webpackJsonp\"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {\n \t\t// add \"moreModules\" to the modules object,\n \t\t// then flag all \"chunkIds\" as loaded and fire callback\n \t\tvar moduleId, chunkId, i = 0, resolves = [], result;\n \t\tfor(;i < chunkIds.length; i++) {\n \t\t\tchunkId = chunkIds[i];\n \t\t\tif(installedChunks[chunkId]) {\n \t\t\t\tresolves.push(installedChunks[chunkId][0]);\n \t\t\t}\n \t\t\tinstalledChunks[chunkId] = 0;\n \t\t}\n \t\tfor(moduleId in moreModules) {\n \t\t\tif(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {\n \t\t\t\tmodules[moduleId] = moreModules[moduleId];\n \t\t\t}\n \t\t}\n \t\tif(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules);\n \t\twhile(resolves.length) {\n \t\t\tresolves.shift()();\n \t\t}\n \t\tif(executeModules) {\n \t\t\tfor(i=0; i < executeModules.length; i++) {\n \t\t\t\tresult = __webpack_require__(__webpack_require__.s = executeModules[i]);\n \t\t\t}\n \t\t}\n \t\treturn result;\n \t};\n\n \t// The module cache\n \tvar installedModules = {};\n\n \t// objects to store loaded and loading chunks\n \tvar installedChunks = {\n \t\t2: 0\n \t};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"/\";\n\n \t// on error function for async loading\n \t__webpack_require__.oe = function(err) { console.error(err); throw err; };\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap f3383f2c542efd14ff14"],"sourceRoot":""}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
|
@ -36,7 +36,7 @@
|
|||
"babel-preset-stage-2": "^6.22.0",
|
||||
"babel-register": "^6.22.0",
|
||||
"chalk": "^2.0.1",
|
||||
"chromedriver": "^2.27.2",
|
||||
"chromedriver": "^2.46.0",
|
||||
"copy-webpack-plugin": "^4.0.1",
|
||||
"cross-spawn": "^5.0.1",
|
||||
"css-loader": "^0.28.0",
|
||||
|
|
Loading…
Reference in New Issue