area444 commited on
Commit
fd7ff54
1 Parent(s): 7ce200e

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -0
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+ text = """Estimado Amazon, la semana pasada pedí una figura de acción de \
4
+ Optimus Prime de su tienda online en Alemania. Desafortunadamente, cuando abrí \
5
+ el paquete descubrí con horror que me habían enviado una figura de acción de \
6
+ Megatron en su lugar. Como enemigo de toda la vida de los Decepticons, espero \
7
+ que puedan entender mi dilema. Para resolver el problema, exijo un intercambio \
8
+ de Megatron por la figura de Optimus Prime que pedí. Adjunto copias de mis \
9
+ registros relacionados con esta compra. Espero tener noticias suyas pronto. \
10
+ Sinceramente, Bumblebee."""
11
+
12
+ mytext1="1. DECLARAR EXTINGUIDA LA ACCIÓN PENAL en este caso por cumplimiento de la suspensión del proceso a prueba, y SOBRESEER a EZEQUIEL CAMILO MARCONNI, DNI 11.222.333, en orden a los delitos de lesiones leves agravadas, amenazas simples y agravadas por el uso de armas, en contra de Chuchita Perez de 50 años."
13
+
14
+ import gradio as gr
15
+ from transformers import pipeline
16
+ title = 'Spanish QA - Demo App'
17
+
18
+ #context = "The Amazon rainforest (Portuguese: Floresta Amazônica or Amazônia; Spanish: Selva Amazónica, Amazonía or usually Amazonia; French: Forêt amazonienne; Dutch: Amazoneregenwoud), also known in English as Amazonia or the Amazon Jungle, is a moist broadleaf forest that covers most of the Amazon basin of South America. This basin encompasses 7,000,000 square kilometres (2,700,000 sq mi), of which 5,500,000 square kilometres (2,100,000 sq mi) are covered by the rainforest. This region includes territory belonging to nine nations. The majority of the forest is contained within Brazil, with 60% of the rainforest, followed by Peru with 13%, Colombia with 10%, and with minor amounts in Venezuela, Ecuador, Bolivia, Guyana, Suriname, and French Guiana. States or departments in four nations contain 'Amazonas' in their names. The Amazon represents over half of the planet's remaining rainforests, and comprises the largest and most biodiverse tract of tropical rainforest in the world, with an estimated 390 billion individual trees divided into 16,000 species."
19
+ context = text
20
+ context2 = mytext1
21
+ #question = "Which name is also used to describe the Amazon rainforest in English?"
22
+ question = "¿Qué quiere el cliente?"
23
+ question2 = "¿Nombre completo de Chuchita?"
24
+
25
+
26
+ #question_answerer = pipeline("question-answering", model='distilbert-base-cased-distilled-squad')
27
+ question_answerer = pipeline("question-answering", model="mrm8488/distill-bert-base-spanish-wwm-cased-finetuned-spa-squad2-es")
28
+ #result = question_answerer(question = question, context=context)
29
+ #return result['answer']
30
+
31
+
32
+
33
+ with gr.Blocks(theme=gr.themes.Soft()) as demo:
34
+ gr.HTML("<h1>"+title+"</h1>")
35
+ gr.Interface.from_pipeline(question_answerer,
36
+ #title = title,
37
+ #theme = "soft",
38
+ examples = [[context, question], [context2, question2]]).launch()