Spaces:
Runtime error
Runtime error
azaninello
commited on
Commit
•
0a5ef4b
1
Parent(s):
6460fc9
Update app.py
Browse files
app.py
CHANGED
@@ -11,17 +11,31 @@ nltk.download('punkt')
|
|
11 |
def update(name):
|
12 |
return f"Welcome to Gradio, {name}!"
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
with gr.Blocks() as demo:
|
15 |
-
gr.Markdown("
|
16 |
with gr.Row():
|
17 |
-
|
18 |
out = gr.Textbox()
|
19 |
btn = gr.Button("Run")
|
20 |
-
btn.click(fn=
|
21 |
|
22 |
demo.launch()
|
23 |
|
24 |
-
|
25 |
file = "text.txt"
|
26 |
|
27 |
def get_lists(file):
|
@@ -38,19 +52,8 @@ def get_lists(file):
|
|
38 |
|
39 |
words, words_lower, SENTENCES, SENTENCES_LOWER = get_lists(file)
|
40 |
|
41 |
-
def search_engine_bot(target):
|
42 |
|
43 |
-
|
44 |
-
for i,sent in enumerate(sentences_lower):
|
45 |
-
if target.lower() in sent:
|
46 |
-
result.append(sentences[i])
|
47 |
-
|
48 |
-
if len(result) == 0:
|
49 |
-
return (f"Non ho trovato la parola '{target}' nei testi.\n", result)
|
50 |
-
|
51 |
-
else:
|
52 |
-
return (f"""Ho trovato {len(result)} {"frasi" if len(result) > 1 else "frase"} in cui è presente la parola {target}.\n""", result)
|
53 |
-
|
54 |
def num_sentences(show=''):
|
55 |
try:
|
56 |
number = int(show)
|
|
|
11 |
def update(name):
|
12 |
return f"Welcome to Gradio, {name}!"
|
13 |
|
14 |
+
def search_engine_bot(target):
|
15 |
+
|
16 |
+
result = []
|
17 |
+
for i,sent in enumerate(sentences_lower):
|
18 |
+
if target.lower() in sent:
|
19 |
+
result.append(sentences[i])
|
20 |
+
|
21 |
+
if len(result) == 0:
|
22 |
+
return (f"Non ho trovato la parola '{target}' nei testi.\n", result)
|
23 |
+
|
24 |
+
else:
|
25 |
+
return (f"""Ho trovato {len(result)} {"frasi" if len(result) > 1 else "frase"} in cui è presente la parola {target}.\n""", result)
|
26 |
+
|
27 |
+
|
28 |
with gr.Blocks() as demo:
|
29 |
+
gr.Markdown("Inerisci la parola da cercare.")
|
30 |
with gr.Row():
|
31 |
+
target = gr.Textbox(placeholder="What is your name?")
|
32 |
out = gr.Textbox()
|
33 |
btn = gr.Button("Run")
|
34 |
+
btn.click(fn=search_engine_bot(), inputs=target, outputs=out)
|
35 |
|
36 |
demo.launch()
|
37 |
|
38 |
+
|
39 |
file = "text.txt"
|
40 |
|
41 |
def get_lists(file):
|
|
|
52 |
|
53 |
words, words_lower, SENTENCES, SENTENCES_LOWER = get_lists(file)
|
54 |
|
|
|
55 |
|
56 |
+
'''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
def num_sentences(show=''):
|
58 |
try:
|
59 |
number = int(show)
|