Spaces:
Sleeping
Sleeping
Upload app.py
Browse files- src/app.py +18 -10
src/app.py
CHANGED
|
@@ -978,14 +978,20 @@ with tab_geo:
|
|
| 978 |
|
| 979 |
# βββ 7. ANALYTICS βββββββββββββββββββββββββββββββββββββββββββββββ
|
| 980 |
with tab_analytics:
|
| 981 |
-
|
| 982 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 983 |
|
| 984 |
col_a, col_b = st.columns(2)
|
| 985 |
|
| 986 |
with col_a:
|
| 987 |
st.subheader("Top Authors")
|
| 988 |
-
if "author_id" in seed.columns and not seed["author_id"].isna().all():
|
| 989 |
top_auth = (seed.explode("author_id")
|
| 990 |
.merge(authors_df, on="author_id", how="left")
|
| 991 |
.groupby("author_name").size()
|
|
@@ -1150,15 +1156,17 @@ with tab_analytics:
|
|
| 1150 |
)
|
| 1151 |
|
| 1152 |
with col_e2:
|
| 1153 |
-
|
| 1154 |
["citing_title", "citing_doi", "citing_year", "citing_venue",
|
| 1155 |
"primary_intent", "context_count", "is_influential"]
|
| 1156 |
-
|
| 1157 |
-
|
| 1158 |
-
|
| 1159 |
-
|
| 1160 |
-
|
| 1161 |
-
|
|
|
|
|
|
|
| 1162 |
st.download_button(
|
| 1163 |
"β¬ Citation Events (CSV)",
|
| 1164 |
cite_export, "citation_events.csv", "text/csv",
|
|
|
|
| 978 |
|
| 979 |
# βββ 7. ANALYTICS βββββββββββββββββββββββββββββββββββββββββββββββ
|
| 980 |
with tab_analytics:
|
| 981 |
+
try:
|
| 982 |
+
with st.spinner("Loading analytics data..."):
|
| 983 |
+
authors_df = load_authors_data(data_dir_val)
|
| 984 |
+
_authors_ok = True
|
| 985 |
+
except Exception as _e:
|
| 986 |
+
st.warning(f"Authors data unavailable: {_e}")
|
| 987 |
+
authors_df = pd.DataFrame(columns=["author_id", "author_name"])
|
| 988 |
+
_authors_ok = False
|
| 989 |
|
| 990 |
col_a, col_b = st.columns(2)
|
| 991 |
|
| 992 |
with col_a:
|
| 993 |
st.subheader("Top Authors")
|
| 994 |
+
if _authors_ok and "author_id" in seed.columns and not seed["author_id"].isna().all():
|
| 995 |
top_auth = (seed.explode("author_id")
|
| 996 |
.merge(authors_df, on="author_id", how="left")
|
| 997 |
.groupby("author_name").size()
|
|
|
|
| 1156 |
)
|
| 1157 |
|
| 1158 |
with col_e2:
|
| 1159 |
+
_cite_cols = [c for c in
|
| 1160 |
["citing_title", "citing_doi", "citing_year", "citing_venue",
|
| 1161 |
"primary_intent", "context_count", "is_influential"]
|
| 1162 |
+
if c in seed_events.columns]
|
| 1163 |
+
cite_export = (seed_events[_cite_cols]
|
| 1164 |
+
.rename(columns={
|
| 1165 |
+
"citing_title": "title", "citing_doi": "doi",
|
| 1166 |
+
"citing_year": "year", "citing_venue": "venue",
|
| 1167 |
+
"primary_intent": "intent", "context_count": "contexts",
|
| 1168 |
+
"is_influential": "influential",
|
| 1169 |
+
}).to_csv(index=False).encode("utf-8"))
|
| 1170 |
st.download_button(
|
| 1171 |
"β¬ Citation Events (CSV)",
|
| 1172 |
cite_export, "citation_events.csv", "text/csv",
|