First try: select sample articles and auto-load their text in text-area
Browse files- .idea/.gitignore +3 -0
- .idea/HFSummSpace.iml +14 -0
- .idea/inspectionProfiles/profiles_settings.xml +6 -0
- .idea/misc.xml +4 -0
- .idea/modules.xml +8 -0
- .idea/vcs.xml +6 -0
- app.py +54 -29
- sample-articles/Biden.txt +69 -0
- sample-articles/Protestors.txt +25 -0
.idea/.gitignore
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
# Default ignored files
|
2 |
+
/shelf/
|
3 |
+
/workspace.xml
|
.idea/HFSummSpace.iml
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<module type="PYTHON_MODULE" version="4">
|
3 |
+
<component name="NewModuleRootManager">
|
4 |
+
<content url="file://$MODULE_DIR$">
|
5 |
+
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
6 |
+
</content>
|
7 |
+
<orderEntry type="inheritedJdk" />
|
8 |
+
<orderEntry type="sourceFolder" forTests="false" />
|
9 |
+
</component>
|
10 |
+
<component name="PyDocumentationSettings">
|
11 |
+
<option name="format" value="PLAIN" />
|
12 |
+
<option name="myDocStringFormat" value="Plain" />
|
13 |
+
</component>
|
14 |
+
</module>
|
.idea/inspectionProfiles/profiles_settings.xml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<component name="InspectionProjectProfileManager">
|
2 |
+
<settings>
|
3 |
+
<option name="USE_PROJECT_PROFILE" value="false" />
|
4 |
+
<version value="1.0" />
|
5 |
+
</settings>
|
6 |
+
</component>
|
.idea/misc.xml
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (HFSummSpace)" project-jdk-type="Python SDK" />
|
4 |
+
</project>
|
.idea/modules.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="ProjectModuleManager">
|
4 |
+
<modules>
|
5 |
+
<module fileurl="file://$PROJECT_DIR$/.idea/HFSummSpace.iml" filepath="$PROJECT_DIR$/.idea/HFSummSpace.iml" />
|
6 |
+
</modules>
|
7 |
+
</component>
|
8 |
+
</project>
|
.idea/vcs.xml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="VcsDirectoryMappings">
|
4 |
+
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
5 |
+
</component>
|
6 |
+
</project>
|
app.py
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
import random
|
|
|
2 |
|
3 |
import streamlit as st
|
4 |
from bs4 import BeautifulSoup
|
5 |
|
6 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
7 |
from transformers import pipeline
|
|
|
8 |
from transformers_interpret import SequenceClassificationExplainer
|
9 |
|
10 |
# Map model names to URLs
|
@@ -96,6 +98,17 @@ def format_explainer_html(html_string):
|
|
96 |
|
97 |
return p
|
98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
|
100 |
def classify_comment(comment, selected_model):
|
101 |
"""Classify the given comment and augment with additional information."""
|
@@ -150,36 +163,48 @@ Try it yourself! 👇""",
|
|
150 |
|
151 |
|
152 |
# Demo
|
153 |
-
with st.form("dutch-toxic-comment-detection-input", clear_on_submit=True):
|
154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
)#index=0, format_func=special_internal_function, key=None, help=None, on_change=None, args=None, kwargs=None, *, disabled=False)
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
|
|
|
|
161 |
|
162 |
# Listener
|
163 |
-
if submitted:
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
# Results
|
171 |
-
if 'results' in st.session_state and st.session_state.results:
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
|
|
|
1 |
import random
|
2 |
+
from typing import AnyStr
|
3 |
|
4 |
import streamlit as st
|
5 |
from bs4 import BeautifulSoup
|
6 |
|
7 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
8 |
from transformers import pipeline
|
9 |
+
import os
|
10 |
from transformers_interpret import SequenceClassificationExplainer
|
11 |
|
12 |
# Map model names to URLs
|
|
|
98 |
|
99 |
return p
|
100 |
|
101 |
+
def list_all_filenames() -> list:
|
102 |
+
filenames = []
|
103 |
+
for file in os.listdir('./sample-articles/'):
|
104 |
+
if file.endswith('.txt'):
|
105 |
+
filenames.append(file.replace('.txt', ''))
|
106 |
+
return filenames
|
107 |
+
|
108 |
+
def fetch_file_contents(filename: str) -> AnyStr:
|
109 |
+
with open(f'./sample-terms-and-conditions/{filename.lower()}.txt', 'r') as f:
|
110 |
+
data = f.read()
|
111 |
+
return data
|
112 |
|
113 |
def classify_comment(comment, selected_model):
|
114 |
"""Classify the given comment and augment with additional information."""
|
|
|
163 |
|
164 |
|
165 |
# Demo
|
166 |
+
# with st.form("dutch-toxic-comment-detection-input", clear_on_submit=True):
|
167 |
+
# selected_model = st.selectbox('Select a model:', model_names_to_URLs.keys(),
|
168 |
+
# )#index=0, format_func=special_internal_function, key=None, help=None, on_change=None, args=None, kwargs=None, *, disabled=False)
|
169 |
+
# text = st.text_area(
|
170 |
+
# label='Enter the comment you want to classify below (in Dutch):')
|
171 |
+
# _, rightmost_col = st.columns([6,1])
|
172 |
+
# submitted = rightmost_col.form_submit_button("Classify",
|
173 |
+
# help="Classify comment")
|
174 |
+
|
175 |
+
with st.form("article-inpu"):
|
176 |
+
# TODO: should probably set a minimum length of article or something
|
177 |
+
selected_article = st.selectbox('Select an article or provide your own:', list_all_filenames(),
|
178 |
)#index=0, format_func=special_internal_function, key=None, help=None, on_change=None, args=None, kwargs=None, *, disabled=False)
|
179 |
+
st.session_state.article_text = fetch_file_contents(selected_article)
|
180 |
+
article_text = st.text_area(
|
181 |
+
#label='Enter the comment you want to classify below (in Dutch):')
|
182 |
+
value = st.session_state.article_text)
|
183 |
+
#_, rightmost_col = st.columns([6,1])
|
184 |
+
#submitted = rightmost_col.form_submit_button("Classify",
|
185 |
+
#help="Classify comment")
|
186 |
|
187 |
# Listener
|
188 |
+
# if submitted:
|
189 |
+
# if text:
|
190 |
+
# with st.spinner('Analysing comment...'):
|
191 |
+
# classify_comment(text, selected_model)
|
192 |
+
# else:
|
193 |
+
# st.error('**Error**: No comment to classify. Please provide a comment.')
|
194 |
+
#
|
195 |
+
# # Results
|
196 |
+
# if 'results' in st.session_state and st.session_state.results:
|
197 |
+
# first = True
|
198 |
+
# for result in st.session_state.results[::-1]:
|
199 |
+
# if not first:
|
200 |
+
# st.markdown("---")
|
201 |
+
# st.markdown(f"Text:\n> {result['text']}")
|
202 |
+
# col_1, col_2, col_3 = st.columns([1,2,2])
|
203 |
+
# col_1.metric(label='', value=f"{result['emoji']}")
|
204 |
+
# col_2.metric(label='Label', value=f"{result['label']}")
|
205 |
+
# col_3.metric(label='Score', value=f"{result['score']:.3f}")
|
206 |
+
# st.markdown(f"Token Attribution:\n{result['tokens_with_background']}",
|
207 |
+
# unsafe_allow_html=True)
|
208 |
+
# st.caption(f"Model: {result['model_name']}")
|
209 |
+
# first = False
|
210 |
|
sample-articles/Biden.txt
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
The White House says President Joe Biden told Russian President Vladimir Putin on Tuesday that the United States is prepared to launch strong economic measures should Russia invade Ukraine -- signaling that these new measures would pack a bigger punch than the sanctions issued in 2014 that failed to stop Russia from occupying Crimea.
|
2 |
+
|
3 |
+
"I will look you in the eye and tell you, as President Biden looked Putin in the eye and told him today, that things we did not do in 2014 we are prepared to do now," national security adviser Jake Sullivan told reporters Tuesday afternoon after Biden's call with Putin.
|
4 |
+
|
5 |
+
During the last several months, Russia has erected supply lines, including medical units and fuel, which could sustain a drawn-out conflict should Moscow choose to invade Ukraine, two sources familiar with the latest intelligence assessments told CNN. And recent US intelligence findings estimate Russia could begin a military offensive in Ukraine in a matter of months as it amasses up to 175,000 troops along the border. Sullivan said the administration still believes Putin has not made a decision on whether to to launch a military offensive against Ukraine.
|
6 |
+
|
7 |
+
Sullivan did not go into specifics, but added that the US is coordinating with European allies "at a deep level of specificity."
|
8 |
+
|
9 |
+
He said Biden "was direct and straightforward with President Putin, as he always is," later adding that "there was a lot of give and take. There was no finger-wagging, but the President was crystal clear about where the United States stands on all of these issues."
|
10 |
+
|
11 |
+
Along with the economic ramifications mentioned on the call, Sullivan said Biden relayed that the US is prepared to bolster defense capabilities in the region.
|
12 |
+
|
13 |
+
"He reiterated America's support for Ukraine's sovereignty and territorial integrity. He told President Putin directly that if Russia further invades Ukraine, the United States and our European allies would respond with strong economic measures," Sullivan said. "We would provide additional defensive materiel to the Ukrainians above and beyond that which we are already providing, and we would fortify our NATO allies on the eastern flank with additional capabilities in response to such an escalation."
|
14 |
+
|
15 |
+
The other option, Sullivan said, is de-escalation and diplomacy.
|
16 |
+
|
17 |
+
"The United States and our European allies would engage in a larger discussion that covers strategic issues, including our strategic concerns with Russia and Russia's strategic concerns. We managed to do this at the height of the Cold War and we developed mechanisms to help reduce instability and increase transparency," he said.
|
18 |
+
|
19 |
+
A call in the Situation Room
|
20 |
+
|
21 |
+
Biden and Putin spoke for about two hours over a secure video call earlier Tuesday.
|
22 |
+
|
23 |
+
The two presidents tasked their respective teams with following up on their discussions, with the White House adding that "the US will do so in close coordination with allies and partners."
|
24 |
+
|
25 |
+
In addition to the Ukraine issue, the two leaders discussed "the US-Russia dialogue on Strategic Stability, a separate dialogue on ransomware, as well as joint work on regional issues such as Iran," the White House said.
|
26 |
+
|
27 |
+
A White House photograph from the meeting, which began at 10:07 a.m. ET and ended at 12:08 p.m. ET, showed that Secretary of State Antony Blinken, Sullivan and senior director for Russia and Central Asia Eric Green were seated next to Biden in the Situation Room during the video call.
|
28 |
+
|
29 |
+
The two leaders took part in a summit in Geneva last June. Their last publicly known call was in July.
|
30 |
+
|
31 |
+
Later Tuesday afternoon, Biden spoke with President Emmanuel Macron of France, Chancellor Angela Merkel of Germany, Prime Minister Mario Draghi of Italy and Prime Minister Boris Johnson of the United Kingdom -- the same group of European allies he conferred with Monday night. Tuesday marks Merkel's final full day in office.
|
32 |
+
|
33 |
+
Biden briefed the allies on the Putin call and, according to a White House statement, the "leaders underscored their support for Ukraine's sovereignty and territorial integrity, as well as the need for Russia to reduce tensions and engage in diplomacy."
|
34 |
+
|
35 |
+
Sullivan said during Tuesday's press briefing that the White House team was debriefing the embassies of NATO members, European Union members and key Indo-Pacific allies on the US-Russia call. Biden will speak with Ukrainian President Volodymyr Zelensky on Thursday.
|
36 |
+
|
37 |
+
Biden is also expected to speak with the leaders of both houses of Congress to discuss "ways in which the administration and the Congress can work together on a bipartisan basis to stand up for American interests and values and stand behind our friends and partners," Sullivan added.
|
38 |
+
|
39 |
+
The Russians said in their readout of the Biden-Putin meeting that Ukraine was the "predominant" subject of the conversation and Biden had "emphasized the allegedly 'threatening' nature of the movements of Russian troops near the Ukrainian borders and outlined sanctions measures that the United States and its allies would be ready to apply in the event of a further escalation of the situation."
|
40 |
+
|
41 |
+
"In response, Vladimir Putin stressed that the responsibility should not be shifted onto the shoulders of Russia, since it is NATO that is making dangerous attempts to conquer Ukrainian territory and is building up its military potential at our borders," the Kremlin statement said. "Therefore, Russia is seriously interested in obtaining reliable, legally fixed guarantees excluding the expansion of NATO in the eastern direction and the deployment of offensive strike weapons systems in the states adjacent to Russia."
|
42 |
+
|
43 |
+
Putin aide Yury Ushakov told reporters on a conference call Tuesday night that the Russian President told Biden while Americans are worried about Russian troops thousands of kilometers away from the United States, Moscow is "really worried about our security, the security of Russia in a global sense."
|
44 |
+
|
45 |
+
Asked if Putin promised Biden that he would not use his troops in Ukraine, Ushakov dismissed the idea of an invasion.
|
46 |
+
|
47 |
+
"There was not even such a discussion. What do you mean to bring in troops, what is it -- an invasion, or what? This was out of the question," Ushakov said.
|
48 |
+
|
49 |
+
Measures under consideration
|
50 |
+
|
51 |
+
US officials in recent days have weighed whether to issue wide-reaching sanctions on Russia meant to deter Putin from launching an invasion into Ukraine. They include new actions against members of Putin's inner circle and on Russian energy producers, and one potential "nuclear option" -- disconnecting Russia from the SWIFT international payment system used by banks around the world.
|
52 |
+
|
53 |
+
The officials said final decisions hadn't been made on whether and when to apply the new sanctions, and said the Biden administration is currently in talks with European partners -- many of whom have closer economic relationships to Russia -- in the hopes of coordinating action.
|
54 |
+
|
55 |
+
Along with considerations of economic sanctions, the administration is also exploring options for a potential evacuation of US citizens from Ukraine if Russia were to invade the country and create a dire security situation, half a dozen sources tell CNN. The contingency planning is being led by the Pentagon, the sources said, and comes as the administration briefs Congress on how the US is preparing. In a "gloomy" briefing to senators by senior State Department official Victoria Nuland on Monday night, Nuland outlined the tough sanctions package being prepared by the administration in response to a potential Russian attack but acknowledged that the US' options to deter an invasion are fairly limited, a person familiar with the briefing said.
|
56 |
+
|
57 |
+
Nuland said on Tuesday that it is the US expectation that the controversial Nord Stream 2 pipeline "will be suspended" if Russia moves on Ukraine.
|
58 |
+
|
59 |
+
But the White House relayed that while conversations are being had with Germany about the pipeline in the context of a potential invasion of Ukraine by Russia, taking action may not necessarily be the most effective deterrent against Russian aggression.
|
60 |
+
|
61 |
+
The European Union "continues to fully support Ukraine in the face of the Russian aggression," European Commission President Ursula von der Leyen said in a tweet on Tuesday.
|
62 |
+
|
63 |
+
"We will respond to any further aggressions, by scaling-up and expanding existing sanctions," she added.
|
64 |
+
|
65 |
+
She also said the EU was "ready to take additional restrictive measures, in coordination with our partners."
|
66 |
+
|
67 |
+
"The rise of extremism and autocracy can also be a security issue for countries. In this context, we must also speak about the Russian military movements and their massive build-up along Ukraine's eastern border," she continued.
|
68 |
+
|
69 |
+
This story has been updated with additional developments Tuesday.
|
sample-articles/Protestors.txt
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Hundreds of protestors demonstrated at Boise State University in Idaho over the weekend following comments made at a conference by a professor who said men should be prioritized for fields of study such as engineering, medicine and law.
|
2 |
+
|
3 |
+
BSU political science professor Scott Yenor made disparaging remarks about women and spoke critically of feminism at the National Conservatism Conference in Orlando, Florida, on October 31 in a speech titled "The Family Form that Nations Need."
|
4 |
+
|
5 |
+
"Every effort made must be made not to recruit women into engineering, but rather to recruit and demand more of men who become engineers," Yenor said. "Ditto for med school, and the law, and every trade."
|
6 |
+
|
7 |
+
CNN has reached out to Yenor for comment but has not heard back.
|
8 |
+
|
9 |
+
In response to the attention the video received recently on social media, Yenor said on Twitter that "making special efforts to recruit women into fields where they don't seem to want to be" should be stopped, and he denied wanting to prevent women from obtaining those professions.
|
10 |
+
|
11 |
+
He also posted a video in which he said the country should "elevate the importance of family life for both men and women in America."
|
12 |
+
|
13 |
+
Boise State issued a statement saying it doesn't endorse Yenor's comments yet "cannot infringe" on his ability to make them.
|
14 |
+
|
15 |
+
"Boise State University understands that the open exchange of ideas, which is fundamental to education, can introduce uncomfortable and even offensive ideas," the statement said. "However, the university cannot infringe upon the First Amendment rights of anyone in our community, regardless of whether we, as individual leaders, agree or disagree with the message. No single faculty member defines what Boise State -- or any public university -- endorses or stands for."
|
16 |
+
|
17 |
+
Idaho state representative Brooke Green told CNN that Yenor's beliefs are "not only outdated, but completely sexist and reflect a society that no longer exists."
|
18 |
+
|
19 |
+
Green helped organize the event Saturday at the university to counter Yenor's remarks, and said there were about 500 men and women in attendance.
|
20 |
+
|
21 |
+
"Many young women at the university are worried their futures are in the hands of a tenured professor who believes they do not deserve to be there and occupy a seat that belongs to a man," Green said.
|
22 |
+
|
23 |
+
"Women shouldn't have to spend time today defending our value in society or rights as human beings however, women wanted to gather to send a message saying we will continue to occupy professional spaces, whether it's a boardroom, courtroom, or leadership role within our community," she said.
|
24 |
+
|
25 |
+
Boise State is the largest university in Idaho with nearly 20,000 students.
|