File size: 1,719 Bytes
46cacbc
 
 
 
 
 
 
df1df2c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63df90f
46cacbc
 
 
 
22f4a25
46cacbc
 
 
 
 
 
 
 
 
2f0be93
 
a5f83bc
4ab4c78
46cacbc
 
a5f83bc
df1df2c
a5f83bc
df1df2c
a5f83bc
df1df2c
46cacbc
df1df2c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# import
import streamlit as st
from parstdex import Parstdex

# set config
st.set_page_config(layout="wide", page_title="Parstdex")

# Layout adjustments
st.markdown(
    """
<style>
.reportview-container .main .block-container {
    max-width: 1400px;
}
</style>
""",
    unsafe_allow_html=True,
)


# Load models lazily
@st.cache(allow_output_mutation=True)
def load_model():
    model = Parstdex()
    return model

with st.spinner(text="Please wait while the model is loading...."):
    # cache
    model = load_model()

# APP
# set title and subtitle
st.title("Parstdex")
st.markdown("Demo of Parstdex Python Package: https://github.com/kargaranamir/parstdex")
st.markdown("Paste any persian (farsi) text you want to extract its time and date 🖖.")
# create the input text box and setting panel
text = st.text_area('Paste your text here...', "ساعت ۸ صبح من و علی قرار گذاشتیم که شانزده بهمن ۱۳۷۵ هم دیگر را در دوشنبه بازار ببینیم.", height=50)
button = st.button("Extract")

# if button is clicked
with st.spinner("Processing Text  and Extracting..."):
    if button and text:
        # extract markers from the text
        spans = model.extract_span(text)
        markers = model.extract_marker(text)
        time_mls = model.extract_time_ml(text)
        ners = model.extract_ner(text)

        # display the result
        st.markdown("**Span:**")
        st.code(spans, language="python")
        st.markdown("**Marker:**")
        st.code(markers, language="python")
        st.markdown("**Time_ML:**")
        st.code(f"\u202b{time_mls}\u202c", language="python")
        st.markdown("**NER:**")
        st.code(ners, language="python")