File size: 873 Bytes
9541562
5089840
 
 
 
 
 
 
 
 
 
 
7f0a3e9
5089840
7f0a3e9
5089840
9541562
 
 
 
 
 
 
 
 
 
 
2f25ee7
cdaa37b
9541562
cdaa37b
2f25ee7
cdaa37b
9541562
2f25ee7
5089840
9541562
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
import gradio as gr
import requests
from bs4 import BeautifulSoup

def sinonimos(palabra):
    url = "https://www.wordreference.com/sinonimos/" + palabra

    resp = requests.get(url)
    soup = BeautifulSoup(resp.text)

    try:
        myElement1 = soup.find(class_="trans clickable").find("li")
        return myElement1.text.replace("  ", " ")
    except:
        return "No hay sinóninos"

value1 = gr.Textbox(lines=2, label="Palabra", placeholder="Ingrese aquí la palabra...")
value2 = gr.Textbox(label="Sinónimos")

examples = [
    ["libre"],
    ["palabra"],
    ["compromiso"],
    ["decisión"],
    ["poder"]
]

demo = gr.Interface(
    fn=sinonimos,
    inputs=value1,
    outputs=value2,
    title="Sinónimos español",
    examples=examples,
    description="Generador de sinónimos en español, hace scraping a wordreference."
)

demo.launch(debug=True)