Update app.py
Browse files
app.py
CHANGED
|
@@ -151,6 +151,31 @@ def ner_results(ner_object, groups=True, NER_THRESHOLD=0.5) -> List[str]:
|
|
| 151 |
ner_list = [i for i in set(people) if len(i) > 2] + [i for i in set(places) if len(i) > 2] + [i for i in set(orgs) if len(i) > 2] + [i for i in set(misc) if len(i) > 2]
|
| 152 |
|
| 153 |
return ner_list
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
|
| 155 |
# These could be passed through the command line
|
| 156 |
# or read from a config file.
|
|
@@ -249,29 +274,7 @@ with st.form(key='columns_in_form'):
|
|
| 249 |
st.write("Here are some stats about the summarization:\n")
|
| 250 |
|
| 251 |
# Summarize the findings for all models
|
| 252 |
-
|
| 253 |
-
original_length = [outdata['summaries'][i]['original_length'] for i in outdata['summaries']]
|
| 254 |
-
summarized_length = [outdata['summaries'][i]['summary_length'] for i in outdata['summaries']]
|
| 255 |
-
x = np.arange(len(labels)) # the label locations
|
| 256 |
-
width = 0.35 # the width of the bars
|
| 257 |
-
|
| 258 |
-
fig, ax = plt.subplots(figsize=(14,8))
|
| 259 |
-
rects1 = ax.bar(x - width/2, original_length, width, color='lightgreen',zorder=0)
|
| 260 |
-
rects2 = ax.bar(x + width/2, summarized_length, width, color='lightblue',zorder=0)
|
| 261 |
-
|
| 262 |
-
rects3 = ax.bar(x - width/2, original_length, width, color='none',edgecolor='black', hatch='XX', lw=1.25,zorder=1)
|
| 263 |
-
rects4 = ax.bar(x + width/2, summarized_length, width, color='none',edgecolor='black', hatch='xx', lw=1.25,zorder=1)
|
| 264 |
-
|
| 265 |
-
# Add some text for labels, title and custom x-axis tick labels, etc.
|
| 266 |
-
ax.set_ylabel('Text Length')
|
| 267 |
-
ax.set_xticks(x)
|
| 268 |
-
ax.set_yticks([i for i in range(0,max(original_length),max(summarized_length))])
|
| 269 |
-
ax.set_xticklabels(labels)
|
| 270 |
-
ax.set_xlabel('Article')
|
| 271 |
-
|
| 272 |
-
plt.title('Original to Summarized Lengths in Space-Separated Tokens')
|
| 273 |
-
#ax.hist(arr, bins=20)
|
| 274 |
-
st.pyplot(fig)
|
| 275 |
|
| 276 |
|
| 277 |
"st.session_state object:", st.session_state
|
|
|
|
| 151 |
ner_list = [i for i in set(people) if len(i) > 2] + [i for i in set(places) if len(i) > 2] + [i for i in set(orgs) if len(i) > 2] + [i for i in set(misc) if len(i) > 2]
|
| 152 |
|
| 153 |
return ner_list
|
| 154 |
+
|
| 155 |
+
def show_length_graph():
|
| 156 |
+
labels = [i for i in range(outdata['article_count'])]
|
| 157 |
+
original_length = [outdata['summaries'][i]['original_length'] for i in outdata['summaries']]
|
| 158 |
+
summarized_length = [outdata['summaries'][i]['summary_length'] for i in outdata['summaries']]
|
| 159 |
+
x = np.arange(len(labels)) # the label locations
|
| 160 |
+
width = 0.35 # the width of the bars
|
| 161 |
+
|
| 162 |
+
fig, ax = plt.subplots(figsize=(14,8))
|
| 163 |
+
rects1 = ax.bar(x - width/2, original_length, width, color='lightgreen',zorder=0)
|
| 164 |
+
rects2 = ax.bar(x + width/2, summarized_length, width, color='lightblue',zorder=0)
|
| 165 |
+
|
| 166 |
+
rects3 = ax.bar(x - width/2, original_length, width, color='none',edgecolor='black', hatch='XX', lw=1.25,zorder=1)
|
| 167 |
+
rects4 = ax.bar(x + width/2, summarized_length, width, color='none',edgecolor='black', hatch='xx', lw=1.25,zorder=1)
|
| 168 |
+
|
| 169 |
+
# Add some text for labels, title and custom x-axis tick labels, etc.
|
| 170 |
+
ax.set_ylabel('Text Length')
|
| 171 |
+
ax.set_xticks(x)
|
| 172 |
+
ax.set_yticks([i for i in range(0,max(original_length),max(summarized_length))])
|
| 173 |
+
ax.set_xticklabels(labels)
|
| 174 |
+
ax.set_xlabel('Article')
|
| 175 |
+
|
| 176 |
+
plt.title('Original to Summarized Lengths in Space-Separated Tokens')
|
| 177 |
+
#ax.hist(arr, bins=20)
|
| 178 |
+
st.pyplot(fig)
|
| 179 |
|
| 180 |
# These could be passed through the command line
|
| 181 |
# or read from a config file.
|
|
|
|
| 274 |
st.write("Here are some stats about the summarization:\n")
|
| 275 |
|
| 276 |
# Summarize the findings for all models
|
| 277 |
+
show_length_graph()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 278 |
|
| 279 |
|
| 280 |
"st.session_state object:", st.session_state
|