Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,10 @@
|
|
1 |
import os
|
|
|
2 |
import pandas as pd
|
3 |
import plotly.express as px
|
4 |
import streamlit as st
|
5 |
|
|
|
6 |
DATA_FILE = "data/anthology-2020-23_specter2_base.json"
|
7 |
|
8 |
|
@@ -22,6 +24,7 @@ def load_df(data_file: os.PathLike):
|
|
22 |
def load_dataframe():
|
23 |
return load_df(DATA_FILE)
|
24 |
|
|
|
25 |
DF = load_dataframe()
|
26 |
|
27 |
with st.sidebar:
|
@@ -31,32 +34,37 @@ with st.sidebar:
|
|
31 |
["ACL", "EMNLP", "NAACL", "TACL"],
|
32 |
)
|
33 |
|
34 |
-
start_year, end_year = st.select_slider(
|
35 |
-
|
|
|
|
|
36 |
|
37 |
start_year = int(start_year)
|
38 |
end_year = int(end_year)
|
39 |
df = DF[(DF["year"] >= start_year) & (DF["year"] <= end_year)]
|
40 |
-
if len(venues) < 4:
|
41 |
selected_venues = [v.lower() for v in venues]
|
42 |
df = df[df["source"].isin(selected_venues)]
|
|
|
|
|
43 |
|
44 |
if author_names:
|
45 |
-
authors = [a.strip()
|
46 |
-
author_mask = df.authors.apply(
|
|
|
|
|
47 |
df = df[author_mask]
|
48 |
|
49 |
st.write(f"Number of points: {df.shape[0]}")
|
50 |
|
51 |
|
52 |
-
|
53 |
fig = px.scatter(
|
54 |
df,
|
55 |
x="x",
|
56 |
y="y",
|
57 |
color="cluster",
|
58 |
-
width=
|
59 |
-
height=
|
60 |
hover_data=["title", "authors", "year", "source", "type"],
|
61 |
color_continuous_scale="fall",
|
62 |
)
|
@@ -71,4 +79,5 @@ fig.update_layout(
|
|
71 |
fig.update_xaxes(title="")
|
72 |
fig.update_yaxes(title="")
|
73 |
|
|
|
74 |
st.plotly_chart(fig, use_container_width=True)
|
|
|
1 |
import os
|
2 |
+
import re
|
3 |
import pandas as pd
|
4 |
import plotly.express as px
|
5 |
import streamlit as st
|
6 |
|
7 |
+
st.set_page_config(layout="wide")
|
8 |
DATA_FILE = "data/anthology-2020-23_specter2_base.json"
|
9 |
|
10 |
|
|
|
24 |
def load_dataframe():
|
25 |
return load_df(DATA_FILE)
|
26 |
|
27 |
+
|
28 |
DF = load_dataframe()
|
29 |
|
30 |
with st.sidebar:
|
|
|
34 |
["ACL", "EMNLP", "NAACL", "TACL"],
|
35 |
)
|
36 |
|
37 |
+
start_year, end_year = st.select_slider(
|
38 |
+
"Publication year", options=("2020", "2021", "2022", "2023"), value=("2020", "2023")
|
39 |
+
)
|
40 |
+
author_names = st.text_input("Author names (separated by comma)")
|
41 |
|
42 |
start_year = int(start_year)
|
43 |
end_year = int(end_year)
|
44 |
df = DF[(DF["year"] >= start_year) & (DF["year"] <= end_year)]
|
45 |
+
if 0 < len(venues) < 4:
|
46 |
selected_venues = [v.lower() for v in venues]
|
47 |
df = df[df["source"].isin(selected_venues)]
|
48 |
+
elif not venues:
|
49 |
+
st.write(":red[Please select a venue]")
|
50 |
|
51 |
if author_names:
|
52 |
+
authors = [a.strip() for a in author_names.split(",")]
|
53 |
+
author_mask = df.authors.apply(
|
54 |
+
lambda row: all(any(re.match(rf".*{a}.*", x, re.IGNORECASE) for x in row) for a in authors)
|
55 |
+
)
|
56 |
df = df[author_mask]
|
57 |
|
58 |
st.write(f"Number of points: {df.shape[0]}")
|
59 |
|
60 |
|
|
|
61 |
fig = px.scatter(
|
62 |
df,
|
63 |
x="x",
|
64 |
y="y",
|
65 |
color="cluster",
|
66 |
+
width=1000,
|
67 |
+
height=800,
|
68 |
hover_data=["title", "authors", "year", "source", "type"],
|
69 |
color_continuous_scale="fall",
|
70 |
)
|
|
|
79 |
fig.update_xaxes(title="")
|
80 |
fig.update_yaxes(title="")
|
81 |
|
82 |
+
|
83 |
st.plotly_chart(fig, use_container_width=True)
|