Hitri popravki in navodila
This commit is contained in:
@@ -11,3 +11,8 @@ services:
|
|||||||
- ./swagger_server/classla/classla_resources:/root/classla_resources
|
- ./swagger_server/classla/classla_resources:/root/classla_resources
|
||||||
environment:
|
environment:
|
||||||
- PYTHONUNBUFFERED=1
|
- PYTHONUNBUFFERED=1
|
||||||
|
tika:
|
||||||
|
image: apache/tika
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- 9998:9998
|
||||||
|
|||||||
@@ -11,3 +11,4 @@ pandas==1.3.3
|
|||||||
python-docx==0.8.11
|
python-docx==0.8.11
|
||||||
lxml==4.8.0
|
lxml==4.8.0
|
||||||
PyPDF2==2.10.4
|
PyPDF2==2.10.4
|
||||||
|
requests
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import connexion
|
import connexion
|
||||||
import six
|
import six
|
||||||
# import tika
|
# import tika
|
||||||
|
import requests
|
||||||
|
|
||||||
from swagger_server import util
|
from swagger_server import util
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
@@ -20,37 +21,25 @@ def datoteka_v_besedilo_post(file=None): # noqa: E501
|
|||||||
|
|
||||||
:rtype: str
|
:rtype: str
|
||||||
"""
|
"""
|
||||||
|
#zakaj ? tika server se požene zraven v dodatnem containerju in se datoteka samo pošlje tja, nazaj pa se dobi čisto besedilo...
|
||||||
|
#tika ima rest api
|
||||||
if file is None:
|
if file is None:
|
||||||
return "No file provided", 400
|
return "No file provided", 400
|
||||||
elif "openxmlformats-officedocument.wordprocessingml.document" in file.content_type:
|
|
||||||
content = [p.text for p in docx.Document(file).paragraphs]
|
|
||||||
elif "text/plain" in file.content_type:
|
|
||||||
content = file.read().decode('utf-8')
|
|
||||||
elif "application/pdf" in file.content_type:
|
|
||||||
reader = PdfReader(file)
|
|
||||||
content = '\n'.join([p.extract_text() for p in reader.pages])
|
|
||||||
content = "ZACASNO UPORABLJEN DRUGI BRALEC KOT TIKA, TA BO SE DODANA KASNEJE...\n\n" + content
|
|
||||||
elif "text/xml" in file.content_type:
|
|
||||||
root = ET.parse(file).getroot()
|
|
||||||
plainText = root.findall('PlainText')
|
|
||||||
if len(plainText) == 0:
|
|
||||||
return "Didn't find anything in PlainText", 400
|
|
||||||
content = '\n'.join([pt.text for pt in plainText])
|
|
||||||
else:
|
|
||||||
return "Currently supporing only docx, txt/plain, pdf, xml*... more will be added later", 501
|
|
||||||
|
|
||||||
return content, 200
|
tika_server="http://tika:9998/tika"
|
||||||
|
response=requests.post(tika_server, data=file)
|
||||||
|
return response.text, 200
|
||||||
|
|
||||||
|
|
||||||
def get_text_ocr(file=None): # noqa: E501
|
def get_text_ocr(file=None): # noqa: E501
|
||||||
"""Pretvori datoteko formata pdf, doc, docx, ppt, xls,... v besedilo s pomočjo ocr razpoznavanja
|
|
||||||
|
|
||||||
# noqa: E501
|
|
||||||
|
|
||||||
:param file:
|
if file is None:
|
||||||
:type file: strstr
|
return "No file provided", 400
|
||||||
|
|
||||||
|
tika_server="http://tika:9998/tika"
|
||||||
|
#za ocr se zraven samo doda header
|
||||||
|
response=requests.post(tika_server, data=file,headers={"X-Tika-PDFOcrStrategy":"ocr_only","X-Tika-OCRLanguage":"slv+eng"})
|
||||||
|
return response.text, 200
|
||||||
|
|
||||||
|
|
||||||
:rtype: str
|
|
||||||
"""
|
|
||||||
return 'Not yet implemented'
|
|
||||||
|
|||||||
@@ -18,4 +18,54 @@ def get_candidates(body): # noqa: E501
|
|||||||
"""
|
"""
|
||||||
if connexion.request.is_json:
|
if connexion.request.is_json:
|
||||||
body = IzlusciBody.from_dict(connexion.request.get_json()) # noqa: E501
|
body = IzlusciBody.from_dict(connexion.request.get_json()) # noqa: E501
|
||||||
return 'do some magic!3'
|
|
||||||
|
|
||||||
|
data={
|
||||||
|
terminoloski_kandidati:[
|
||||||
|
{
|
||||||
|
"POSoznake": "Ncmsn",
|
||||||
|
"kandidat": "vpliv",
|
||||||
|
"kanonicnaoblika": "vpliv",
|
||||||
|
"nosilnautez": 0.8008282,
|
||||||
|
"podporneutezi": [
|
||||||
|
6.0274563,
|
||||||
|
6.0274563
|
||||||
|
],
|
||||||
|
"pogostostpojavljanja": [101,71]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"POSoznake": "Agpnsg Ncnsg",
|
||||||
|
"kandidat": "bivalen okolje",
|
||||||
|
"kanonicnaoblika": "bivalno okolje",
|
||||||
|
"nosilnautez": 0.60254,
|
||||||
|
"podporneutezi": [
|
||||||
|
3.263,
|
||||||
|
2.134
|
||||||
|
],
|
||||||
|
"pogostostpojavljanja": [27,11]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"POSoznake": "Agpmsny Ncmsn Ncmpg",
|
||||||
|
"kandidat": "motorični status otrok",
|
||||||
|
"kanonicnaoblika": "motorični status otrok",
|
||||||
|
"nosilnautez": 0.3324,
|
||||||
|
"podporneutezi": [
|
||||||
|
1.221,
|
||||||
|
3.323
|
||||||
|
],
|
||||||
|
"pogostostpojavljanja": [31,51]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"POSoznake": "Agpnsn Ncnsn",
|
||||||
|
"kandidat": "diplomsko delo",
|
||||||
|
"kanonicnaoblika": "diplomsko delo",
|
||||||
|
"nosilnautez": 0.2008282,
|
||||||
|
"podporneutezi": [
|
||||||
|
0.883,
|
||||||
|
1.02
|
||||||
|
],
|
||||||
|
"pogostostpojavljanja": [1241,111]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
return data
|
||||||
|
|||||||
Reference in New Issue
Block a user