Spaces:
Build error
Build error
Commit ·
cdd06f9
1
Parent(s): ef128d6
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
imprt functions
|
| 3 |
+
|
| 4 |
+
demo=gr.Blocks()
|
| 5 |
+
|
| 6 |
+
with demo:
|
| 7 |
+
gr.Image("logo_credit_agricole_CIB_0.jpg")
|
| 8 |
+
gr.Markdown("## Important Sentences Recognizer")
|
| 9 |
+
gr.Markdown("This project aims to retrieve critical sentences related with some important words in a document.")
|
| 10 |
+
#gr.Interface(fn=reading_file, inputs=gr.File(), outputs="text")
|
| 11 |
+
with gr.Box():
|
| 12 |
+
with gr.Row():
|
| 13 |
+
file=gr.File()
|
| 14 |
+
with gr.Column():
|
| 15 |
+
b1=gr.Button("Reading file",variant="primary")
|
| 16 |
+
t1=gr.Textbox(label="Result")
|
| 17 |
+
|
| 18 |
+
b2=gr.Button("Filtering")
|
| 19 |
+
t2=gr.Textbox(label="Result")
|
| 20 |
+
|
| 21 |
+
gr.Markdown("Now we run ctrl+f method.")
|
| 22 |
+
with gr.Box():
|
| 23 |
+
checkbox1=gr.CheckboxGroup(words, label="Select desired words")
|
| 24 |
+
b4=gr.Button("Run analysis")
|
| 25 |
+
t4=gr.Textbox(label="Result")
|
| 26 |
+
|
| 27 |
+
gr.Markdown("But first we need to choose how to parse the text.")
|
| 28 |
+
with gr.Box():
|
| 29 |
+
t=gr.Textbox(label="Write: sentences or paragraphs or lines or words", value="sentences")
|
| 30 |
+
#radio1=gr.Radio(["lines", "sentences", "paragraphs"], label="Parse by", value="sentences", interactive=True),
|
| 31 |
+
b3=gr.Button("Split text")
|
| 32 |
+
t3=gr.Textbox(label="Result")
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
gr.Markdown("Using previous the previous result, we run now the NLP analysis.")
|
| 36 |
+
with gr.Box():
|
| 37 |
+
|
| 38 |
+
gr.Markdown("Now we will proceed with the analysis.")
|
| 39 |
+
dropdown1=gr.Dropdown(choices=["all-MiniLM-L6-v2","multi-qa-mpnet-base-dot-v1","msmarco-distilbert-base-v4"], label="Model")
|
| 40 |
+
slider1=gr.Slider(1,100,10, label="Top k", interactive=True, step=1)
|
| 41 |
+
dropdown2=gr.Dropdown(choices=["cosine similarity","dot product"], label="Similarity function")
|
| 42 |
+
b5=gr.Button("Run analysis", variant="primary")
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
gr.Markdown
|
| 46 |
+
df1= gr.Dataframe(row_count = (1, "dynamic"), col_count=(2, "fixed"), label="Important sentences", headers=["Expression", "Score"], overflow_row_behaviour="paginate")
|
| 47 |
+
|
| 48 |
+
b1.click(reading_file, inputs=file, outputs=t1)
|
| 49 |
+
b2.click(filtering, inputs=t1, outputs=t2)
|
| 50 |
+
b3.click(splitting, inputs=[t, t2], outputs=t3)
|
| 51 |
+
b4.click(ctrlf,[checkbox1, t2], t4)
|
| 52 |
+
b5.click(fn=total, inputs=[t2, t4,t, dropdown1, slider1, dropdown2], outputs=df1)
|
| 53 |
+
demo.launch(share=True)
|