examples
Browse files
app.py
CHANGED
@@ -23,6 +23,14 @@ def unpack(result):
|
|
23 |
output[labels[res['label']]] = res['score']
|
24 |
return output
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
#text insert
|
28 |
input = st.text_area("Insert text to be analyzed", value="you stink",
|
@@ -50,16 +58,35 @@ else:
|
|
50 |
|
51 |
output = []
|
52 |
output.append(['Tweet', 'Highest', 'Score', 'Second Highest', 'Score'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
|
54 |
if st.button('Analyze'):
|
55 |
result = classifier(input)
|
56 |
result = result[0]
|
57 |
if option == 'Fine-Tuned':
|
58 |
result = unpack(result)
|
59 |
-
|
60 |
-
|
61 |
-
output.append([input, highest[0], highest[1], max(result, key=result.get), result[max(result, key=result.get)]])
|
62 |
-
st.table(output)
|
63 |
else:
|
64 |
st.write(result)
|
65 |
else:
|
|
|
23 |
output[labels[res['label']]] = res['score']
|
24 |
return output
|
25 |
|
26 |
+
def add_to_table(result, output):
|
27 |
+
highest = (max(result, key=result.get), result[max(result, key=result.get)])
|
28 |
+
result.pop(max(result, key=result.get))
|
29 |
+
output.append([input, highest[0], highest[1], max(result, key=result.get),
|
30 |
+
result[max(result, key=result.get)]])
|
31 |
+
|
32 |
+
|
33 |
+
|
34 |
|
35 |
#text insert
|
36 |
input = st.text_area("Insert text to be analyzed", value="you stink",
|
|
|
58 |
|
59 |
output = []
|
60 |
output.append(['Tweet', 'Highest', 'Score', 'Second Highest', 'Score'])
|
61 |
+
strings = [ "D'aww! He matches this background colour I'm seemingly stuck with. Thanks. (talk) 21:51, January 11, 2016 (UTC)",
|
62 |
+
"Hey man, I'm really not trying to edit war. It's just that this guy is constantly removing relevant information and talking to me through edits instead of my talk page. He seems to care more about the formatting than the actual info.",
|
63 |
+
"Why can't you believe how fat Artie is? Did you see him on his recent appearence on the Tonight Show with Jay Leno? He looks absolutely AWFUL! If I had to put money on it, I'd say that Artie Lange is a can't miss candidate for the 2007 Dead pool! \
|
64 |
+
Kindly keep your malicious fingers off of my above comment, . Everytime you remove it, I will repost it!!!",
|
65 |
+
"Thank you. This would make my life complete. ",
|
66 |
+
"Would you both shut up, you don't run wikipedia, especially a stupid kid.",
|
67 |
+
"Please stop. If you continue to vandalize Wikipedia, as you did to Homosexuality, you will be blocked from editing.",
|
68 |
+
"== Arabs are committing genocide in Iraq, but no protests in Europe. == May Europe also burn in hell.",
|
69 |
+
":yeah, thanks for reviving the tradition of pissing all over articles because you want to live out your ethnic essentialism. Why let mere facts get into the way of enjoying that.",
|
70 |
+
"==Category:Italian Jews== :Category:Italian Jews, which you created, has been nominated for possible deletion, merging, or renaming. If you would like to participate in the discussion, you are invited to add your comments at the category's entry on the Categories for discussion page. Thank you.",
|
71 |
+
"KSchwartz is an annoying person who often smells of rotten fish and burnt animal hair. He has a passing interest in Wikipedia."
|
72 |
+
]
|
73 |
+
|
74 |
+
for string in strings:
|
75 |
+
result = classifier(string)
|
76 |
+
result = result[0]
|
77 |
+
result = unpack(result)
|
78 |
+
add_to_table(result, output)
|
79 |
+
|
80 |
+
st.table(output)
|
81 |
+
|
82 |
|
83 |
if st.button('Analyze'):
|
84 |
result = classifier(input)
|
85 |
result = result[0]
|
86 |
if option == 'Fine-Tuned':
|
87 |
result = unpack(result)
|
88 |
+
add_to_table(result, output)
|
89 |
+
# st.table(output)
|
|
|
|
|
90 |
else:
|
91 |
st.write(result)
|
92 |
else:
|