Spaces:
Sleeping
Sleeping
update app
Browse files
app.py
CHANGED
@@ -328,25 +328,23 @@ def procesar(texto,archivo):
|
|
328 |
model.identificacion_idioma(texto)
|
329 |
return model.predict(),gr.Dataframe(),gr.File()
|
330 |
else:
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
df_new = pd.DataFrame( columns=df.columns.values)
|
336 |
-
print(df_new)
|
337 |
-
for item in df.columns.values:
|
338 |
-
sentences=df[item]
|
339 |
-
ides, predicted = modelo.aplicar_modelo(sentences)
|
340 |
-
out=modelo.salida_texto2( ides,predicted)
|
341 |
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
|
|
|
|
|
|
|
|
350 |
demo = gr.Interface(fn=procesar,inputs=["text",gr.File()] , outputs=["text",gr.Dataframe(interactive=False),"text"])
|
351 |
#
|
352 |
demo.launch(share=True)
|
|
|
328 |
model.identificacion_idioma(texto)
|
329 |
return model.predict(),gr.Dataframe(),gr.File()
|
330 |
else:
|
331 |
+
if archivo.name.split(".")[1]=="csv":
|
332 |
+
df=pd.read_csv(archivo.name,delimiter=",")
|
333 |
+
|
334 |
+
df_new = pd.DataFrame( columns=df.columns.values)
|
|
|
|
|
|
|
|
|
|
|
|
|
335 |
|
336 |
+
for item in df.columns.values:
|
337 |
+
sentences=df[item]
|
338 |
+
ides, predicted = modelo.aplicar_modelo(sentences)
|
339 |
+
out=modelo.salida_texto2( ides,predicted)
|
340 |
+
|
341 |
+
df_new[item] = modelo.unir_array(out)
|
342 |
+
return "", df_new, df_new.to_csv(sep='\t', encoding='utf-8',index=False)
|
343 |
+
#return "", df_new, df_new.to_excel( index=False)
|
344 |
+
else:
|
345 |
+
if archivo.name.split(".")[1]=="json":
|
346 |
+
print("json")
|
347 |
+
return "", gr.Dataframe(), ""
|
348 |
demo = gr.Interface(fn=procesar,inputs=["text",gr.File()] , outputs=["text",gr.Dataframe(interactive=False),"text"])
|
349 |
#
|
350 |
demo.launch(share=True)
|