Ejemplo n.º 1
0
color = st.select_slider(
    'Select a color of the rainbow',
    options=['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'])
st.write('My favorite color is', color)

title = st.text_input('Movie title', 'Life of Brian')
title

number = st.number_input('Insert a number')
number

txt = st.text_area(
    'Text to analyze', '''
    It was the best of times, it was the worst of times, it was
    the age of wisdom, it was the age of foolishness, it was
    the epoch of belief, it was the epoch of incredulity, it
    was the season of Light, it was the season of Darkness, it
    was the spring of hope, it was the winter of despair, (...)
    ''')

txt

st.title("Layout (**TODO**)")

# ------------------------------------------------------------------------------

"------"

# ------------------------------------------------------------------------------

st.title('Uber pickups in NYC')
Ejemplo n.º 2
0
def main():
    """A Simple NLP app with Spacy-Streamlit"""
    st.title("Text processing app for biological scientific papers")
    menu = ["Home", "NER", "Summarization", "Zero shot learning"]
    choice = st.sidebar.selectbox("Menu", menu)
    if choice == "Home":

        link = '[GitHub page](https://github.com/fm1320/IC_NLP)'
        st.write(
            """This application was made as part of a postgradute program at Imeprial College London. The details about the traning of the models, data and the techniques can be found at my personal github page provided below."""
        )
        st.markdown(link, unsafe_allow_html=True)
        st.write(
            """<---- Choose and try out one of the NLP tasks available from the drop down menu on the left"""
        )
        st.markdown(
            "![Alt Text](https://upload.wikimedia.org/wikipedia/en/thumb/5/5f/Imperial_College_London_monotone_logo.jpg/320px-Imperial_College_London_monotone_logo.jpg)"
        )
        st.write(
            "*Text examples source: Garcia-Perez, I., Posma, J.M., Serrano-Contreras, J.I. et al. Identifying unknown metabolites using NMR-based metabolic profiling techniques. Nat Protoc 15, 2538–2567 (2020). https://doi.org/10.1038/s41596-020-0343-3"
        )

        #st.subheader("Tokenization")
        #raw_text = st.text_area("Your Text","Enter Text Here")
        #docx = nlp(raw_text)
        #if st.button("Tokenize"):
        #   spacy_streamlit.visualize_tokens(docx,attrs=['text','pos_','dep_','ent_type_'])

    elif choice == "NER":
        st.subheader("Named Entity Recognition")
        # Add a selectbox to the sidebar:
        sel = st.sidebar.selectbox("Which NER model would you like to use ?", [
            "SpaCy Bloom embedding DL", "Spacy core en default",
            "String/Regex matching"
        ])

        # if sel== "SciSpacy":
        #import scispacy
        # nlp = spacy.load("en_core_sci_sm")
        # elif sel=="DL small":
        # nlp = spacy.load('./BiA') #Location of directory of spacy model
        if sel == "SpaCy Bloom embedding DL":
            path = model_loader(
                "https://github.com/fm1320/IC_NLP/releases/download/V3/V3-20210203T001829Z-001.zip",
                "V3")
            nlp = spacy.load(path)
        elif sel == "Spacy core en default":
            import en_core_web_sm
            nlp = en_core_web_sm.load()
            st.write(
                "*This is an example of a default model with general entities. Choose one of the other two to see assay recognition."
            )
        elif sel == "String/Regex matching":
            #r_text = st.text_area("Enter text for entity recognition with Regex","Text here")
            r_text = st.text_area(
                "Enter text for entity recognition with Regex",
                "However, it is very challenging to elucidate the structure of all metabolites present in biofluid samples. The large number of unknown or unidentified metabolites with high dynamic concentration range, extensive chemical diversity and different physical properties poses a substantial analytical challenge. Metabolic profiling studies are often geared toward finding differences in the levels of metabolites that are statistically correlated with a clinical outcome, dietary intervention or toxic exposure when compared to a control group. The chemical assignment of this reduced panel of biologically relevant metabolites is possible using statistical spectroscopic tools9–11, two-dimensional (2D) NMR spectroscopic analysis12–14, separation and pre-concentration techniques11, various chromatographic and mass spectroscopy (MS)-based analytical platforms."
            )
            iz = finder(r_text, "")
            ######################################
            # '''
            # model_id = model_ids[model_desc]
            # ex_names, ex_map = load_examples(model_id)

            # st.title('Zero Shot Topic Classification')
            # sequence = st.text_area('Text', ex_map[example][0], key='sequence', height=height)
            # labels = st.text_input('Possible topics (separated by `,`)', ex_map[example][1], max_chars=1000)
            # multi_class = st.checkbox('Allow multiple correct topics', value=True)
            # hypothesis_template = "This text is about {}."
            # labels = list(set([x.strip() for x in labels.strip().split(',') if len(x.strip()) > 0]))
            # if len(labels) == 0 or len(sequence) == 0:
            # st.write('Enter some text and at least one possible topic to see predictions.')
            # return
            # if do_print_code:
            # st.markdown(CODE_DESC.format(model_id))

            # with st.spinner('Classifying...'):
            # top_topics, scores = get_most_likely(model_id, sequence, labels, hypothesis_template, multi_class, do_print_code)

            # plot_result(top_topics[::-1][-10:], scores[::-1][-10:])

            # if "socat" not in [p.name() for p in psutil.process_iter()]:
            # os.system('socat tcp-listen:8000,reuseaddr,fork tcp:localhost:8001 &')
            # '''
            ##########################################
        method = st.sidebar.selectbox(
            "Choose input method (recommended:text box)", ["Text box", "URL"])

        if method == "Text box" and sel != "String/Regex matching":
            raw_text = st.text_area(
                "Enter text for entity recognition",
                "However, it is very challenging to elucidate the structure of all metabolites present in biofluid samples. The large number of unknown or unidentified metabolites with high dynamic concentration range, extensive chemical diversity and different physical properties poses a substantial analytical challenge. Metabolic profiling studies are often geared toward finding differences in the levels of metabolites that are statistically correlated with a clinical outcome, dietary intervention or toxic exposure when compared to a control group. The chemical assignment of this reduced panel of biologically relevant metabolites is possible using statistical spectroscopic tools9–11, two-dimensional (2D) NMR spectroscopic analysis12–14, separation and pre-concentration techniques11, various chromatographic and mass spectroscopy (MS)-based analytical platforms."
            )
            docx = nlp(raw_text)
            spacy_streamlit.visualize_ner(docx,
                                          labels=nlp.get_pipe('ner').labels)

        if method == "URL" and sel != "String/Regex matching":
            user_input = st.text_input("Enter page URL of an HTML file")
            if user_input is not None:
                downloaded = trafilatura.fetch_url(user_input)
                raw_text = trafilatura.extract(downloaded)
                raw_text = str(raw_text)
                docx = nlp(raw_text)
                spacy_streamlit.visualize_ner(
                    docx, labels=nlp.get_pipe('ner').labels)

    elif choice == "Summarization":
        #Textbox for text user is entering
        st.subheader(
            "Enter the text you'd like to summarize (Here is an example that can be pasted in the text box!)"
        )
        raw_text = st.text_area('''
    For over three decades, NMR spectroscopy has been widely applied in metabolic profiling and phenotyping1,2,3. The technology allows for accurate high-throughput screening of thousands of metabolites (small molecular species <1 kDa) present in a biological sample4,5,6,7, such as urine, plasma, feces, saliva and multiple types of tissues, as well as food8 and plant extracts. NMR spectroscopy provides robust multi-metabolite fingerprints of hundreds of metabolites in many biofluids, many of which are listed in spectral databases, particularly for common biofluids in urine and blood.
    However, it is very challenging to elucidate the structure of all metabolites present in biofluid samples. The large number of unknown or unidentified metabolites with high dynamic concentration range, extensive chemical diversity and different physical properties poses a substantial analytical challenge. Metabolic profiling studies are often geared toward finding differences in the levels of metabolites that are statistically correlated with a clinical outcome, dietary intervention or toxic exposure when compared to a control group. The chemical assignment of this reduced panel of biologically relevant metabolites is possible using statistical spectroscopic tools9,10,11, two-dimensional (2D) NMR spectroscopic analysis12,13,14, separation and pre-concentration techniques11, various chromatographic and mass spectroscopy 
    (MS)-based analytical platforms15,16 and existing spectral databases. However, the structural elucidation of NMR resonances relating to unknown molecules remains a major bottleneck in metabolic profiling studies. As a result, many published NMR-based metabolic profiling studies still continue to include putatively identified metabolites and unknown features without providing unequivocal proof of assignment, or they simply label peaks as ‘unknown’, thereby potentially missing key mechanistic information.
    To avoid the problem of multiple entries for the same compound in databases under different names, a community-wide effort is underway to develop better, faster and more standardized metabolite identification strategies, such as implementing standard nomenclature for newly identified metabolites using the International Chemical Identifier (InChI)17. Sumner et al. proposed a four-level system18 for assigning a confidence level to newly identified metabolites in metabolic profiling studies: 1) positively identified compounds (with a name, a known structure, a CAS number or an InChI); 2) putatively annotated compounds using spectral similarity with databases but without chemical reference standard; 3) putatively identified chemicals within a compound class; and 4) unknown compounds. Wishart et al. proposed a further distinction for those metabolites: the ‘known unknowns’ and the ‘unknown unknowns’19.
    A ‘known unknown’ corresponds to a metabolite that has not yet been identified in the sample of interest but that has been previously described in a database or in the literature, whereas a truly new compound, an ‘unknown unknown’, has never been described or formally identified.
    Commercial packages, such as Bruker’s AMIX TM software, and open-source software20, such as COLMAR (http://spinportal.magnet.fsu.edu/), can help with identifying these ‘known unknowns’, and some of these software applications are capable of automatically or semi-automatically annotating a limited number of compounds in a biological sample. However, even with automated annotation, the software still requires manual revision and can be prone to inconsistent interpretation and assignment by different individuals19. Most software packages and databases do not support identification of ‘unknown unknowns’, although a few platforms, such as AMIX, include prediction software to aid the identification of new compounds.
    Open-access databases have been created for researchers to deposit information relating to newly identified compounds. Most of the available databases, such as the Human Metabolome Database (HMDB)21, the BioMagResBank (BMRB)22, PRIMe server23, COLMAR 1H(13C)-TOCCATA and Bruker-AMIX (http://www.bruker-biospin.com/amix.html), contain chemical shift values, relative intensity and peak shape information for 1H-NMR and often 13C-NMR data to support metabolite identification. However, all databases contain inherent errors, such as incorrect structures for the metabolites, incorrect names and incorrect assigments. This problem is compounded further by the effect that experimental conditions, such as the pH or ionic content of the sample, can have on the chemical shift of a metabolite.
    Some of these databases, such as HMDB, provide complementary information, including MS assignments, which can be useful for checking potential errors in assignments of NMR peaks. However, although there are resources available to aid assignment of candidate biomarkers, there is no panacea for accurate metabolite identification, and there remains a clear unmet need for improved strategies for metabolite identification and curation for NMR spectral profiling.  
      ''')  #text is stored in this variable
        summWords = summarize(raw_text)
        st.subheader("Summary")
        st.write(summWords)

    elif choice == "Zero shot learning":
        st.write(
            """Due to resource constraints, this demo is moved to the link below:"""
        )
        link = '[Zero shot learning for NER demo](https://colab.research.google.com/drive/1zKDbjLo9vyEuSRotSSVwFLyaA61o1ceG#scrollTo=hkfE6NRA0Dzy)'
        st.markdown(link, unsafe_allow_html=True)
        st.write(
            "*Thanks to Hugging face's wonderful model repository and inspired by Joe Davison (researcher at hugging face)"
        )
        hug = '[Hugging face](https://huggingface.co/)'
        st.markdown(hug, unsafe_allow_html=True)
Ejemplo n.º 3
0
    )
    return response

    
st.title('音声出力アプリ,いわゆる棒読みちゃんやで')

st.markdown('###  データ準備したるで')
input_option = st.selectbox(
    '入力データの選択',
    ('直接入力する??','テキストファイルもっとるん自分?.txtのやつやで?')
)
input_data = None

if input_option  == '直接入力する??':
    input_data = st.text_area('ここに読んで欲しい文書けよ!!。','ここに早よかけ言うてるやん!!!そうじゃないとこの文読むで?ええんか?')
else:
    uploaded_file = st.file_uploader('テキストファイルもっとるん自分?.txtのやつやで?',['txt'])
    if uploaded_file is not None:
        content = uploaded_file.read()
        input_data = content.decode()

if input_data is not None:
    st.write('これでええか?')
    st.write(input_data)
    st.markdown('###  パラメーター設定')
    st.subheader(('言語と話者の性別選択'))

    lang = st.selectbox(
        '言語を選択しろやぼけええええ',
        ('日本語','英語やで?ええん?ほんまに?わかる?')
Ejemplo n.º 4
0
import requests

st.title("BERT DRCD QuestionAnswering")

# backend_pred_url = "http://fastapi:8000/predict/"
backend_pred_url = "http://127.0.0.1:8000/predict/"

with st.form("input_area"):

    # setting default value
    text_area_value = "鴻海科技集團是由臺灣企業家郭台銘創辦的跨國企業,總部位於臺灣新北市土城區,主要生產地則在中國大陸,以富士康做為商標名稱。其專注於電子產品的代工服務,研發生產精密電氣元件、機殼、準系統、系統組裝、光通訊元件、液晶顯示件等3C產品上、下游產品及服務。"
    text_input_value = "鴻海集團總部位於哪裡?"

    text = st.text_area(
        "Paragraph: ",
        value=text_area_value,
        help=
        "BERT model can only process 512 tokens, the rest tokens will be truncated.",
    )
    query = st.text_input("Question: ", value=text_input_value)

    submitted = st.form_submit_button("Submit")
    if submitted:
        if not text or not query:
            st.warning("Paragraph and Question should not be empty.")
        else:
            payload = {"text": text, "query": query}
            with st.spinner(
                    "It'll take a while to run for the first time. Please wait."
            ):
                result = requests.post(backend_pred_url, json=payload)
                st.write(result.json())
Ejemplo n.º 5
0
st.title("Interactive Widgets")

st.subheader("Checkbox")
w1 = st.checkbox("I am human", True)
st.write(w1)

if w1:
    st.write("Agreed")

st.subheader("Slider")
w2 = st.slider("Age", 0.0, 100.0, (32.5, 72.5), 0.5)
st.write(w2)

st.subheader("Textarea")
w3 = st.text_area("Comments", "Streamlit is awesomeness!")
st.write(w3)

st.subheader("Button")
w4 = st.button("Click me")
st.write(w4)

if w4:
    st.write("Hello, Interactive Streamlit!")

st.subheader("Radio")
options = ("female", "male")
w5 = st.radio("Gender", options, 1)
st.write(w5)

st.subheader("Text input")
Ejemplo n.º 6
0
    cluster = kmeans_models[cat].predict(pca_x)
    return cluster[0]


max_rf_regressor = joblib.load('models/max_salary_rf')
min_rf_regressor = joblib.load('models/min_salary_rf')

st.header('If you are looking to post a job, you came to the right place, we will help you to have an estimate of how much the industry is paying for this kind of position.')

cat = st.selectbox('Select a category', categories)

contract_type = st.selectbox('Select a contract type', contracts)

d_work = st.multiselect('Full time or part time?', d_works)

description = st.text_area('Describe the job')

state = st.selectbox('Select a state?', states)

has_category = len(cat)>0
has_contract_type = len(contract_type)>0
has_d_work = len(d_work)>0
has_description = len(cat)>0 and len(description)>50
has_state = len(state)>0

if (
    has_category
    and has_contract_type
    and has_d_work
    and has_description
    and has_description
        response = bot_response(response)

    return response


def get_text():
    input_text = st.text_input("You: ", key=3)
    global original_input_text
    original_input_text = input_text
    df_input = pd.DataFrame([input_text], columns=['questions'])
    return df_input


def get_user_name():
    response = 'Hello user, Let me get some details before I can help you. Please enter your name.'
    return response


st.title("""
Bowhead Bot  
Bowhead Bot's main functionality is to help you find the information about medical trials
""")

# if user_name and user_location and user_age:
#     response = botResponse(user_input, user_name, user_location, user_age, user_gender)

response = get_user_name()
if response:
    st.text_area("Bot:", value=response, height=200, max_chars=None, key=None)
user_input = get_text()
Ejemplo n.º 8
0
import streamlit as st

#텍스트 데이터 입력을 받을 경우
st.text_input("hello")

# 텍스트 데이터를 암호로 사용하고 싶은 경우에는 type='password' ㅊ 구ㅏ
st.text_input("password", type="password")

# 숫자를 입력하고 싶은 경우
st.number_input("nuber")

# 여러줄의 텍스트 데이터를 입력하고 싶은 경우
st.text_area("multi lines")

# 날짜를 입력하고 싶은 경우
st.date_input("date")

# 시간을 입력하고 싶은 경우
st.time_input("time")
Ejemplo n.º 9
0
def main():
    st.sidebar.title("Programas Presupuestales")
    t1 = st.sidebar.selectbox(label="Selecciona un Texto",
                              options=['Texto 1', 'Texto 2', 'Texto 3'])

    spacy_model = st.sidebar.selectbox("Modelo de Lenguaje",
                                       SPACY_MODEL_NAMES,
                                       index=1)
    model_load_state = st.info(
        "Cargando el Modelo de Lenguaje {}".format(spacy_model))
    nlp = load_model(spacy_model)
    model_load_state.empty()

    if t1 == 'Texto 1':
        text = st.text_area("Texto a analizar", TEXT1)
        st.text("Puedes editar el texto que se muestra arriba.")
    elif t1 == 'Texto 2':
        text = st.text_area("Texto a analizar", TEXT2)
        st.text("Puedes editar el texto que se muestra arriba.")
    elif t1 == 'Texto 3':
        text = st.text_area("Texto a analizar", TEXT3)
        st.text("Puedes editar el texto que se muestra arriba.")
    else:
        st.info("Error")

    doc = process_text(spacy_model, text)

    st.header("Mapa de Palabras")
    doc_input = process_text(spacy_model, text)
    List_Vect = []
    List_Vect_Text = []

    for s in doc_input:
        if s.has_vector:
            List_Vect_Text.append(s.text)
            List_Vect.append(s.vector)

    M = pd.DataFrame(List_Vect)
    L = pca.fit_transform(M)
    L2 = pd.DataFrame(L)
    L2['Text'] = List_Vect_Text

    L2.columns = ['Col_1', 'Col_2', 'Text']
    Plot_Text = ColumnDataSource(data=L2)
    p = figure(plot_width=400, plot_height=350, title="Mapa de Texto")
    p.scatter('Col_1', 'Col_2', source=Plot_Text, fill_alpha=0.6, size=10)
    p.legend.location = "top_left"
    labels = LabelSet(x='Col_1',
                      y='Col_2',
                      text='Text',
                      level='glyph',
                      text_font_size='9pt',
                      x_offset=5,
                      y_offset=5,
                      source=Plot_Text,
                      render_mode='canvas')
    p.add_layout(labels)
    st.bokeh_chart(p, use_container_width=True)
    st.text("Representación de las palabras en el plano")

    if "ner" in nlp.pipe_names:
        st.header("Entidades Reconocidas")
        st.sidebar.header("Entidades en el Modelo")

        #default_labels = ["PERSON", "ORG", "GPE", "LOC"]
        default_labels = nlp.pipe_labels['ner']
        labels = st.sidebar.multiselect("Tipo de Entidades",
                                        nlp.get_pipe("ner").labels,
                                        default_labels)
        html = displacy.render(doc, style="ent", options={"ents": labels})
        # Newlines seem to mess with the rendering
        html = html.replace("\n", " ")
        st.write(HTML_WRAPPER.format(html), unsafe_allow_html=True)
        attrs = ["text", "label_", "start", "end", "start_char", "end_char"]
        if "entity_linker" in nlp.pipe_names:
            attrs.append("kb_id_")
        data = [[str(getattr(ent, attr)) for attr in attrs] for ent in doc.ents
                if ent.label_ in labels]
        df = pd.DataFrame(data, columns=attrs)
        st.dataframe(df)

    st.header("Token y Atributos")

    if st.button("Mostrar atributos"):
        attrs = [
            "idx", "text", "lemma_", "pos_", "tag_", "dep_", "head",
            "ent_type_", "ent_iob_", "shape_", "is_alpha", "is_ascii",
            "is_digit", "is_punct", "like_num"
        ]
        data = [[str(getattr(token, attr)) for attr in attrs] for token in doc]
        df = pd.DataFrame(data, columns=attrs)
        st.dataframe(df)

    st.header("Vector")
    vector_size = nlp.meta.get("vectors", {}).get("width", 0)
    if vector_size:
        st.subheader("Vectores & Similaridad")
        #st.code(nlp.meta["vectors"])
        text1 = st.text_input("Oración o Palabra 1", text)
        text2 = st.text_input("Oración o Palabra 2",
                              "Transparencia Presupuestaria")
        doc1 = process_text(spacy_model, text1)
        doc2 = process_text(spacy_model, text2)
        similarity = doc1.similarity(doc2)
        if similarity > 0.5:
            st.success(similarity)
        else:
            st.error(similarity)
        st.text("Puedes editar los textos de las oraciones.")

    st.sidebar.header("Estadísticas Generales")

    if st.sidebar.checkbox(label="Mostrar", value=True):
        st.subheader("Estadísticas Generales")
        num_char, Nnoun_chunks, NToken, NVerbs, SinStopWords = statistic_text(
            text_input=text, nlp=nlp)
        Dic_Stat = {
            'Caracteres en la Sentencia': num_char,
            'Num Chunks': Nnoun_chunks,
            'Num Tokens': NToken,
            'Num Verbos': NVerbs,
            'Num de palabras sin StopWords': SinStopWords
        }
        st.write(Dic_Stat)

    if "parser" in nlp.pipe_names:
        st.header("Análisis del Texto & Part-of-speech tags")
        st.sidebar.header("Relación entre palabras")
        split_sents = st.sidebar.checkbox("División de sentencia", value=True)
        collapse_punct = st.sidebar.checkbox("Colapso de puntuación",
                                             value=True)
        collapse_phrases = st.sidebar.checkbox("Colapso de frases", value=True)
        dependencies = st.sidebar.checkbox("Dependencias")
        compact = st.sidebar.checkbox("Modo Compato")
        options = {
            "collapse_punct": collapse_punct,
            "collapse_phrases": collapse_phrases,
            "compact": compact,
            "dependecies": dependencies,
            "bg": "#121112",
            "color": "#ffffff",
            "font": "IBM Plex Sans"
        }
        docs = [span.as_doc() for span in doc.sents] if split_sents else [doc]
        for sent in docs:
            html = displacy.render(sent, options=options, style='dep')
            # Double newlines seem to mess with the rendering
            html = html.replace("\n\n", "\n")

        if split_sents and len(docs) > 1:
            st.markdown("> {}".format(sent.text))
        st.write(HTML_WRAPPER.format(html), unsafe_allow_html=True)
        st.text(
            "Desplazate a la derecha la barra gris para ver toda la imagen.")
        st.sidebar.info(
            "Si no se visualiza la imagen,prueba una a una las opciones.")
Ejemplo n.º 10
0
def main():
    local_css('style.css')
    remote_css('https://fonts.googleapis.com/icon?family=Material+Icons')

    input_type = st.sidebar.selectbox('Input Type:',
                                      ('URL', 'Raw Text', 'Upload File'))

    sum_level = st.sidebar.radio(
        "Output Length: ", ["Short (3 sentences)", "Medium (5 sentences)"])
    max_length = 3 if sum_level == "Short (3 sentences)" else 5

    st.markdown(
        "<h1 style='text-align: center;'>Fine-tune BERT for Extractive Summarization</h1>",
        unsafe_allow_html=True)

    # Load model
    model = load_model('bert_mlp')

    text = ""
    if input_type == "Raw Text":
        with open("./raw_data/input.txt") as f:
            sample_text = f.read()
        text = st.text_area("", sample_text, 400)
    elif input_type == "URL":
        url = st.text_input(
            "",
            "https://edition.cnn.com/2021/05/12/business/ransomware-attacks-banks-stock-exchanges/index.html"
        )
        st.markdown(
            f"<div class='original-news'><a href='{url}' target='_blank'>Read Original News</a></div>",
            unsafe_allow_html=True)
        text = crawl_url(url)
    else:
        docx_file = st.file_uploader("Upload File",
                                     type=['txt', 'docx', 'pdf'])
        if st.button("Process"):
            if docx_file is not None:
                if docx_file.type == "text/plain":
                    text = str(docx_file.read(), "utf-8")
                elif docx_file.type == "application/pdf":
                    try:
                        with pdfplumber.open(docx_file) as pdf:
                            page_numbers = len(pdf.pages)
                            for i in range(page_numbers):
                                page = pdf.pages[i]
                                text += " " + page.extract_text()
                    except:
                        st.write("None")
                elif docx_file.type == "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
                    text = docx2txt.process(docx_file)

                st.write(text)

    text_word_numbers = len(text.split())
    st.markdown(f"<div class='doc'>Document [{text_word_numbers} words]</div>",
                unsafe_allow_html=True)

    st.markdown(f"<hr>", unsafe_allow_html=True)
    with st.spinner('Wait for it...'):
        if text != "":
            input_fp = "./raw_data/input.txt"
            with open(input_fp, 'w') as file:
                file.write(text)

            result_fp = './results/summary.txt'
            summary = summarize(input_fp,
                                result_fp,
                                model,
                                max_length=max_length)

            summary_word_numbers = len(summary.split())
            st.markdown(
                f"<h3 style='text-align: center;'>Summary [{summary_word_numbers} words]</h3>",
                unsafe_allow_html=True)
            st.markdown(
                f"<div align='justify' class='summary alert alert-success'>{summary}</div>",
                unsafe_allow_html=True)
        else:
            st.markdown("<h3 style='text-align: center;'>Summary</h3>",
                        unsafe_allow_html=True)
Ejemplo n.º 11
0
    if item["_id"] not in [
            corrected_item["_id"] for corrected_item in session.corrected_items
    ]:
        break
    session.cursor += 1

# Interface
st.title("OFF spellcheck label tool")
st.info(
    f"{len(session.corrected_items)} items have been labelled ! Keep going ! :)"
)
st.subheader(f'Item id : {item["_id"]}')
st.subheader("Raw text")
st.write(f'```{item["ingredients_text_fr"]}```')
st.subheader("Correction")
correct = st.text_area("Type corrected text here",
                       value=format_percentages(item["ingredients_text_fr"]))
display_image(item["_id"])

TAGS = [
    "LABELLED_USING_IMAGE",
    "INCOMPLETE_INGREDIENTS_LIST",
    "MIXED_NUTRITION",
    "MIXED_OTHER",
    "MIXED_FOREIGN_LANGUAGE",
    "FOREIGN_LANGUAGE_ONLY",
    "TOO_NOISY",
    "NOT_INGREDIENTS_LIST",
]
tags = st.multiselect("Tags", TAGS)

if st.button("Submit"):
        model = load_model('movie_three.h5')

    with open('tokenizer.pickle', 'rb') as handle:
        tokenizer = pickle.load(handle)

    ans = tokenizer.texts_to_sequences([review])
    ans = pad_sequences(ans, maxlen=500)

    predictions = model.predict(ans)[0][0]

    return predictions


st.title('Analyse Movie Review')

review = st.text_area("Enter Your Review!")

if st.button("Predict with LSTM "):
    with st.spinner('Predicting.....'):
        prediction = predict(review, 1)

        if prediction >= 0.6:
            st.success('Positive Review!')
        elif prediction <= 0.4:
            st.error('Negative Review!')
        else:
            st.warning('Neutral, try again')
elif st.button("Predict with DNN "):
    with st.spinner('Predicting.....'):
        prediction = predict(review, 2)
Ejemplo n.º 13
0
    return tags

@st.cache(allow_output_mutation=True,ttl=60*5)
def load_data(file):
    dataframe_raw = pd.read_excel(file, keep_default_na=False).fillna('')
    return dataframe_raw

st.title("English Named Entity Recognition (NER) and Part-of-Speech (POS) tagger")
st.subheader("Created by: Stephan de Goede")

use_type = st.sidebar.radio("Please select the type of input you want to use",
                             ("Manually type a sentence","Automatically tag an Excel file"))

if use_type == "Manually type a sentence":
    st.subheader("Please type something in the box below")
    manual_user_input = st.text_area("")
    if len(manual_user_input)>0:
        manual_sentence = Sentence(manual_user_input)
        tagger.predict(manual_sentence)
        tagged_string = manual_sentence.to_tagged_string()
        st.success("Below is your tagged string.")
        st.write(tagged_string)
        for label in manual_sentence.labels:
            st.write(label)
        st.subheader("See table below for the meaning of the abbreviations")
        st.write (meanings)

elif use_type == "Automatically tag an Excel file":
    st.subheader("Please select your Excel to have it tagged")
    user_input = st.file_uploader("None of your data will be copied. Please be responsible and do not upload sensitive data.",type=['xlsx'],key='file_uploader')
    if user_input is not None:
Ejemplo n.º 14
0
def testWidget():
    # 按钮
    if st.button('Say hello'):
        st.write('Why hello there')
    else:
        st.write('Goodbye')
    # 复选框
    agree = st.checkbox('I agree')

    if agree:
        st.write('Great!')
    dicts = {"a": "a1", "b": "b1"}
    selected_layers = [
        layer for layer_name, layer in dicts.items()
        if st.sidebar.checkbox(layer_name, True)
    ]
    st.write(selected_layers)
    # 单选按钮
    genre = st.radio("What's your favorite movie genre",
                     ('Comedy', 'Drama', 'Documentary'))

    if genre == 'Comedy':
        st.write('You selected comedy.')
    else:
        st.write("You didn't select comedy.")
    # 下拉列表
    option = st.selectbox('How would you like to be contacted?',
                          ('Email', 'Home phone', 'Mobile phone'),
                          index=2)
    st.write('You selected:', option)
    # 多项列表
    options = st.multiselect(
        'What are your favorite colors',
        ['Yellow', 'Red', 'Green', 'Yellow', 'Red', 'Blue'])
    st.write('You selected:', options)
    # 滑块
    # 返回数值
    age = st.slider('How old are you?', 0, 130, 25)
    st.write("I'm ", age, 'years old')
    # 返回数值元组
    values = st.slider('Select a range of values', 0.0, 100.0, (25.0, 75.0))
    st.write('Values:', values)
    # 文本输入
    title = st.text_input('Movie title', 'Life of Brian')
    st.write('The current movie title is', title)
    # 数值输入
    number = st.number_input('Insert a number')
    st.write('The current number is ', number)
    # 多行文本输入
    txt = st.text_area(
        'Text to analyze',
        '''It was the best of times, it was the worst of times, it wasthe age of wisdom, it was the age of foolishness, it wasthe epoch of belief, it was the epoch of incredulity, (...)'''
    )
    st.write("Sentiment:", txt)
    # st.write('Sentiment:', run_sentiment_analysis(txt))
    # 日期输入
    import datetime
    d = st.date_input("When's your birthday", datetime.date(2019, 7, 6))
    st.write('Your birthday is:', d)
    # 时间输入
    t = st.time_input('Set an alarm for', datetime.time(8, 45))
    st.write('Alarm is set for', t)
    # 上传文件
    uploaded_file = st.file_uploader("Choose a CSV file", type=["csv", "txt"])
    if uploaded_file is not None:
        data = pd.read_csv(uploaded_file)
        st.write(data)
Ejemplo n.º 15
0
def main():

    st.title("NLPfy - Text Analytics Application")

    # Sidebar 1 (Information about NLP)
    if st.sidebar.checkbox("About NLP"):
        st.subheader("What is Natural Language Processing(NLP)?")
        st.write(
            "NLP is a branch of artificial intelligence that deals with analyzing, understanding and generating the languages that humans use naturally in order to interface with computers in both written and spoken contexts using natural human languages instead of computer languages."
        )

        img1 = Image.open("Images/1.jpg")
        st.image(img1, width=300)

        st.subheader("What is Natural Language Processing good for?")
        st.write(
            "1) Summarize blocks of text to extract the most important and central ideas while ignoring irrelevant information."
        )
        st.write(
            "2) Create a chat bot, a language parsing deep learning model used by big tech gaints."
        )
        st.write("3) Automatically generate keyword tags from content.")
        st.write(
            "4) Identify the type of entity extracted, such as it being a person, place, or organization using Named Entity Recognition."
        )
        st.write(
            "5) Use Sentiment Analysis to identify the sentiment of a string of text, from very negative to neutral to very positive."
        )

    # Sidebar 2 (Implementing those Algorithms)
    if st.sidebar.checkbox("Implement NLP Algos"):
        functions = [
            "Sentence Tokenizer", "Word Tokenizer and Lemmentizer",
            "Sentiment Analysis", "Text Summarizer", "NER Checker",
            "NER with url"
        ]
        choice = st.sidebar.selectbox("Choose NLP Function:", functions)

        # Sentence Tokenization
        if choice == "Sentence Tokenizer":

            st.subheader("Sentence Tokenization")

            if st.button("Description"):
                st.write(
                    "Sentence tokenization is the process of splitting text into individual sentences."
                )

                st.write(
                    "Why sentence tokenization is needed when we have the option of word tokenization? Imagine if we need to count average words per sentence, how will we calculate?"
                )
                st.write(
                    "For accomplishing such a task, we need both sentence tokenization as well as words to calculate the ratio. Such output serves as an important feature for machine training as the answer would be numeric."
                )

            message = st.text_area("Enter Text", "Type Here.")
            if st.button("Check Input Text"):
                st.write(message)
            if st.button("Tokenize Text"):
                nlp_result = sent_tkzn(message)
                st.json(nlp_result)

        # Word Tokenization and Lemmantization
        # https://www.machinelearningplus.com/nlp/lemmatization-examples-python/
        if choice == "Word Tokenizer and Lemmentizer":

            st.subheader("Word Tokenizer and Lemmentizer")
            if st.button("Description"):
                st.write(
                    "Word tokenization is the process of splitting text into individual words whereas Lemmatization is the process of converting a word to its base form. Another form similar to Lemmatization is Stemming. The difference between stemming and lemmatization is, lemmatization considers the context and converts the word to its meaningful base form, whereas stemming just removes the last few characters, often leading to incorrect meanings and spelling errors."
                )

            message = st.text_area("Enter Text", "Type Here.")
            if st.button("Tokenize  and Lemmantize Text"):
                nlp_result = text_analyzer(message)
                st.json(nlp_result)

        # Sentiment Analysis
        if choice == "Sentiment Analysis":

            st.subheader("Sentiment Analysis using textblob")

            if st.button("Description"):
                st.write(
                    "The sentiment function of textblob returns two properties, polarity, and subjectivity."
                )
                st.write(
                    "Polarity is float which lies in the range of [-1,1] where 1 means positive statement and -1 means a negative statement. Subjective sentences generally refer to personal opinion, emotion or judgment whereas objective refers to factual information. Subjectivity is also a float which lies in the range of [0,1]."
                )

            message = st.text_area("Enter Text", "Type Here.")
            if st.button("Analyze text"):
                blob = TextBlob(message)
                result = blob.sentiment
                st.success(result)

        # Text Summarization
        if choice == "Text Summarizer":

            st.header("Text Summarizer")

            if st.button("Description"):
                st.write(
                    "Text summarization refers to the technique of shortening long pieces of text."
                )
                st.write(
                    "There are two main types of how to summarize the text in NLP:"
                )
                st.write("1.Extraction-based summarization:")
                st.write(
                    "These methods rely on extracting several parts, such as phrases and sentences, from a piece of text and stack them together to create a summary. Therefore, identifying the right sentences for summarization is of utmost importance in an extractive method."
                )
                st.write("2.Abstractive-based summarization")
                st.write(
                    "These methods use advanced NLP and Deep learning techniques to generate an entirely new summary. Some parts of this summary may not even appear in the original text. The abstractive text summarization algorithms create new phrases and sentences that relay the most useful information from the original text — just like humans do. Therefore, abstraction performs better than extraction. However, the text summarization algorithms required to do abstraction are more difficult to develop; that’s why the use of extraction is still popular."
                )
                st.write("I've used Extraction based method.")

            message = st.text_area("Enter Text", "Type Here.")
            test_msg = message
            input_lines = len(test_msg.split('.'))
            if st.button("See Input Text"):
                st.write(message)
            if st.button("Total Input Lines"):
                st.success(input_lines)
            output_lines = st.slider("Select Number of lines in Summary:", 1,
                                     10)
            if st.button("Summarize text"):
                nlp_result = text_summarizer(message, output_lines)
                st.success(nlp_result)

        # NER Checker
        if choice == "NER Checker":

            st.header("Named entity recognition")
            if st.button("Description"):
                st.write(
                    "Named entity recognition (NER)is probably the first step towards information extraction that seeks to locate and classify named entities in text into pre-defined categories such as the names of persons, organizations, locations, expressions of times, quantities, monetary values, percentages, etc. NER is used in many fields in Natural Language Processing (NLP), and it can help answering many real-world questions, such as:"
                )

                st.write(
                    "1) Which companies were mentioned in the news article?")
                st.write(
                    "2) Were specified products mentioned in complaints or reviews?"
                )
                st.write(
                    "3) Does the tweet contain the name of a person? Does the tweet contain this person’s location?"
                )

            message = st.text_area("Enter Text", "Type Here.")
            if st.button("Analyze"):
                docx = analyze_text(message)
                html = displacy.render(docx, style='ent')
                html = html.replace("\n\n", "\n")
                st.write(html, unsafe_allow_html=True)

            if st.button("Extract Entities Code"):
                img2 = Image.open("Images/2.PNG")
                st.image(img2, width=800)

        # Named entity checker with url
        if choice == "NER with url":

            st.subheader("Analyze text from url")
            raw_url = st.text_input("Enter URL", "Type Here.")
            text_length = st.slider("Lenght to preview", 50, 100)
            if st.button("Extract"):
                if raw_url != "Type Here.":
                    result = get_text(raw_url)
                    #text_length = len(result)
                    #preview_length = st.slider("Lenght to preview", 1, text_length)
                    lft = len(result)
                    lst = round(len(result) / text_length)
                    summary_docx = text_summarizer(result, 5)
                    docx = analyze_text(summary_docx)
                    html = displacy.render(docx, style='ent')
                    html = html.replace("\n\n", "\n")
                    st.write(html, unsafe_allow_html=True)

    # Sidebar 3 (Credits)
    st.sidebar.header("About")
    st.sidebar.text("By Rohit Mahajan")
    st.sidebar.text("3rd Year UG at IIT-Kharagpur")
    st.sidebar.text("*****@*****.**")
Ejemplo n.º 16
0
=======
        "3 Mar 2022, Chinese Swimming Club, 1 hour",    
        "23 Mar 2022, Clementi Sports Hall, 1 hour",
>>>>>>> Stashed changes
        "17 Feb 2022, Chinese Swimming Club, 1 hour", 
        "7 Feb 2022, Clementi Sports Hall, 1 hour"]
    ) #, index=2
    
#    bug_severity = cols[1].slider("Bug severity:", 1, 5, 2)
#    courts = cols[1].selectbox("Paid for Court Booking?",["No.","Yes and attended session.", "Yes but did not attend session."])
    shuttles_contributed = cols[0].selectbox("Shuttlecocks Contributed:",[0,1,2,3,4,5])
    attendance= cols[1].selectbox("Attended session:",["Yes","No"])
    court_payment = cols[1].selectbox("Paid for court booking:",["No","Yes"])
    
#    hours = cols[1].selectbox("Length of Session (in hours):",[1,2])
    comments = st.text_area("Remarks if any:")
    submitted = st.form_submit_button(label="Submit")

if submitted:
 #    st.write(datetime.now(tz=None))
     timestmp=datetime.now(tz=None)
     add_row_to_gsheet(
         gsheet_connector, [[player_name, session_name, shuttles_contributed, attendance, court_payment, comments,str(timestmp)]]
     )

     st.success("Thanks! Your participation has been recorded.")
     st.balloons()
     #st.write(session_name)


Ejemplo n.º 17
0
#sentence='What is the average age of students whose name is Doe or age over 25?'
#sentence='Show the average age of students whose name is Doe or age over 25?'
#sentence='Find the average age of students whose name is Doe or age over 25?'
#sentence='who is the manufacturer of the order year 1998?'
#TypesOfQueries=['Select','Create','Insert','Delete']
#options=st.selectbox("Type of query",TypesOfQueries)
#st.write("You selected: ",options)

model = ntc.evaluate(test)
#st.markdown("**Chunk Accuracy**")
#st.write("Accuracy: ",model.accuracy())
#st.write("Precision: ",model.precision())
#st.write("Recall: ",model.recall())
#st.write("F-Measure: ",model.f_measure())
sentence = st.text_area(
    "Enter the text below",
    "What is the name and age of students whose name is Doe or age can be 25?")
if st.button("Click for SQL query"):

    if len(sentence) == 0:
        st.markdown("**Enter the sentence**")
    else:
        # REMOVE SPECIAL CHARACTERS
        st.markdown("**The sentence is:**")
        st.write(sentence)
        for char in string.punctuation:
            if char == "'":
                continue
            elif char == '"':
                continue
            else:
from sklearn.metrics import accuracy_score, confusion_matrix, f1_score
from sklearn.decomposition import PCA
import pandas as pd
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.linear_model import LogisticRegression
from sklearn import metrics
from PIL import Image
from sklearn.model_selection import train_test_split
# import matplotlib.pyplot as plt

import numpy as np
st.write("""
## Who will win this game?
""")

interview = st.text_area("Interview content:", "I am going to win because I am the best")

# filename = st.sidebar.file_uploader('Upload the interview here:')

filename_numerical_predict = st.sidebar.file_uploader('Upload numerical data of this match here:')

player = st.sidebar.text_input("Player", "Federer")

opponent = st.sidebar.text_input("Opponent", "Nadal")

dataset_type = st.sidebar.selectbox("Select Analysis Type:",("-","Text Analysis","Magical Text Analysis","Numerical Analysis", "Text and Numerical Analysis"))

# dataset_type = st.sidebar.selectbox("Select Type:",("Not Pierre","Text Analysis", "Numerical Analysis", "Text and Numerical Analysis","Classification","Regression"))


def get_dataset(dataset_name):
Ejemplo n.º 19
0
    precision = [p1, p2, pl]
    recall = [r1, r2, rl]
    f1 = [f11, f12, f1l]
    df = pd.DataFrame(list(zip(precision, recall, f1)),
                      columns=["Precision", "Recall", "F-1 Score"],
                      index=["ROUGE-1", "ROUGE-2", "ROUGE-L"])
    st.subheader("ROUGE Scores")
    st.table(df)


url = st.text_input('\nEnter URL of news article from The Hindu Newspaper: ')

wikiurl = st.text_input('\nEnter URL of Wikipedia article: ')
video_id = st.text_input("\nEnter the Youtube Video Id:")
# video_id = "Na8vHaCLwKc"
textfield123 = st.text_area(
    '\nEnter article or paragraph you want to summarize ')
no_of_sentences = st.number_input(
    'Choose the no. of sentences in the summary:', min_value=1)


def textfunc():

    content = textfield123
    content = sanitize_input(content)

    text = re.sub(r'\[[0-9]*\]', ' ', content)
    text = re.sub(r'\s+', ' ', text)

    st.subheader('Original text: ')
    st.write(text)
def main():
	"""Sentiment Analysis Web App """

	st.title("Sentiment Analysis Web App")

	activities = ["Sentiment","Text Analysis from URL","About"]
	choice = st.sidebar.selectbox("Choice",activities)

	# Choice = Sentiment
	if choice == 'Sentiment':
		st.subheader("Sentiment Analysis")
		#st.write(emoji.emojize('Everyone :red_heart: Streamlit ',use_aliases=True))
		raw_text = st.text_area("Enter Your Text","Type Here")
		if st.button("Analyze"):
			blob = TextBlob(raw_text)
			result = blob.sentiment.polarity
			result2 = (1-result)
			result3 = (result+1)
			if result > 0.0:
				labels = ['Happy','Sad']
				values = [result, result2]
			elif result < 0.0:
				labels = ['Happy','Sad']
				values = [result3, abs(result)]
			elif result == 0.0:
				labels = ['Neutral','Happy','Sad']
				values = [100,0,0]
			fig = go.Figure(data=[go.Pie(labels=labels, values=values, pull=[0, 0, 0.2, 0])])

			if result > 0.0:
				custom_emoji = ':smile:'
				st.markdown('Sentiment :: {}'.format(custom_emoji))
			elif result < 0.0:
				custom_emoji = ':disappointed:'
				st.markdown('Sentiment :: {}'.format(custom_emoji))
			else:
				custom_emoji = ':expressionless:'
				st.markdown('Sentiment :: {}'.format(custom_emoji))

			st.info("Polarity Score is:: {}".format(result))
			st.write(result)
			st.plotly_chart(fig)
	
	# Choice Text Analysis
	if choice == 'Text Analysis from URL':
		st.subheader("Analysis on Text From URL")
		raw_url = st.text_input("Enter URL Here","Type here")
		text_preview_length = st.slider("Length to Preview",50,100)
		if st.button("Analyze"):
			if raw_url != "Type here":
				result = get_text(raw_url)
				blob = TextBlob(result)
				len_of_full_text = len(result)
				len_of_short_text = round(len(result)/text_preview_length)
				st.success("Length of Full Text::{}".format(len_of_full_text))
				st.success("Length of Short Text::{}".format(len_of_short_text))
				st.info(result[:len_of_short_text])
				c_sentences = [ sentences for sentence in blob.sentences]
				c_sentiment = [sentences.sentiment.polarity for sentences in blob.sentences]

				# Dataframe
				new_df = pd.DataFrame(zip(c_sentences,c_sentiment),columns=['Sentence','Sentiment'])
				st.dataframe(new_df)

				#Plot 
				st.write(new_df.head(20).plot(kind='bar'))
				st.pyplot()
				st.write(new_df.dtypes)
				result_avg = round(np.mean(c_sentiment, axis = 0),3)
				st.write(result_avg)
				st.markdown('##### Average Sentiment of Complete Text')
				if result_avg > 0.0:
					custom_emoji = ':smile:'
					st.markdown('Sentiment :: {}'.format(custom_emoji))
				elif result_avg < 0.0:
					custom_emoji = ':disappointed:'
					st.markdown('Sentiment :: {}'.format(custom_emoji))
				else:
					custom_emoji = ':expressionless:'
					st.markdown('Sentiment :: {}'.format(custom_emoji))

			st.info("Average polarity Score is:: {}".format(result_avg))

	# Choice Abou
	if choice == 'About':
		st.subheader("About")
		st.markdown("""
			#### Sentiment Analysis Web App
			##### Built with Streamlit

			#### By
			+ Hrishikesh Sharad Malkar
			+ References: Jesus Saves@[JCharisTech](https://jcharistech.com)

			""")
Ejemplo n.º 21
0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import streamlit as st

i1 = st.text_area("text area 1")
st.write('value 1: "', i1, '"')

i2 = st.text_area("text area 2", "default text")
st.write('value 2: "', i2, '"')

i3 = st.text_area("text area 3", 1234)
st.write('value 3: "', i3, '"')

i4 = st.text_area("text area 4", None)
st.write('value 4: "', i4, '"')

i5 = st.text_area("text area 5", max_chars=10)
st.write('value 5: "', i5, '"')

i6 = st.text_area("text area 6", placeholder="Placeholder")
Ejemplo n.º 22
0
    cv.fit(reviews_train_clean)
    X = cv.transform(reviews_train_clean)
    X_test = cv.transform(reviews_test_clean)

    return X, X_test, reviews_test


X, X_test, reviews_test = read_file()


logicregression = joblib.load('final_model.pkl')

ram = randint(0,25000)


comment = st.text_area("Type your own comments here", value=reviews_test[ram], height=350)


st.subheader('prediction')

if logicregression.predict(X_test[ram]) == 0:
    prediction = 'Negative'
else:
    prediction = 'Positive'

target = [1 if i < 12500 else 0 for i in range(25000)]

st.text(prediction)

st.subheader('True label')
Ejemplo n.º 23
0
import matplotlib.pyplot as plt
from sklearn.ensemble import RandomForestClassifier

# Import python files we've created to help
from nlp import *
from data_cleaning import *
from classification import *
from visualizations import *

# Load the small English model
nlp = en_core_web_sm.load()

st.title('Customer Conversation Classifier')
st.subheader('Learn how your customers feel about your products')

txt = st.text_area(
    'Paste text from customer here (product review, tweet, etc):', '')

if (st.button('Let me know!')):
    score = sentiment_analyzer_scores(txt)

    clf_forest = pickle.load(open("../models/save.forest", "rb"))

    X_txt = pd.DataFrame({'review_fulltext': [txt]})
    X_txt = append_sentiment_scores(X_txt)

    # if txt.strip() == '':
    if (X_txt['compound'][0] >= -.05) & (X_txt['compound'][0] <= .05):
        y_pred = 0.5
        msg = "Very neutral customer comment. I really can't call it."
    else:
        y_pred = clf_forest.predict(X_txt.drop(columns='review_fulltext'))[0]
Ejemplo n.º 24
0
input_size = data["input_size"]
hidden_size = data["hidden_size"]
output_size = data["output_size"]
all_words = data['all_words']
tags = data['tags']
model_state = data["model_state"]

model = NeuralNet(input_size, hidden_size, output_size).to(device)
model.load_state_dict(model_state)
model.eval()

bot_name = "Covibot"
st.markdown("<h1>Ask Covibot any Questions Related to COVID-19!</h1>",
            unsafe_allow_html=True)
z = 0
sentence = st.text_area('You:')
if sentence:
    sentence = tokenize(sentence)
    X = bag_of_words(sentence, all_words)
    X = X.reshape(1, X.shape[0])
    X = torch.from_numpy(X).to(device)

    output = model(X)
    _, predicted = torch.max(output, dim=1)

    tag = tags[predicted.item()]

    probs = torch.softmax(output, dim=1)
    prob = probs[0][predicted.item()]
    z = 0
    if prob.item() > 0.75:
Ejemplo n.º 25
0
def calc_main():
    st.write("Nimbus Words")   
    st.sidebar.header("Input Options") 

    activites = ["Summary", "Tokenizer","Synonyms","Translator","Search","Spell Correction"]
    choice = st.sidebar.selectbox("Select Activity",activites)
    if choice == "Summary":
        st.title('AI Text Summarizer')
        text = st.text_area("Input Text For Summary",height=300)
        if st.button("summarize"):
            st.success(summary(text))
        text_range= st.sidebar.slider("Summarize words Range",25,500)
        text = st.text_area("Input Text For Summary",height=250)
        if st.button("custom summarization"):
           st.warning(summarize(text,word_count=text_range))
    # Tokenizer
    elif choice == "Tokenizer":
        st.title('Text Tokenizer')
        row_data = st.text_area("write Text For Tokenizer")
        docx= nlp(row_data)
        if st.button("Tokenizer"):
            spacy_streamlit.visualize_tokens(docx,attrs=['text','pos_','dep_','ent_type_'])
        if st.button("NER"):
            spacy_streamlit.visualize_ner(docx,labels=nlp.get_pipe('ner').labels)
        if st.button("Text Relationship"):
            spacy_streamlit.visualize_parser(docx)
       # synonyms      
    elif choice == "Synonyms":
        st.title('Synonym Generator')
        text = st.text_area("Enter Text")
        if st.button("Find"):
            for syn in wordnet.synsets(text):
                for i in syn.lemmas():
                    st.success(i.name())
        if st.checkbox("Defination"):
            for syn in wordnet.synsets(text):
                st.warning(syn.definition()) 
        if st.checkbox("Example"):
            for syn in wordnet.synsets(text):
                st.success(syn.examples())
      # Translator          
    elif choice == "Translator":
        st.title('Speech Tranlation')
        row_text = st.text_area("Enter Your Text For Translation",height=300)
        translation_text = TextBlob(row_text)
        list1 = ["en","ta","pa","gu","hi","ur","kn","bn","te"]
        a= st.selectbox("select",list1)
        if st.button("search"):
            #input1 = TextBlob("Simple is better than complex")
            st.success(translation_text.translate(to=a))
    #Search Bar
    elif choice == "Search":
        st.title('Web Search')
        row_text= st.text_input("Search Anything")
        google = Google(license=None)
        if st.button("search"):
            for search_result in google.search(row_text):
                st.write(search_result.text)
                st.warning(search_result.url)
    elif choice == "Spell Correction":
        st.title('AI Spell Correction')
        text_data = st.text_area("Enter Text Here")
        a = TextBlob(text_data)
        if st.button("Correct"):
            st.success(a.correct())
        st.title('Pluralize & Singularize')
        text_data1 = st.text_input("Enter a word For pluralize / singularize")
        if st.checkbox("pluralize"):
            st.warning(pluralize(text_data1))
        if st.checkbox("singularize"):
            st.warning(singularize(text_data1))
        
        st.title('Compartitive & Superlative')
        text2 = st.text_input("Enter Text For comparative & superlative")
        if st.checkbox("comparative"):
            st.success(comparative(text2))
        if st.checkbox("superlative"):
            st.success(superlative(text2))
Ejemplo n.º 26
0
def main():
    st.title("NLP App with Streamlit")
    st.markdown(
        "Welcome! This is a simple NLP application created using Streamlit and deployed on Heroku."
    )
    st.markdown(
        "In the box below, you can type custom text or paste an URL from which text is extracted. Once you have a the text, open the sidebar and choose any of the four applications. Currently, we have applications to tokenize text, extract entitiles, analyze sentiment, and summarize text (and a suprise! :wink:)."
    )
    st.markdown(
        "You can preview a percentage of your text by selecting a value on the slider and clicking on \"Preview\""
    )

    nlp = load_spacy()

    text = fetch_text(
        st.text_area(
            "Enter Text (or URL) and select application from sidebar",
            "Here is some sample text. When inputing your custom text or URL make sure you delete this text!"
        ))

    pct = st.slider("Preview length (%)", 0, 100)
    length = (len(text) * pct) // 100
    preview_text = text[:length]

    if st.button("Preview"):
        st.write(preview_text)

    apps = [
        'Show tokens & lemmas', 'Extract Entities', 'Show sentiment',
        'Summarize text', 'Suprise'
    ]
    choice = st.sidebar.selectbox("Select Application", apps)
    if choice == "Show tokens & lemmas":
        if st.button("Tokenize"):
            st.info("Using spaCy for tokenization and lemmatization")
            st.json([(f"Token: {token.text}, Lemma: {token.lemma_}")
                     for token in analyze_text(nlp, text)])
    elif choice == 'Extract Entities':
        if st.button("Extract"):
            st.info("Using spaCy for NER")
            doc = analyze_text(nlp, text)
            html = displacy.render(doc, style='ent')
            html = html.replace('\n\n', '\n')
            st.write(html, unsafe_allow_html=True)
    elif choice == "Show sentiment":
        if st.button("Analyze"):
            st.info("Using TextBlob for sentiment analysis")
            blob = TextBlob(text)
            sentiment = {
                'polarity': np.round(blob.sentiment[0], 3),
                'subjectivity': np.round(blob.sentiment[1], 3),
            }
            st.write(sentiment)
            st.info(
                "Polarity is between -1 (negative) and 1 (positive) indicating the type of sentiment\nSubjectivity is between 0 (objective) and 1 (subjective) indicating the bias of the sentiment"
            )
    elif choice == "Summarize text":
        summarizer_type = st.sidebar.selectbox("Select Summarizer",
                                               ['Gensim', 'Sumy Lex Rank'])
        if summarizer_type == 'Gensim':
            summarizer = gensim_summarizer
        elif summarizer_type == 'Sumy Lex Rank':
            summarizer = sumy_summarizer

        if st.button(f"Summarize using {summarizer_type}"):
            st.success(summarizer(text))
    elif choice == 'Suprise':
        st.balloons()

    st.markdown(
        "The code for this app can be found in [this](https://github.com/sudarshan85/streamlit_nlp) Github repository."
    )
# Slider
salary = st.slider("What is your salary", 1000, 10000)

# Buttons
st.button("Simple Button")

# Text Input
name = st.text_input("Enter Name", "Type Here...")
if st.button('Submit'):
    result = name.title()
    st.success(result)
else:
    st.write("Press the above button..")

# Text Area
c_text = st.text_area("Enter Text", "Type Here...")
if st.button('Analyze'):
    c_result = c_text.title()
    st.success(c_result)
else:
    st.write("Press the above button..")

#  Date Input
import datetime, time
today = st.date_input("Today is", datetime.datetime.now())

# Time Input
t = st.time_input("The time now is", datetime.time())

# SIDE Bar
st.sidebar.header("Side Bar Header")
Ejemplo n.º 28
0
def draw_all(
    key,
    plot=False,
):
    st.write(
        """
        # Example Widgets
        
        These widgets don't do anything. But look at all the new colors they got 👀 
    
        ```python
        # First some code.
        streamlit = "cool"
        theming = "fantastic"
        both = "💥"
        ```
        """
    )

    st.checkbox("Is this cool or what?", key=key)
    st.radio(
        "How many balloons?",
        ["1 balloon 🎈", "2 balloons 🎈🎈", "3 balloons 🎈🎈🎈"],
        key=key,
    )
    st.button("🤡 Click me", key=key)

    # if plot:
    #     st.write("Oh look, a plot:")
    #     x1 = np.random.randn(200) - 2
    #     x2 = np.random.randn(200)
    #     x3 = np.random.randn(200) + 2

    #     hist_data = [x1, x2, x3]
    #     group_labels = ["Group 1", "Group 2", "Group 3"]

    #     fig = ff.create_distplot(hist_data, group_labels, bin_size=[0.1, 0.25, 0.5])

    #     st.plotly_chart(fig, use_container_width=True)

    st.file_uploader("You can now upload with style", key=key)
    st.slider(
        "From 10 to 11, how cool are themes?", min_value=10, max_value=11, key=key
    )
    # st.select_slider("Pick a number", [1, 2, 3], key=key)
    st.number_input("So many numbers", key=key)
    st.text_area("A little writing space for you :)", key=key)
    st.selectbox(
        "My favorite thing in the world is...",
        ["Streamlit", "Theming", "Baloooons 🎈 "],
        key=key,
    )
    # st.multiselect("Pick a number", [1, 2, 3], key=key)
    # st.color_picker("Colors, colors, colors", key=key)
    with st.beta_expander("Expand me!"):
        st.write("Hey there! Nothing to see here 👀 ")
    st.write("")
    # st.write("That's our progress on theming:")
    # st.progress(0.99)
    if plot:
        st.write("And here's some data and plots")
        st.json({"data": [1, 2, 3, 4]})
        st.dataframe({"data": [1, 2, 3, 4]})
        st.table({"data": [1, 2, 3, 4]})
        st.line_chart({"data": [1, 2, 3, 4]})
        # st.help(st.write)
    st.write("This is the end. Have fun building themes!")
Ejemplo n.º 29
0
import streamlit as st

st.header('Rangkuman Cerpen')
st.text('powered by BERT')

os.environ['KMP_DUPLICATE_LIB_OK'] = 'True'

tokenizer = BertTokenizer.from_pretrained(
    "cahya/bert2bert-indonesian-summarization")
tokenizer.bos_token = tokenizer.cls_token
tokenizer.eos_token = tokenizer.sep_token
model = EncoderDecoderModel.from_pretrained(
    "cahya/bert2bert-indonesian-summarization")

#
ARTICLE_TO_SUMMARIZE = st.text_area(
    "Masukkan cerpen yang ingin diringkas (max 512 token)")

# generate summary
input_ids = tokenizer.encode(ARTICLE_TO_SUMMARIZE, return_tensors='pt')
summary_ids = model.generate(input_ids,
                             min_length=20,
                             max_length=80,
                             num_beams=10,
                             repetition_penalty=2.5,
                             length_penalty=1.0,
                             early_stopping=True,
                             no_repeat_ngram_size=2,
                             use_cache=True,
                             do_sample=True,
                             temperature=0.8,
                             top_k=50,
Ejemplo n.º 30
0
    def Question_Answer(qna):
        user_answer = ["i"]
        questions = [sub["question"] for sub in qna]
        answers = [sub["answer"] for sub in qna]
        if len(questions) == 1:
            st.write(questions[0])
            user_answer_1 = st.text_area("Enter the Answer:", height=2, key=1)
            submission = st.button("Submit", key=1)
            if submission:
                user_answer.append(user_answer_1)
                user_answer.pop(0)
                correct_wrong = get_similarity([answers[0]], user_answer)
                total_marks = (sum(correct_wrong) / len(correct_wrong)) * 100
                st.write("Awesome!!!", str(total_marks))
            if 0 in correct_wrong:
                st.write(
                    "You have done some mistakes, here is where you went wrong..."
                )
                for boolean in correct_wrong:
                    if boolean == 0:
                        st.write("Mistaken Question:", questions[0])
                        st.write("Correct answer: ", answers[0])
                    else:
                        pass
            else:
                st.balloons()

        elif len(questions) == 2:
            st.write(questions[0])
            user_answer_1 = st.text_area("Enter the Answer:", height=2, key=1)
            st.write(questions[1])
            user_answer_2 = st.text_area("Enter the Answer:", height=2, key=2)
            submission = st.button("Submit", key=1)
            if submission:
                user_answer.extend([user_answer_1, user_answer_2])
                user_answer.pop(0)
                correct_wrong = get_similarity(answers, user_answer)
                total_marks = (sum(correct_wrong) / len(correct_wrong)) * 100
                st.write("Awesome!!!", str(total_marks))
            i = 0
            if 0 in correct_wrong:
                st.write(
                    "You have done some mistakes, here is where you went wrong..."
                )
                for i in range(len(correct_wrong)):
                    if correct_wrong[i] == 0:
                        st.write("Mistaken Question:", questions[i])
                        st.write("Correct answer: ", answers[i])
                    else:
                        pass
            else:
                st.balloons()

        elif len(questions) == 3:
            st.write(questions[0])
            user_answer_1 = st.text_area("Enter the Answer:", height=2, key=1)
            st.write(questions[1])
            user_answer_2 = st.text_area("Enter the Answer:", height=2, key=2)
            st.write(questions[2])
            user_answer_3 = st.text_area("Enter the Answer:", height=2, key=3)
            submission = st.button("Submit", key=1)
            if submission:
                user_answer.extend(
                    [user_answer_1, user_answer_2, user_answer_3])
                user_answer.pop(0)
                correct_wrong = get_similarity(answers, user_answer)
                total_marks = (sum(correct_wrong) / len(correct_wrong)) * 100
                st.write("Awesome!!!", str(total_marks))
            i = 0
            if 0 in correct_wrong:
                st.write(
                    "You have done some mistakes, here is where you went wrong..."
                )
                for i in range(len(correct_wrong)):
                    if correct_wrong[i] == 0:
                        st.write("Mistaken Question:", questions[i])
                        st.write("Correct answer: ", answers[i])
                    else:
                        pass
            else:
                st.balloons()

        elif len(questions) == 4:
            st.write(questions[0])
            user_answer_1 = st.text_area("Enter the Answer:", height=2, key=1)
            st.write(questions[1])
            user_answer_2 = st.text_area("Enter the Answer:", height=2, key=2)
            st.write(questions[2])
            user_answer_3 = st.text_area("Enter the Answer:", height=2, key=3)
            st.write(questions[3])
            user_answer_4 = st.text_area("Enter the Answer:", height=2, key=4)
            submission = st.button("Submit", key=1)
            if submission:
                user_answer.extend([
                    user_answer_1, user_answer_2, user_answer_3, user_answer_4
                ])
                user_answer.pop(0)
                correct_wrong = get_similarity(answers, user_answer)
                total_marks = (sum(correct_wrong) / len(correct_wrong)) * 100
                st.write("Awesome!!!", str(total_marks))
            i = 0
            if 0 in correct_wrong:
                st.write(
                    "You have done some mistakes, here is where you went wrong..."
                )
                for i in range(len(correct_wrong)):
                    if correct_wrong[i] == 0:
                        st.write("Mistaken Question:", questions[i])
                        st.write("Correct answer: ", answers[i])
                    else:
                        pass
            else:
                st.balloons()

        elif len(questions) == 5:
            st.write(questions[0])
            user_answer_1 = st.text_area("Enter the Answer:", height=2, key=1)
            st.write(questions[1])
            user_answer_2 = st.text_area("Enter the Answer:", height=2, key=2)
            st.write(questions[2])
            user_answer_3 = st.text_area("Enter the Answer:", height=2, key=3)
            st.write(questions[3])
            user_answer_4 = st.text_area("Enter the Answer:", height=2, key=4)
            st.write(questions[4])
            user_answer_5 = st.text_area("Enter the Answer:", height=2, key=5)
            submission = st.button("Submit", key=1)
            if submission:
                user_answer.extend([
                    user_answer_1, user_answer_2, user_answer_3, user_answer_4,
                    user_answer_5
                ])
                user_answer.pop(0)
                correct_wrong = get_similarity(answers, user_answer)
                total_marks = (sum(correct_wrong) / len(correct_wrong)) * 100
                st.write("Awesome!!!", str(total_marks))
            i = 0
            if 0 in correct_wrong:
                st.write(
                    "You have done some mistakes, here is where you went wrong..."
                )
                for i in range(len(correct_wrong)):
                    if correct_wrong[i] == 0:
                        st.write("Mistaken Question:", questions[i])
                        st.write("Correct answer: ", answers[i])
                    else:
                        pass
            else:
                st.balloons()

        elif len(questions) == 6:
            st.write(questions[0])
            user_answer_1 = st.text_area("Enter the Answer:", height=2, key=1)
            st.write(questions[1])
            user_answer_2 = st.text_area("Enter the Answer:", height=2, key=2)
            st.write(questions[2])
            user_answer_3 = st.text_area("Enter the Answer:", height=2, key=3)
            st.write(questions[3])
            user_answer_4 = st.text_area("Enter the Answer:", height=2, key=4)
            st.write(questions[4])
            user_answer_5 = st.text_area("Enter the Answer:", height=2, key=5)
            st.write(questions[5])
            user_answer_6 = st.text_area("Enter the Answer:", height=2, key=6)
            submission = st.button("Submit", key=1)
            if submission:
                user_answer.extend([
                    user_answer_1, user_answer_2, user_answer_3, user_answer_4,
                    user_answer_5, user_answer_6
                ])
                user_answer.pop(0)
                correct_wrong = get_similarity(answers, user_answer)
                total_marks = (sum(correct_wrong) / len(correct_wrong)) * 100
                st.write("Awesome!!!", str(total_marks))
            i = 0
            if 0 in correct_wrong:
                st.write(
                    "You have done some mistakes, here is where you went wrong..."
                )
                for i in range(len(correct_wrong)):
                    if correct_wrong[i] == 0:
                        st.write("Mistaken Question:", questions[i])
                        st.write("Correct answer: ", answers[i])
                    else:
                        pass
            else:
                st.balloons()

        elif len(questions) == 7:
            st.write(questions[0])
            user_answer_1 = st.text_area("Enter the Answer:", height=2, key=1)
            st.write(questions[1])
            user_answer_2 = st.text_area("Enter the Answer:", height=2, key=2)
            st.write(questions[2])
            user_answer_3 = st.text_area("Enter the Answer:", height=2, key=3)
            st.write(questions[3])
            user_answer_4 = st.text_area("Enter the Answer:", height=2, key=4)
            st.write(questions[4])
            user_answer_5 = st.text_area("Enter the Answer:", height=2, key=5)
            st.write(questions[5])
            user_answer_6 = st.text_area("Enter the Answer:", height=2, key=6)
            st.write(questions[6])
            user_answer_7 = st.text_area("Enter the Answer:", height=2, key=7)
            submission = st.button("Submit", key=1)
            if submission:
                user_answer.extend([
                    user_answer_1, user_answer_2, user_answer_3, user_answer_4,
                    user_answer_5, user_answer_6, user_answer_7
                ])
                user_answer.pop(0)
                correct_wrong = get_similarity(answers, user_answer)
                total_marks = (sum(correct_wrong) / len(correct_wrong)) * 100
                st.write("Awesome!!!", str(total_marks))
            i = 0
            if 0 in correct_wrong:
                st.write(
                    "You have done some mistakes, here is where you went wrong..."
                )
                for i in range(len(correct_wrong)):
                    if correct_wrong[i] == 0:
                        st.write("Mistaken Question:", questions[i])
                        st.write("Correct answer: ", answers[i])
                    else:
                        pass
            else:
                st.balloons()

        elif len(questions) == 8:
            st.write(questions[0])
            user_answer_1 = st.text_area("Enter the Answer:", height=2, key=1)
            st.write(questions[1])
            user_answer_2 = st.text_area("Enter the Answer:", height=2, key=2)
            st.write(questions[2])
            user_answer_3 = st.text_area("Enter the Answer:", height=2, key=3)
            st.write(questions[3])
            user_answer_4 = st.text_area("Enter the Answer:", height=2, key=4)
            st.write(questions[4])
            user_answer_5 = st.text_area("Enter the Answer:", height=2, key=5)
            st.write(questions[5])
            user_answer_6 = st.text_area("Enter the Answer:", height=2, key=6)
            st.write(questions[6])
            user_answer_7 = st.text_area("Enter the Answer:", height=2, key=7)
            st.write(questions[7])
            user_answer_8 = st.text_area("Enter the Answer:", height=2, key=8)
            submission = st.button("Submit", key=1)
            if submission:
                user_answer.extend([
                    user_answer_1, user_answer_2, user_answer_3, user_answer_4,
                    user_answer_5, user_answer_6, user_answer_7, user_answer_8
                ])
                user_answer.pop(0)
                correct_wrong = get_similarity(answers, user_answer)
                total_marks = (sum(correct_wrong) / len(correct_wrong)) * 100
                st.write(total_marks)
            i = 0
            if 0 in correct_wrong:
                st.write(
                    "You have done some mistakes, here is where you went wrong..."
                )
                for i in range(len(correct_wrong)):
                    if correct_wrong[i] == 0:
                        st.write("Mistaken Question:", questions[i])
                        st.write("Correct answer: ", answers[i])
                    else:
                        pass
            else:
                st.balloons()

        elif len(questions) == 9:
            st.write(questions[0])
            user_answer_1 = st.text_area("Enter the Answer:", height=2, key=1)
            st.write(questions[1])
            user_answer_2 = st.text_area("Enter the Answer:", height=2, key=2)
            st.write(questions[2])
            user_answer_3 = st.text_area("Enter the Answer:", height=2, key=3)
            st.write(questions[3])
            user_answer_4 = st.text_area("Enter the Answer:", height=2, key=4)
            st.write(questions[4])
            user_answer_5 = st.text_area("Enter the Answer:", height=2, key=5)
            st.write(questions[5])
            user_answer_6 = st.text_area("Enter the Answer:", height=2, key=6)
            st.write(questions[6])
            user_answer_7 = st.text_area("Enter the Answer:", height=2, key=7)
            st.write(questions[7])
            user_answer_8 = st.text_area("Enter the Answer:", height=2, key=8)
            st.write(questions[8])
            user_answer_9 = st.text_area("Enter the Answer:", height=2, key=9)
            submission = st.button("Submit", key=1)
            if submission:
                user_answer.extend([
                    user_answer_1, user_answer_2, user_answer_3, user_answer_4,
                    user_answer_5, user_answer_6, user_answer_7, user_answer_8,
                    user_answer_9
                ])
                user_answer.pop(0)
                correct_wrong = get_similarity(answers, user_answer)
                total_marks = (sum(correct_wrong) / len(correct_wrong)) * 100
                st.write("Awesome!!!", str(total_marks))
            i = 0
            if 0 in correct_wrong:
                st.write(
                    "You have done some mistakes, here is where you went wrong..."
                )
                for i in range(len(correct_wrong)):
                    if correct_wrong[i] == 0:
                        st.write("Mistaken Question:", questions[i])
                        st.write("Correct answer: ", answers[i])
                    else:
                        pass
            else:
                st.balloons()

        elif len(questions) >= 10:
            st.write(questions[0])
            user_answer_1 = st.text_area("Enter the Answer:", height=2, key=1)
            st.write(questions[1])
            user_answer_2 = st.text_area("Enter the Answer:", height=2, key=2)
            st.write(questions[2])
            user_answer_3 = st.text_area("Enter the Answer:", height=2, key=3)
            st.write(questions[3])
            user_answer_4 = st.text_area("Enter the Answer:", height=2, key=4)
            st.write(questions[4])
            user_answer_5 = st.text_area("Enter the Answer:", height=2, key=5)
            st.write(questions[5])
            user_answer_6 = st.text_area("Enter the Answer:", height=2, key=6)
            st.write(questions[6])
            user_answer_7 = st.text_area("Enter the Answer:", height=2, key=7)
            st.write(questions[7])
            user_answer_8 = st.text_area("Enter the Answer:", height=2, key=8)
            st.write(questions[8])
            user_answer_9 = st.text_area("Enter the Answer:", height=2, key=9)
            st.write(questions[9])
            user_answer_10 = st.text_area("Enter the Answer:",
                                          height=2,
                                          key=10)
            submission = st.button("Submit", key=1)
            if submission:
                user_answer.extend([
                    user_answer_1, user_answer_2, user_answer_3, user_answer_4,
                    user_answer_5, user_answer_6, user_answer_7, user_answer_8,
                    user_answer_9, user_answer_10
                ])
                user_answer.pop(0)
                correct_wrong = get_similarity(answers, user_answer)
                total_marks = (sum(correct_wrong) / len(correct_wrong)) * 100
                st.write("Awesome!!!", str(total_marks))
            i = 0
            if 0 in correct_wrong:
                st.write(
                    "You have done some mistakes, here is where you went wrong..."
                )
                for i in range(len(correct_wrong)):
                    if correct_wrong[i] == 0:
                        st.write("Mistaken Question:", questions[i])
                        st.write("Correct answer: ", answers[i])
                    else:
                        pass
            else:
                st.balloons()