from typing import Optional import spacy from spacy import displacy from spacy.language import Language import streamlit as st from spacy_streamlit import visualize_parser from spacy_streamlit import visualize_tokens import base64 from PIL import Image #import pandas st.set_page_config(layout="wide") st.image("logo.png", use_column_width=False, width=150) st.title("Ancient Greek Syntax Analyzer") st.markdown("Welcome to our analyzer. Here you can parse the parts of speech (POS) and the syntactic relationships of any ancient Greek sentence. This analysis is done by our language models trained with transformers and the NLP library spaCy. Below, you can choose which model do you want to use (each model may produce a different analysis). Documentation about the linguistic terms used by our models to annotate your sentences can be found here. If you have any questions, please contact us at diogenet@ucsd.edu") st.header("Select a model:") spacy_model = st.selectbox("Model", ["grc_proiel_lg","grc_proiel_trf","grc_proiel_sm","grc_perseus_lg","grc_perseus_trf","grc_perseus_sm"]) st.header("Enter text:") text = st.text_area("Greek text","φύσει μὲν οὖν αἴσθησιν ἔχοντα γίγνεται τὰ ζῷα, ἐκ δὲ ταύτης τοῖς μὲν αὐτῶν οὐκ ἐγγίγνεται μνήμη, τοῖς δʼ ἐγγίγνεται.") #config = {"punct_chars": [".", ";", "·"]} nlp = spacy.load(spacy_model, exclude="senter") #nlp.add_pipe("sentencizer", config=config, before="parser") # Get the new pipeline order doc = nlp(text) def get_html(html: str): """Convert HTML so it can be rendered.""" WRAPPER = """