import streamlit as st import spacy from streamlit_echarts import st_echarts from annotated_text import annotated_text st.set_page_config( page_title="LeetSpeak-NER", page_icon=":mega:", layout="wide", initial_sidebar_state="expanded", menu_items={ 'Get Help': 'https://www.extremelycoolapp.com/help', 'Report a bug': "https://www.extremelycoolapp.com/bug", 'About': "# This is a header. This is an *extremely* cool app!" } ) @st.cache(show_spinner=False, allow_output_mutation=True, suppress_st_warning=True) def load_models(): spanish_model = spacy.load("./spacy-models/toy_output_es_blank/model-best/") english_model = spacy.load("./spacy-models/toy_output_en_blank/model-best/") models = {"English": english_model, "Spanish": spanish_model} return models # 'INV_CAMO', 'LEETSPEAK', 'MIX', 'PUNCT_CAMO' def process_text(doc, selected_multi_ner): tokens = [] for token in doc: if selected_multi_ner == "Yes": if token.ent_type_ == "INV_CAMO": tokens.append((token.text, "INV_CAMO", "#faa")) elif token.ent_type_ == "LEETSPEAK": tokens.append((token.text, "LEETSPEAK", "#fda")) elif token.ent_type_ == "MIX": tokens.append((token.text, "MIX", "#afa")) elif token.ent_type_ == "PUNCT_CAMO": tokens.append((token.text, "PUNCT_CAMO", "#aaaaff")) else: tokens.append(" " + token.text + " ") else: if token.ent_type_ in ['INV_CAMO', 'LEETSPEAK', 'MIX', 'PUNCT_CAMO']: tokens.append((token.text, "CAMOUFLAGE", "#ffd5aa")) else: tokens.append(" " + token.text + " ") return tokens # Side bar selected_language = st.sidebar.selectbox("Select a language", options=["English", "Spanish"]) selected_multi_ner = st.sidebar.radio('Do you want to break down the Entities detected by type of leetspeak?', ['Yes', 'No']) models = load_models() selected_model = models[selected_language] import base64 LOGO_IMAGE = "aida_logo.png" st.markdown( """ """, unsafe_allow_html=True ) col1, col2 = st.columns([4, 1]) with col1: st.markdown(""" """, unsafe_allow_html=True) st.markdown('
Welcome to LeetSpeak-NER
', unsafe_allow_html=True) with col2: # st.image('./aida_logo.png') st.markdown( f"""