Preperation for merging multiple conllus, also added ATE files
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
import connexion
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
from swagger_server.models.izlusci_body import IzlusciBody # noqa: E501
|
||||
from swagger_server.classla import cl_utils
|
||||
import requests
|
||||
|
||||
# ATEapi_endpoint = "http://localhost:5000/predict"
|
||||
|
||||
|
||||
ATEapi_endpoint = "http://ate-api:5000/predict"
|
||||
|
||||
|
||||
def get_candidates(body): # noqa: E501
|
||||
@@ -16,6 +24,45 @@ def get_candidates(body): # noqa: E501
|
||||
if connexion.request.is_json:
|
||||
body = IzlusciBody.from_dict(connexion.request.get_json()) # noqa: E501
|
||||
|
||||
# Todo: What is "conllus" in body input anyway??
|
||||
# Todo: Kaj je s prepovedanimi besedami?
|
||||
# file_ids = [10000, 10001, 10002, 10003]
|
||||
# big_conllu = cl_utils.multipla_conllus_to_one_from_file_ids(file_ids)
|
||||
|
||||
# txt = Path('../ATEapi/temp_1.conllu').read_text('utf-8') # LOCAL ONLY
|
||||
|
||||
# # Todo: does this close the file after the request?
|
||||
# files = [
|
||||
# ('file', ('temp_1.conllu', open('../ATEapi/temp_1.conllu', 'rb'),
|
||||
# 'application/octet-stream'))
|
||||
# ]
|
||||
# res = requests.post(ATEapi_endpoint, files=files)
|
||||
# # res.status_code
|
||||
# # res.text
|
||||
#
|
||||
# return res.text, res.status_code
|
||||
#
|
||||
# example_data = ""
|
||||
# with open("C:\\Users\\Kiki\\Desktop\\Untitled-2.json", "r", encoding='utf-8') as f:
|
||||
# example_data = json.loads(f.read())
|
||||
#
|
||||
# d = 0
|
||||
#
|
||||
# ret = {'terminoloski_kandidati': [
|
||||
# {
|
||||
# 'POSoznake': tk['msd'],
|
||||
# 'kandidat': tk['terms'], # more to bit lemma al terms?
|
||||
# 'kanonicnaoblika': tk['canonical'],
|
||||
# 'ranking': tk['ranking'],
|
||||
# 'podporneutezi': [
|
||||
# 6.0274563, # ????????
|
||||
# 6.0274563 # ??????
|
||||
# ],
|
||||
# 'pogostostpojavljanja': [101, 71] # ???????
|
||||
# }
|
||||
# for tk in example_data
|
||||
# ]}
|
||||
|
||||
data = {
|
||||
"terminoloski_kandidati": [
|
||||
{
|
||||
|
||||
@@ -97,7 +97,7 @@ def try_do_jobs_classla():
|
||||
[ex.submit(execute_classla_job, job) for job in unfinished_jobs]
|
||||
|
||||
except Exception as e:
|
||||
print(f"Exception in {__name__}: {e}")
|
||||
print(f"Exception in try_do_jobs_classla")
|
||||
finally:
|
||||
time.sleep(3)
|
||||
|
||||
@@ -113,7 +113,7 @@ def try_do_jobs_doc2text():
|
||||
with cf.ThreadPoolExecutor(max_workers=DOC2TEXT_CONCURANCE_LIMIT) as ex:
|
||||
[ex.submit(execute_doc2text_job, job) for job in unfinished_jobs]
|
||||
except Exception as e:
|
||||
print(f"Exception in {__name__}: {e}")
|
||||
print(f"Exception in try_do_jobs_doc2text")
|
||||
finally:
|
||||
time.sleep(3)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user