test-api / app.py
TymaaHammouda's picture
test
245fc67
from fastapi import FastAPI
from sinatools.utils import parser
from sinatools.DataDownload.downloader import download_file
from sinatools.DataDownload.downloader import download_folder_from_hf
import os
app = FastAPI()
SINATOOLS_DIR = os.path.expanduser("~/.sinatools")
os.makedirs(SINATOOLS_DIR, exist_ok=True)
# Destination path
dest_path = os.path.join(SINATOOLS_DIR)
# Download explicitly to the expected path
download_file(url="https://sina.birzeit.edu/lemmas_dic.pickle", dest_path=dest_path)
#download_folder_from_hf("TymaaHammouda/testing_lemmatizer_model", 'Lemmatizer_model')
download_file(url='https://sina.birzeit.edu/five_grams.pickle', dest_path=dest_path)
download_file(url='https://sina.birzeit.edu/four_grams.pickle', dest_path=dest_path)
download_file(url='https://sina.birzeit.edu/three_grams.pickle', dest_path=dest_path)
download_file(url='https://sina.birzeit.edu/two_grams.pickle', dest_path=dest_path)
from sinatools.morphology.morph_analyzer import analyze
# download_file('https://sina.birzeit.edu/lemmas_dic.pickle')
# args_path = hf_hub_download(
# repo_id="SinaLab/Nested",
# filename="args.json"
# )
download_file(url='https://sina.birzeit.edu/Wj27012000.tar.gz', dest_path=dest_path)
from sinatools.ner.entity_extractor import extract
@app.get("/")
def greet_json():
# output =parser.arStrip('2023الجو جميلُ')
# print(output)
# lemmatizer_results = analyze('ذهب الولد الى المدرسة')
ner_output = extract('ذهب محمد الى جامعة بيرزيت')
return {"output": ner_output}