Spaces:
Running
Running
poemsforaphrodite
commited on
Commit
•
36a7b5d
1
Parent(s):
faa6271
Update app.py
Browse files
app.py
CHANGED
@@ -498,34 +498,24 @@ def show_tabular_data(df, co):
|
|
498 |
score = calculate_relevance_score(content, row['query'], co)
|
499 |
return score
|
500 |
|
501 |
-
# Function to update the relevancy score
|
502 |
-
def update_relevancy(row_index):
|
503 |
-
score = calculate_single_relevancy(df.iloc[row_index])
|
504 |
-
df.at[row_index, 'relevancy_score'] = score
|
505 |
-
df_display.at[row_index, 'relevancy_score'] = f"{score:.4f}"
|
506 |
-
|
507 |
-
# Create a column for the calculate button
|
508 |
-
df_display['calculate'] = ['Calculate' if pd.isna(score) or score == 0 else f"{score:.4f}"
|
509 |
-
for score in df['relevancy_score']]
|
510 |
-
|
511 |
# Display the dataframe
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
)
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
|
530 |
# Add an expander for each row to show competitor analysis
|
531 |
for index, row in df.iterrows():
|
@@ -538,6 +528,8 @@ def show_tabular_data(df, co):
|
|
538 |
our_rank = results_df.index[results_df['url'] == row['page']].tolist()[0] + 1
|
539 |
st.write(f"Our page ranks {our_rank} out of {len(results_df)} in terms of relevancy score.")
|
540 |
|
|
|
|
|
541 |
def show_date_range_selector():
|
542 |
# logging.info("Showing date range selector")
|
543 |
return st.selectbox(
|
@@ -680,7 +672,7 @@ def main():
|
|
680 |
if st.session_state.report_data is not None and not st.session_state.report_data.empty:
|
681 |
st.write("Data fetched successfully.")
|
682 |
|
683 |
-
show_tabular_data(st.session_state.report_data, co)
|
684 |
|
685 |
download_csv_link(st.session_state.report_data)
|
686 |
elif st.session_state.report_data is not None:
|
|
|
498 |
score = calculate_relevance_score(content, row['query'], co)
|
499 |
return score
|
500 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
501 |
# Display the dataframe
|
502 |
+
st.dataframe(df_display)
|
503 |
+
|
504 |
+
# Create buttons for each row
|
505 |
+
for index, row in df_display.iterrows():
|
506 |
+
col1, col2 = st.columns([3, 1])
|
507 |
+
with col1:
|
508 |
+
st.write(f"Query: {row['query']} | Page: {row['page']}")
|
509 |
+
with col2:
|
510 |
+
if pd.isna(row['relevancy_score']) or row['relevancy_score'] == 0:
|
511 |
+
if st.button(f"Calculate Score", key=f"calc_{index}"):
|
512 |
+
score = calculate_single_relevancy(row)
|
513 |
+
df.at[index, 'relevancy_score'] = score
|
514 |
+
df_display.at[index, 'relevancy_score'] = score
|
515 |
+
st.success(f"Relevancy Score: {score:.4f}")
|
516 |
+
st.experimental_rerun()
|
517 |
+
else:
|
518 |
+
st.write(f"Relevancy Score: {row['relevancy_score']:.4f}")
|
519 |
|
520 |
# Add an expander for each row to show competitor analysis
|
521 |
for index, row in df.iterrows():
|
|
|
528 |
our_rank = results_df.index[results_df['url'] == row['page']].tolist()[0] + 1
|
529 |
st.write(f"Our page ranks {our_rank} out of {len(results_df)} in terms of relevancy score.")
|
530 |
|
531 |
+
return df # Return the updated dataframe
|
532 |
+
|
533 |
def show_date_range_selector():
|
534 |
# logging.info("Showing date range selector")
|
535 |
return st.selectbox(
|
|
|
672 |
if st.session_state.report_data is not None and not st.session_state.report_data.empty:
|
673 |
st.write("Data fetched successfully.")
|
674 |
|
675 |
+
st.session_state.report_data = show_tabular_data(st.session_state.report_data, co)
|
676 |
|
677 |
download_csv_link(st.session_state.report_data)
|
678 |
elif st.session_state.report_data is not None:
|