Amrrs commited on
Commit
18d3ec0
·
1 Parent(s): 527ae01

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -0
app.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # load required libraries
2
+
3
+ import streamlit as st
4
+ import spacy
5
+ import en_core_web_sm
6
+ from numerizer import numerize
7
+
8
+
9
+ st.title("Numerizer - Convert *English Numbers* into *Ints* and *Floats*")
10
+
11
+ @st.cache(allow_output_mutation=True, suppress_st_warning=True)
12
+ def load_model():
13
+ """Load a spaCy model."""
14
+ model = en_core_web_sm.load()
15
+ return model
16
+
17
+
18
+ @st.cache(allow_output_mutation=True, suppress_st_warning=True)
19
+ def process_text(text: str):
20
+ """Process a text and create a Doc object."""
21
+ nlp = load_model()
22
+ return nlp(text)
23
+
24
+ st.markdown("Input Text")
25
+
26
+ inp_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
+
29
+ st.write(inp_text)
30
+
31
+ doc = process_text(inp_text)
32
+
33
+
34
+ numerized_parts = doc._.numerize()
35
+
36
+ st.markdown("Numerized Sections \n")
37
+
38
+ st.markdown( numerized_parts)
39
+
40
+
41
+ final_sentence = inp_text
42
+
43
+ for key in numerized_parts.keys():
44
+ #print(key)
45
+ final_sentence = final_sentence.replace(str(key),numerized_parts[key])
46
+
47
+ st.write("### Numerized Output Text")
48
+
49
+ st.write(final_sentence)