File size: 1,553 Bytes
a54c5a9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
38
39
40
41
42
43
44
import gradio as gr
from gliner import GLiNER

model = GLiNER.from_pretrained("chris32/gliner_multi_pii_real_state-v2")
model.eval()

#text = """
#Casa en venta Valle de San Ángel, San Pedro Garza García**Para remodelar o demoler Casa de 1220 m2 de terreno y 1400 m2 de construcciónCasa de 3 niveles-Sala-Comedor-Cocina-Estancia-Preparación para alberca-Cochera para 3 autos techada -4 recamaras -Lavandería"Esta es una de las varias opciones que tenemos para ti. Somos una agencia de bienes raíces especializada en la venta y renta de vivienda residencial, te brindamos un servicio personalizado y de alta calidad. Si necesitas ayuda para comprar o rentar, contáctanos y uno de nuestros asesores te atenderá.
#"""
#for entity in entities:
#    print(entity["text"], "=>", entity["label"])

def generate_answer(text):
    labels = [
    'SUPERFICIE_JARDIN',
    'NOMBRE_CLUB_GOLF',
    'SUPERFICIE_TERRENO',
    'SUPERFICIE_HABITABLE',
    'SUPERFICIE_TERRAZA',
    'NOMBRE_COMPLETO_ARQUITECTO',
    'SUPERFICIE_BALCON',
    'NOMBRE_DESARROLLO',
    'NOMBRE_TORRE',
    'NOMBRE_CONDOMINIO',
    'AÑO_REMODELACIÓN'
    ]
    entities = model.predict_entities(text, labels, threshold=0.4)
    result_dict = entities
    
    return result_dict

# Cambiar a entrada de texto
text_input = gr.inputs.Textbox(lines=15, label="Input Text")

iface = gr.Interface(
    fn=generate_answer, 
    inputs=text_input, 
    outputs="text",
    title="Text Intelligence for Real State",
    description="Input text describing the property."
)

iface.launch()