File size: 2,161 Bytes
fca122e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
58
59
60
61
62
63
64
65
66
67
import streamlit as st

from run_eval import run_generate

st.write("# GupShup")
st.write("## Summarizing Open-Domain Code-Switched Conversations")
task_type = st.sidebar.selectbox(
    "Task type", ["Hinglish to English", "English to English"]
)
model_name = st.sidebar.selectbox(
    "Model", ["Pegasus", "mBart", "Bart", "GPT", "T5", "T5_MTL"]
)


default_value = "summarize: Debanjan: Hi! kya tum EMNLP attend kar rahein ho? Anish: nehi I will skip this year. what about you? Debanjan: mein virtually attend kar raha hu  Debanjan: hopefully can attend the conference in person from next year... Anish: haan dekhtey hain, in person attend karney mein alaag hi maaza hain Debanjan: but I also like this hybrid mode allows to attend the sessions in case you do not make it Anish: right Anish: if you are attending to mujhe interesting papers kuch bhej dena Debanjan: sure"

conv_form = st.sidebar.form(key="conv_form")
conv_ip = conv_form.text_input(label="Please enter the conversastion", value=default_value)
conv_submit_button = conv_form.form_submit_button(label="Submit")

# sent = st.text_area("Text", default_value, height=275)

st.write("### Task Type:", task_type)
st.write("### Model:", model_name)
x = "fg"

src_file = None
tar_file = None
gen_file = "generated_summary.txt"
score_file = None

if conv_submit_button:
    if conv_ip == "":
        st.write("Pls enter non empty conversastion")
    else:
        st.write("### Summarizing below Conversastion")
        st.write(conv_ip)
        src_file = "conversastion.txt"
        src_fp = open(src_file, "w")
        src_fp.write(conv_ip)
        src_fp.close()

tt = "h2e"
if task_type == "English to English":
    tt = "e2e"
elif task_type == "Hinglish to English":
    tt = "h2e"
model_name_path = "midas/gupshup_" + str(tt) + "_" + str(model_name).lower()


result = run_generate(
    verbose=True,
    model_name_path=model_name_path,
    src_txt=src_file,
    tar_txt=tar_file,
    gen_path=gen_file,
    scor_path=score_file,
    batch_size=8,
)

if conv_submit_button:
    st.write("summary:")
    fp = open(gen_file, "r")
    summary = fp.readlines()
    fp.close()
    st.write(summary)