Spaces:
Sleeping
Sleeping
fschwartzer
commited on
Commit
•
94b2524
1
Parent(s):
ea98fbe
Update app.py
Browse files
app.py
CHANGED
@@ -43,7 +43,7 @@ def refinar_resultados(df, include_word=[]):
|
|
43 |
def get_best_match(query, choices, limit=50):
|
44 |
# Using RapidFuzz for improved performance and fuzzy matching
|
45 |
matches = process.extract(query, choices, scorer=fuzz.WRatio, limit=limit)
|
46 |
-
return [match[0] for match in matches if match[1] >
|
47 |
|
48 |
def match_query_words_in_titles(query, title):
|
49 |
"""
|
@@ -51,7 +51,7 @@ def match_query_words_in_titles(query, title):
|
|
51 |
Returns True if all words match to a certain degree; False otherwise.
|
52 |
"""
|
53 |
query_words = query.lower().split()
|
54 |
-
match_threshold =
|
55 |
|
56 |
for word in query_words:
|
57 |
# Find the best match for each word in the query within the title
|
@@ -88,7 +88,7 @@ def calcular_fator_avaliacao(titulo, EC, PU):
|
|
88 |
def select_nearest_items(df, query):
|
89 |
# Lower the title similarity threshold if necessary
|
90 |
df['Title_Similarity'] = df['Title'].apply(lambda x: fuzz.WRatio(query, x))
|
91 |
-
df_filtered = df[df['Title_Similarity'] >
|
92 |
|
93 |
# Calculate mode price in a more inclusive manner
|
94 |
mode_price = df_filtered['Price'].mode()
|
@@ -156,6 +156,9 @@ def integrated_app(query, titulo, EC, PU, selected_rows):
|
|
156 |
selected_indices = [int(idx) for idx in selected_rows.split(',') if idx.isdigit()]
|
157 |
df_nearest = df_nearest.iloc[selected_indices]
|
158 |
|
|
|
|
|
|
|
159 |
fator_avaliacao = calcular_fator_avaliacao(titulo, EC, PU)
|
160 |
valor_avaliacao = df_nearest['Price'].mean() * fator_avaliacao
|
161 |
return f"Valor Médio do Bem: R$ {df_nearest['Price'].mean():.2f}, Fator de Avaliação: {fator_avaliacao*100:.2f}%, Valor de Avaliação: R$ {valor_avaliacao:.2f}", df_nearest
|
|
|
43 |
def get_best_match(query, choices, limit=50):
|
44 |
# Using RapidFuzz for improved performance and fuzzy matching
|
45 |
matches = process.extract(query, choices, scorer=fuzz.WRatio, limit=limit)
|
46 |
+
return [match[0] for match in matches if match[1] > 75]
|
47 |
|
48 |
def match_query_words_in_titles(query, title):
|
49 |
"""
|
|
|
51 |
Returns True if all words match to a certain degree; False otherwise.
|
52 |
"""
|
53 |
query_words = query.lower().split()
|
54 |
+
match_threshold = 75 # Adjust this threshold as needed
|
55 |
|
56 |
for word in query_words:
|
57 |
# Find the best match for each word in the query within the title
|
|
|
88 |
def select_nearest_items(df, query):
|
89 |
# Lower the title similarity threshold if necessary
|
90 |
df['Title_Similarity'] = df['Title'].apply(lambda x: fuzz.WRatio(query, x))
|
91 |
+
df_filtered = df[df['Title_Similarity'] > 75] # Adjusted threshold
|
92 |
|
93 |
# Calculate mode price in a more inclusive manner
|
94 |
mode_price = df_filtered['Price'].mode()
|
|
|
156 |
selected_indices = [int(idx) for idx in selected_rows.split(',') if idx.isdigit()]
|
157 |
df_nearest = df_nearest.iloc[selected_indices]
|
158 |
|
159 |
+
df_nearest.reset_index(drop=True, inplace=True)
|
160 |
+
df_nearest['ID'] = df_nearest.index
|
161 |
+
|
162 |
fator_avaliacao = calcular_fator_avaliacao(titulo, EC, PU)
|
163 |
valor_avaliacao = df_nearest['Price'].mean() * fator_avaliacao
|
164 |
return f"Valor Médio do Bem: R$ {df_nearest['Price'].mean():.2f}, Fator de Avaliação: {fator_avaliacao*100:.2f}%, Valor de Avaliação: R$ {valor_avaliacao:.2f}", df_nearest
|