Spaces:
Paused
Paused
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import pandas as pd
|
3 |
+
import plotly.express as px
|
4 |
+
import streamlit as st
|
5 |
+
|
6 |
+
OPTS = {
|
7 |
+
"ACL 2022": "data/acl2022_spectre2-base.json",
|
8 |
+
"ACL 2023": "data/acl2023_spectre2-base.json",
|
9 |
+
}
|
10 |
+
|
11 |
+
|
12 |
+
def load_df(data_file: os.PathLike):
|
13 |
+
df = pd.read_json(data_file, orient="records")
|
14 |
+
df["x"] = df["point2d"].apply(lambda x: x[0])
|
15 |
+
df["y"] = df["point2d"].apply(lambda x: x[1])
|
16 |
+
if "publication_type" in df.columns:
|
17 |
+
df["type"] = df["publication_type"]
|
18 |
+
df = df.drop(columns=["point2d", "publication_type"])
|
19 |
+
else:
|
20 |
+
df = df.drop(columns=["point2d"])
|
21 |
+
return df
|
22 |
+
|
23 |
+
|
24 |
+
@st.cache
|
25 |
+
def load_dataframes():
|
26 |
+
return {venue: load_df(df_file) for venue, df_file in OPTS.items()}
|
27 |
+
|
28 |
+
DFS = load_dataframes()
|
29 |
+
|
30 |
+
option = st.selectbox(
|
31 |
+
'Please select a venue',
|
32 |
+
('ACL 2022', 'ACL 2023',)
|
33 |
+
)
|
34 |
+
|
35 |
+
|
36 |
+
external_stylesheets = ["https://codepen.io/chriddyp/pen/bWLwgP.css"]
|
37 |
+
|
38 |
+
|
39 |
+
fig = px.scatter(
|
40 |
+
DFS[option],
|
41 |
+
x="x",
|
42 |
+
y="y",
|
43 |
+
color="cluster",
|
44 |
+
height=700,
|
45 |
+
hover_data=["title", "authors", "year", "source", "type"],
|
46 |
+
)
|
47 |
+
fig.update_layout(
|
48 |
+
margin=dict(l=10, r=10, t=20, b=20),
|
49 |
+
showlegend=False,
|
50 |
+
font=dict(
|
51 |
+
family="Times New Roman",
|
52 |
+
size=30,
|
53 |
+
),
|
54 |
+
)
|
55 |
+
fig.update_xaxes(title="")
|
56 |
+
fig.update_yaxes(title="")
|
57 |
+
|
58 |
+
st.plotly_chart(fig)
|