Amrrs/numerizerlit
1
1# load required libraries2 3import streamlit as st4import spacy5#import en_core_web_sm6from numerizer import numerize7 8 9st.title("Numerizer - Convert *English Numbers* into *Ints* and *Floats*")10 11@st.cache(allow_output_mutation=True, suppress_st_warning=True)12def load_model():13 """Load a spaCy model."""14 model = spacy.load("en_core_web_sm")15 return model16 17 18@st.cache(allow_output_mutation=True, suppress_st_warning=True)19def process_text(text: str):20 """Process a text and create a Doc object."""21 nlp = load_model()22 return nlp(text)23 24st.markdown("Input Text")25 26inp_text = st.text_input(label="Add text here", value = "Two plus Two equals Four")27#inp_text = 'The Hogwarts Express is at platform nine and three quarters and platform nine and three quarters'28 29st.write(inp_text)30 31doc = process_text(inp_text)32 33 34numerized_parts = doc._.numerize()35 36st.markdown("Numerized Sections \n")37 38st.markdown( numerized_parts)39 40 41final_sentence = inp_text42 43for key in numerized_parts.keys():44 #print(key)45 final_sentence = final_sentence.replace(str(key),numerized_parts[key])46 47st.write("### Numerized Output Text")48 49st.write(final_sentence)50 