This commit is contained in:
yair-mantis 2024-01-09 11:57:06 +02:00
parent fff7f81e38
commit 95ce964fac

View File

@ -10,6 +10,7 @@ load_dotenv()
# Read API key from .env file # Read API key from .env file
api_key = os.getenv("API_KEY") api_key = os.getenv("API_KEY")
def get_nakdan_response(hebrew_text, api_key): def get_nakdan_response(hebrew_text, api_key):
url = "https://nakdan-5-3.loadbalancer.dicta.org.il/addnikud" url = "https://nakdan-5-3.loadbalancer.dicta.org.il/addnikud"
headers = {'Content-Type': 'text/plain;charset=utf-8'} headers = {'Content-Type': 'text/plain;charset=utf-8'}
@ -47,7 +48,12 @@ def main():
response = get_nakdan_response(hebrew_text, api_key) response = get_nakdan_response(hebrew_text, api_key)
# st.json(response) # st.json(response)
# Extract words # Extract words
words = [option['w'] for item in response['data'] if 'nakdan' in item for option in item['nakdan'].get('options', [])] words = [
option['w']
for item in response['data']
if 'nakdan' in item
for option in item['nakdan'].get('options', [])
]
st.text(words) st.text(words)
# Create an image # Create an image
img = Image.new('RGB', (300, 100), color=(255, 255, 255)) img = Image.new('RGB', (300, 100), color=(255, 255, 255))
@ -63,7 +69,5 @@ def main():
st.image(img) st.image(img)
if __name__ == "__main__": if __name__ == "__main__":
main() main()