Update resultados_consulta.py
Browse files- resultados_consulta.py +4 -2
resultados_consulta.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import pandas as pd
|
2 |
import numpy as np
|
3 |
from preprocesamiento_articulos import remove_URL, remove_html_markup, eliminar_puntuacion, eliminar_stopwords, obtener_raices
|
|
|
4 |
|
5 |
|
6 |
# La idea aqui es colocar el query en minusculas y limpiar el query de palabras vacias y algunos caracteres
|
@@ -61,8 +62,9 @@ def retrieve_index(data,cosine_scores, document_index, topn=10):
|
|
61 |
data['scores'] = cosine_scores
|
62 |
df_top_scores=data.reset_index().sort_values('scores',ascending=False).head(topn)
|
63 |
df_top_scores=df_top_scores[df_top_scores['scores'] > 0]
|
|
|
64 |
return df_top_scores.index # Dataframe original con los scores
|
65 |
-
|
66 |
|
67 |
|
68 |
def resultados_consulta(df,articulos_indexados, query):
|
@@ -71,7 +73,7 @@ def resultados_consulta(df,articulos_indexados, query):
|
|
71 |
qs=query_score(articulos_indexados,query)
|
72 |
if 'query_tf_idf' in qs.columns:
|
73 |
cosenos = cosine_similarity(qs, df['ID'].values, 'query_tf_idf')
|
74 |
-
indices = retrieve_index(df, cosenos, 'ID',
|
75 |
return indices
|
76 |
|
77 |
def detalles_resultados(df,indices):
|
|
|
1 |
import pandas as pd
|
2 |
import numpy as np
|
3 |
from preprocesamiento_articulos import remove_URL, remove_html_markup, eliminar_puntuacion, eliminar_stopwords, obtener_raices
|
4 |
+
import streamlit as st
|
5 |
|
6 |
|
7 |
# La idea aqui es colocar el query en minusculas y limpiar el query de palabras vacias y algunos caracteres
|
|
|
62 |
data['scores'] = cosine_scores
|
63 |
df_top_scores=data.reset_index().sort_values('scores',ascending=False).head(topn)
|
64 |
df_top_scores=df_top_scores[df_top_scores['scores'] > 0]
|
65 |
+
st.write(df_top_scores)
|
66 |
return df_top_scores.index # Dataframe original con los scores
|
67 |
+
# del coseno en una columna nueva
|
68 |
|
69 |
|
70 |
def resultados_consulta(df,articulos_indexados, query):
|
|
|
73 |
qs=query_score(articulos_indexados,query)
|
74 |
if 'query_tf_idf' in qs.columns:
|
75 |
cosenos = cosine_similarity(qs, df['ID'].values, 'query_tf_idf')
|
76 |
+
indices = retrieve_index(df, cosenos, 'ID', len(df))
|
77 |
return indices
|
78 |
|
79 |
def detalles_resultados(df,indices):
|