Commit
·
7a88212
1
Parent(s):
20801dd
Update app.py
Browse files
app.py
CHANGED
@@ -47,9 +47,42 @@ def get_entities(example):
|
|
47 |
|
48 |
return output
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
def process(example):
|
51 |
entidades = get_entities(example)
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
iface.launch(debug=True)
|
|
|
47 |
|
48 |
return output
|
49 |
|
50 |
+
def clasifica_sistema_universal(example):
|
51 |
+
tokenizer = AutoTokenizer.from_pretrained("hackathon-pln-es/jurisbert-class-tratados-internacionales-sistema-universal")
|
52 |
+
|
53 |
+
model = AutoModelForSequenceClassification.from_pretrained("hackathon-pln-es/jurisbert-class-tratados-internacionales-sistema-universal")
|
54 |
+
text_classifier = pipeline("text-classification", model=model, tokenizer=tokenizer)
|
55 |
+
results= text_classifier (example)
|
56 |
+
|
57 |
+
salida=[]
|
58 |
+
for i in results:
|
59 |
+
salida.append({i["label"]:i["score"]})
|
60 |
+
|
61 |
+
return {i["label"]: float(i["score"]) for i in results}
|
62 |
+
|
63 |
+
def clasifica_conv_americana(example):
|
64 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
65 |
+
|
66 |
+
tokenizer = AutoTokenizer.from_pretrained("hackathon-pln-es/jurisbert-clas-art-convencion-americana-dh")
|
67 |
+
|
68 |
+
model = AutoModelForSequenceClassification.from_pretrained("hackathon-pln-es/jurisbert-clas-art-convencion-americana-dh")
|
69 |
+
|
70 |
+
text_classifier = pipeline("text-classification", model=model, tokenizer=tokenizer)
|
71 |
+
results= text_classifier (example)
|
72 |
+
|
73 |
+
return {i["label"]: float(i["score"]) for i in results}
|
74 |
+
|
75 |
def process(example):
|
76 |
entidades = get_entities(example)
|
77 |
+
|
78 |
+
class_sistema_universal = clasifica_sistema_universal(example)
|
79 |
+
|
80 |
+
class_conv_americana = clasifica_conv_americana(example)
|
81 |
+
|
82 |
+
|
83 |
+
return entidades,class_sistema_universal, class_conv_americana
|
84 |
+
|
85 |
+
|
86 |
+
iface = gr.Interface(fn=process, inputs="text", outputs=["highlight","label","label"], examples=examples, title="Modelo Jurídico Mexicano")
|
87 |
+
|
88 |
iface.launch(debug=True)
|