Spaces:
Sleeping
Sleeping
paragon-analytics
commited on
Commit
•
868eab7
1
Parent(s):
4260f66
Update app.py
Browse files
app.py
CHANGED
@@ -93,11 +93,26 @@ def process_final_text(text):
|
|
93 |
|
94 |
# Transformer Interpret:
|
95 |
word_attributions = cls_explainer(X_test)
|
96 |
-
|
97 |
-
|
98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
|
100 |
-
return {"Resilience": float(scores.numpy()[1]), "Non-Resilience": float(scores.numpy()[0])},keywords,NER,
|
101 |
|
102 |
def main(prob1):
|
103 |
text = str(prob1)
|
@@ -124,7 +139,10 @@ with gr.Blocks(title=title) as demo:
|
|
124 |
color_map={"+++": "royalblue","++": "cornflowerblue",
|
125 |
"+": "lightsteelblue", "NA":"white"})
|
126 |
NER = gr.HTML(label = 'NER:')
|
127 |
-
intp =
|
|
|
|
|
|
|
128 |
|
129 |
submit_btn.click(
|
130 |
main,
|
|
|
93 |
|
94 |
# Transformer Interpret:
|
95 |
word_attributions = cls_explainer(X_test)
|
96 |
+
letter = []
|
97 |
+
score = []
|
98 |
+
for i in word_attributions:
|
99 |
+
if i[1]>0.5:
|
100 |
+
a = "++"
|
101 |
+
elif (i[1]<=0.5) and (i[1]>0.1):
|
102 |
+
a = "+"
|
103 |
+
elif (i[1]>=-0.5) and (i[1]<-0.1):
|
104 |
+
a = "-"
|
105 |
+
elif i[1]<-0.5:
|
106 |
+
a = "--"
|
107 |
+
else:
|
108 |
+
a = "NA"
|
109 |
+
|
110 |
+
letter.append(i[0])
|
111 |
+
score.append(a)
|
112 |
+
|
113 |
+
word_attributions = [(letter[i], score[i]) for i in range(0, len(letter))]
|
114 |
|
115 |
+
return {"Resilience": float(scores.numpy()[1]), "Non-Resilience": float(scores.numpy()[0])},keywords,NER,word_attributions
|
116 |
|
117 |
def main(prob1):
|
118 |
text = str(prob1)
|
|
|
139 |
color_map={"+++": "royalblue","++": "cornflowerblue",
|
140 |
"+": "lightsteelblue", "NA":"white"})
|
141 |
NER = gr.HTML(label = 'NER:')
|
142 |
+
intp =gr.HighlightedText(label="Word Scores",
|
143 |
+
combine_adjacent=False).style(color_map={"++": "darkgreen","+": "green",
|
144 |
+
"--": "darkred",
|
145 |
+
"-": "red", "NA":"white"})
|
146 |
|
147 |
submit_btn.click(
|
148 |
main,
|