-
Notifications
You must be signed in to change notification settings - Fork 0
/
article_card_similarity.py
249 lines (177 loc) · 7.79 KB
/
article_card_similarity.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
import streamlit as st
class articleCardNewsworthiness():
def __init__(self):
self.arxiv_id = None
self.title = None
self.summary = None
self.published = None
self.arxiv_url = None
self.arxiv_primary_category = None
self.arxiv_primary_category_hr = None
self.published_hr = None
self.completion1 = None
self.completion2 = None
self.completion3 = None
self.predicted_newsworthiness = None
def set_arxiv_id(self, arxiv_id):
self.arxiv_id = arxiv_id
def set_title(self, title):
self.title = title
def set_summary(self, summary):
self.summary = summary
def set_published(self, published):
self.published = published
def set_published_hr(self, published_hr):
self.published_hr = published_hr
def set_arxiv_url(self, arxiv_url):
self.arxiv_url = arxiv_url
def set_arxiv_primary_category(self, arxiv_primary_category):
self.arxiv_primary_category = arxiv_primary_category
def set_arxiv_primary_category_hr(self, arxiv_primary_category_hr):
self.arxiv_primary_category_hr = arxiv_primary_category_hr
# def set_arxiv_all_categories(self, arxiv_all_categories):
# self.arxiv_all_categories = arxiv_all_categories
# def set_code_mentioned(self, code_mentioned):
# self.code_mentioned = code_mentioned
# def set_readability(self, readability):
# self.readability = readability
def set_completion1(self, completion1):
self.completion1 = completion1
def set_completion2(self, completion2):
self.completion2 = completion2
def set_completion3(self, completion3):
self.completion3 = completion3
def set_predicted_newsworthiness(self, predicted_newsworthiness):
# Out of 100 case
self.predicted_newsworthiness = str(int(predicted_newsworthiness))# +"/100"
# Out of 10 case
# self.predicted_newsworthiness = str(round(predicted_newsworthiness, 1))+"/10"
# self.predicted_newsworthiness = str(round(predicted_newsworthiness, 2)*100)[:2]+"/100"
# Change with newwest data update
def set_outlet_relevance(self, outlet_relevance):
if isinstance(outlet_relevance, str): # if it is N/A
self.outlet_relevance = outlet_relevance
else:
self.outlet_relevance = str(int(outlet_relevance*100))# + "/10"
def show(self):
'''Display the article card.'''
# Make a container
article_container = st.container()
# Make columns
main, aside = article_container.columns([4, 1])
# Main column
with main:
# New containers
header = st.container()
completions_container = st.container()
summary = st.container()
with header:
# Title
st.subheader(f"{self.title}")
# Published and link
st.markdown(
f"**Date Published**: {self.published_hr} \n **Primary Category**: {self.arxiv_primary_category_hr}")
with completions_container:
# Describe it
st.markdown(f"#### Potential news angles for framing this story:")
# Completions
st.markdown(f" \t 1. {self.completion1} \n 2. {self.completion2} \n 3. {self.completion3}")
with summary:
# Summary
st.markdown(f"#### Abstract: \n {self.summary} \n [Link to full arXiv article.]({self.arxiv_url})")
# Aside column stuff
aside.metric(
label="Newsworthiness",
value=self.predicted_newsworthiness)
aside.metric(
label="Outlet Similarity",
value=self.outlet_relevance)
article_container.markdown("""---""")
class articleCardSimilarity():
def __init__(self):
self.arxiv_id = None
self.title = None
self.summary = None
self.published = None
self.arxiv_url = None
self.arxiv_primary_category = None
self.arxiv_primary_category_hr = None
self.published_hr = None
self.completion1 = None
self.completion2 = None
self.completion3 = None
self.predicted_newsworthiness = None
def set_arxiv_id(self, arxiv_id):
self.arxiv_id = arxiv_id
def set_title(self, title):
self.title = title
def set_summary(self, summary):
self.summary = summary
def set_published(self, published):
self.published = published
def set_published_hr(self, published_hr):
self.published_hr = published_hr
def set_arxiv_url(self, arxiv_url):
self.arxiv_url = arxiv_url
def set_arxiv_primary_category(self, arxiv_primary_category):
self.arxiv_primary_category = arxiv_primary_category
def set_arxiv_primary_category_hr(self, arxiv_primary_category_hr):
self.arxiv_primary_category_hr = arxiv_primary_category_hr
# def set_arxiv_all_categories(self, arxiv_all_categories):
# self.arxiv_all_categories = arxiv_all_categories
# def set_code_mentioned(self, code_mentioned):
# self.code_mentioned = code_mentioned
# def set_readability(self, readability):
# self.readability = readability
def set_completion1(self, completion1):
self.completion1 = completion1
def set_completion2(self, completion2):
self.completion2 = completion2
def set_completion3(self, completion3):
self.completion3 = completion3
def set_predicted_newsworthiness(self, predicted_newsworthiness):
# Out of 100 case
self.predicted_newsworthiness = str(int(predicted_newsworthiness))# +"/100"
# Out of 10 case
# self.predicted_newsworthiness = str(round(predicted_newsworthiness, 1))+"/10"
# self.predicted_newsworthiness = str(round(predicted_newsworthiness, 2)*100)[:2]+"/100"
# Change with newwest data update
def set_outlet_relevance(self, outlet_relevance):
if isinstance(outlet_relevance, str): # if it is N/A
self.outlet_relevance = outlet_relevance
else:
self.outlet_relevance = str(int(outlet_relevance*100))# + "/10"
def show(self):
'''Display the article card.'''
# Make a container
article_container = st.container()
# Make columns
main, aside = article_container.columns([4, 1])
# Main column
with main:
# New containers
header = st.container()
completions_container = st.container()
summary = st.container()
with header:
# Title
st.subheader(f"{self.title}")
# Published and link
st.markdown(
f"**Date Published**: {self.published_hr} \n **Primary Category**: {self.arxiv_primary_category_hr}")
with completions_container:
# Describe it
st.markdown(f"#### Potential news angles for framing this story:")
# Completions
st.markdown(f" \t 1. {self.completion1} \n 2. {self.completion2} \n 3. {self.completion3}")
with summary:
# Summary
st.markdown(f"#### Abstract: \n {self.summary} \n [Link to full arXiv article.]({self.arxiv_url})")
# Aside column stuff
aside.metric(
label="Outlet Similarity",
value=self.outlet_relevance)
aside.metric(
label="Newsworthiness",
value=self.predicted_newsworthiness)
article_container.markdown("""---""")