Spaces:
Running
Running
poemsforaphrodite
commited on
Commit
•
14c5146
1
Parent(s):
3c85ea8
Update app.py
Browse files
app.py
CHANGED
@@ -177,11 +177,14 @@ def analyze_competitors(row, co):
|
|
177 |
|
178 |
results = []
|
179 |
for url in competitor_urls:
|
180 |
-
|
181 |
-
|
182 |
-
|
|
|
183 |
|
|
|
184 |
results.append({'url': our_url, 'relevancy_score': our_score})
|
|
|
185 |
results_df = pd.DataFrame(results).sort_values('relevancy_score', ascending=False)
|
186 |
|
187 |
logger.info(f"Competitor analysis completed. {len(results)} results obtained.")
|
@@ -196,8 +199,16 @@ def show_competitor_analysis(row, co):
|
|
196 |
st.dataframe(results_df)
|
197 |
|
198 |
our_rank = results_df.index[results_df['url'] == row['page']].tolist()[0] + 1
|
199 |
-
|
200 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
|
202 |
|
203 |
def analyze_competitors(row, co):
|
|
|
177 |
|
178 |
results = []
|
179 |
for url in competitor_urls:
|
180 |
+
if url != our_url: # Skip our URL if it's in the SERP results
|
181 |
+
content = fetch_content(url)
|
182 |
+
score = calculate_relevance_score(content, query, co)
|
183 |
+
results.append({'url': url, 'relevancy_score': score})
|
184 |
|
185 |
+
# Add our page's data
|
186 |
results.append({'url': our_url, 'relevancy_score': our_score})
|
187 |
+
|
188 |
results_df = pd.DataFrame(results).sort_values('relevancy_score', ascending=False)
|
189 |
|
190 |
logger.info(f"Competitor analysis completed. {len(results)} results obtained.")
|
|
|
199 |
st.dataframe(results_df)
|
200 |
|
201 |
our_rank = results_df.index[results_df['url'] == row['page']].tolist()[0] + 1
|
202 |
+
total_results = len(results_df)
|
203 |
+
logger.info(f"Our page ranks {our_rank} out of {total_results} in terms of relevancy score.")
|
204 |
+
st.write(f"Our page ranks {our_rank} out of {total_results} in terms of relevancy score.")
|
205 |
+
|
206 |
+
if our_rank == 1:
|
207 |
+
st.success("Your page has the highest relevancy score!")
|
208 |
+
elif our_rank <= 3:
|
209 |
+
st.info("Your page is among the top 3 most relevant results.")
|
210 |
+
elif our_rank > total_results / 2:
|
211 |
+
st.warning("Your page's relevancy score is in the lower half of the results. Consider optimizing your content.")
|
212 |
|
213 |
|
214 |
def analyze_competitors(row, co):
|