Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -150,6 +150,28 @@ def fDistancePlot(text2Party,plotN=15):
|
|
150 |
return img1
|
151 |
|
152 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
|
154 |
def getSubjectivity(text):
|
155 |
|
@@ -230,11 +252,12 @@ def analysis(Manifesto,Search):
|
|
230 |
|
231 |
fdist_Party=fDistance(text_Party)
|
232 |
img4=fDistancePlot(text_Party)
|
|
|
233 |
|
234 |
searchRes=concordance(text_Party,Search)
|
235 |
searChRes=clean(searchRes)
|
236 |
searChRes=searchRes.replace(Search,"\u0332".join(Search))
|
237 |
-
return searChRes,fdist_Party,img1,img2,img3,img4
|
238 |
|
239 |
|
240 |
Search_txt=gr.inputs.Textbox()
|
@@ -245,8 +268,9 @@ plot1=gr.outputs. Image(label='Sentiment Analysis')
|
|
245 |
plot2=gr.outputs.Image(label='Subjectivity Analysis')
|
246 |
plot3=gr.outputs.Image(label='Word Cloud')
|
247 |
plot4=gr.outputs.Image(label='Frequency Distribution')
|
|
|
248 |
|
249 |
-
io=gr.Interface(fn=analysis, inputs=[filePdf,Search_txt], outputs=[text,mfw,plot1,plot2,plot3,plot4], title='Manifesto Analysis',examples=[['./Bjp_Manifesto_2019.pdf','development'],['./Aap_Manifesto_2019.pdf','delhi'],['./Congress_Manifesto_2019.pdf','safety']])
|
250 |
io.launch(debug=False,share=True)
|
251 |
#,examples=[['./Bjp_Manifesto_2019.pdf','india'],['./Aap_Manifesto_2019.pdf',],['./Congress_Manifesto_2019.pdf',]]
|
252 |
|
|
|
150 |
return img1
|
151 |
|
152 |
|
153 |
+
def DispersionPlot(textParty):
|
154 |
+
'''
|
155 |
+
Dispersion PLot
|
156 |
+
'''
|
157 |
+
word_tokens_party = word_tokenize(text2Party) #Tokenizing
|
158 |
+
moby = Text(word_tokens_party)
|
159 |
+
word_Lst=[]
|
160 |
+
for x in range(5):
|
161 |
+
word_Lst.append(fdist_Party.most_common(5)[x][0])
|
162 |
+
|
163 |
+
plt.axis('off')
|
164 |
+
plt.title('Dispersion Plot')
|
165 |
+
plt.figure(figsize=(4,3))
|
166 |
+
moby.dispersion_plot(word_Lst)
|
167 |
+
plt.tight_layout()
|
168 |
+
buf = BytesIO()
|
169 |
+
plt.savefig(buf)
|
170 |
+
buf.seek(0)
|
171 |
+
img = Image.open(buf)
|
172 |
+
plt.clf()
|
173 |
+
return img
|
174 |
+
|
175 |
|
176 |
def getSubjectivity(text):
|
177 |
|
|
|
252 |
|
253 |
fdist_Party=fDistance(text_Party)
|
254 |
img4=fDistancePlot(text_Party)
|
255 |
+
img5=DispersionPlot(text_Party)
|
256 |
|
257 |
searchRes=concordance(text_Party,Search)
|
258 |
searChRes=clean(searchRes)
|
259 |
searChRes=searchRes.replace(Search,"\u0332".join(Search))
|
260 |
+
return searChRes,fdist_Party,img1,img2,img3,img4,img5
|
261 |
|
262 |
|
263 |
Search_txt=gr.inputs.Textbox()
|
|
|
268 |
plot2=gr.outputs.Image(label='Subjectivity Analysis')
|
269 |
plot3=gr.outputs.Image(label='Word Cloud')
|
270 |
plot4=gr.outputs.Image(label='Frequency Distribution')
|
271 |
+
plot5=gr.outputs.Image(label='Dispersion Plot')
|
272 |
|
273 |
+
io=gr.Interface(fn=analysis, inputs=[filePdf,Search_txt], outputs=[text,mfw,plot1,plot2,plot3,plot4,plot5], title='Manifesto Analysis',examples=[['./Bjp_Manifesto_2019.pdf','development'],['./Aap_Manifesto_2019.pdf','delhi'],['./Congress_Manifesto_2019.pdf','safety']])
|
274 |
io.launch(debug=False,share=True)
|
275 |
#,examples=[['./Bjp_Manifesto_2019.pdf','india'],['./Aap_Manifesto_2019.pdf',],['./Congress_Manifesto_2019.pdf',]]
|
276 |
|