Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -10,11 +10,13 @@ DATA_FILE = "data/gwf_2017-2021_specter2_base.json"
|
|
10 |
THEMES = {"cluster": "fall", "year": "mint", "source": "phase"}
|
11 |
|
12 |
|
13 |
-
def
|
14 |
-
if len(
|
15 |
-
return ", ".join(
|
|
|
|
|
16 |
else:
|
17 |
-
return " and ".join(
|
18 |
|
19 |
|
20 |
def load_df(data_file: os.PathLike):
|
@@ -25,10 +27,9 @@ def load_df(data_file: os.PathLike):
|
|
25 |
df["year"] = df["year"].astype(int)
|
26 |
|
27 |
df["authors_trimmed"] = df.authors.apply(
|
28 |
-
lambda row:
|
29 |
-
|
30 |
-
|
31 |
-
lambda row: decorated_to_string(row[:5]) + (" et al." if len(row) > 5 else "")
|
32 |
)
|
33 |
|
34 |
if "publication_type" in df.columns:
|
@@ -114,4 +115,4 @@ fig.update_layout(
|
|
114 |
fig.update_xaxes(title="")
|
115 |
fig.update_yaxes(title="")
|
116 |
|
117 |
-
st.plotly_chart(fig, use_container_width=True)
|
|
|
10 |
THEMES = {"cluster": "fall", "year": "mint", "source": "phase"}
|
11 |
|
12 |
|
13 |
+
def to_string_authors(list_of_authors):
|
14 |
+
if len(list_of_authors) > 6:
|
15 |
+
return ", ".join(list_of_authors[:6]) + ", et al."
|
16 |
+
elif len(list_of_authors) > 2:
|
17 |
+
return ", ".join(list_of_authors[:-1]) + ", and " + list_of_authors[-1]
|
18 |
else:
|
19 |
+
return " and ".join(list_of_authors)
|
20 |
|
21 |
|
22 |
def load_df(data_file: os.PathLike):
|
|
|
27 |
df["year"] = df["year"].astype(int)
|
28 |
|
29 |
df["authors_trimmed"] = df.authors.apply(
|
30 |
+
lambda row: to_string_authors(
|
31 |
+
[(x[x.index(",") + 1 :].strip() + " " + x.split(",")[0].strip()) if "," in x else x for x in row]
|
32 |
+
)
|
|
|
33 |
)
|
34 |
|
35 |
if "publication_type" in df.columns:
|
|
|
115 |
fig.update_xaxes(title="")
|
116 |
fig.update_yaxes(title="")
|
117 |
|
118 |
+
st.plotly_chart(fig, use_container_width=True)
|