2021-10-18 18:22:03 +02:00
|
|
|
from fastapi import FastAPI, Response, Request
|
|
|
|
|
|
|
|
from fastapi.responses import JSONResponse
|
|
|
|
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
|
|
from updateDatabase import *
|
|
|
|
|
|
|
|
pluriDBupdater = PluritonUpdater()
|
|
|
|
|
|
|
|
pluriDBupdater.loadModels()
|
|
|
|
|
|
|
|
|
|
|
|
@app.post("/datext", response_class=JSONResponse)
|
|
|
|
async def root(data: Request):
|
|
|
|
|
|
|
|
text_bytes = await data.body()
|
|
|
|
|
|
|
|
text = str(text_bytes)
|
|
|
|
|
|
|
|
print(text)
|
|
|
|
|
2023-03-06 15:36:57 +01:00
|
|
|
text_lower = text.lower()
|
|
|
|
|
|
|
|
einfach, schwer = pluriDBupdater.searchNearest2Translate(text_lower)
|
2021-10-18 18:22:03 +02:00
|
|
|
|
|
|
|
einfachstr = ''
|
|
|
|
schwerstr = ''
|
|
|
|
|
|
|
|
for word in einfach:
|
|
|
|
einfachstr += word + ' '
|
|
|
|
for word in schwer:
|
|
|
|
schwerstr += word + ' '
|
|
|
|
|
|
|
|
daresponse = einfachstr + '?&?&' + schwerstr
|
|
|
|
|
|
|
|
|
|
|
|
return JSONResponse(content=daresponse)
|
|
|
|
|