Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -201,13 +201,25 @@ def analysis(Manifesto,Search):
|
|
| 201 |
plt.ylabel('Counts')
|
| 202 |
plt.figure(figsize=(4,6))
|
| 203 |
df['Analysis on Polarity'].value_counts().plot(kind ='bar')
|
| 204 |
-
plt.savefig('./sentimentAnalysis.png')
|
| 205 |
-
plt.clf()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
|
| 207 |
plt.figure(figsize=(4,6))
|
| 208 |
df['Analysis on Subjectivity'].value_counts().plot(kind ='bar')
|
| 209 |
-
plt.savefig('sentimentAnalysis2.png')
|
| 210 |
-
plt.clf()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 211 |
|
| 212 |
wordcloud = WordCloud(max_words=2000, background_color="white",mode="RGB").generate(text_Party)
|
| 213 |
plt.figure(figsize=(4,3))
|
|
@@ -219,15 +231,15 @@ def analysis(Manifesto,Search):
|
|
| 219 |
fdist_Party=fDistance(text_Party)
|
| 220 |
fDistancePlot(text_Party)
|
| 221 |
|
| 222 |
-
img1=cv2.imread('/sentimentAnalysis.png')
|
| 223 |
-
img2=cv2.imread('/wordcloud.png')
|
| 224 |
-
img3=cv2.imread('/
|
| 225 |
img4=cv2.imread('/distplot.png')
|
| 226 |
|
| 227 |
searchRes=concordance(text_Party,Search)
|
| 228 |
searChRes=clean(searchRes)
|
| 229 |
searChRes=searchRes.replace(Search,"\u0332".join(Search))
|
| 230 |
-
return searChRes,fdist_Party,
|
| 231 |
|
| 232 |
|
| 233 |
Search_txt=gr.inputs.Textbox()
|
|
@@ -240,7 +252,7 @@ plot2=gr.outputs.Image(label='Word Cloud')
|
|
| 240 |
plot3=gr.outputs.Image(label='Subjectivity')
|
| 241 |
plot4=gr.outputs.Image(label='Frequency Distribution')
|
| 242 |
|
| 243 |
-
io=gr.Interface(fn=analysis, inputs=[filePdf,Search_txt], outputs=[text,mfw,
|
| 244 |
io.launch(debug=False,share=True)
|
| 245 |
|
| 246 |
|
|
|
|
| 201 |
plt.ylabel('Counts')
|
| 202 |
plt.figure(figsize=(4,6))
|
| 203 |
df['Analysis on Polarity'].value_counts().plot(kind ='bar')
|
| 204 |
+
#plt.savefig('./sentimentAnalysis.png')
|
| 205 |
+
#plt.clf()
|
| 206 |
+
plt.tight_layout()
|
| 207 |
+
buf = io.BytesIO()
|
| 208 |
+
plt.savefig(buf)
|
| 209 |
+
buf.seek(0)
|
| 210 |
+
img1 = Image.open(buf)
|
| 211 |
+
plt.clf()
|
| 212 |
|
| 213 |
plt.figure(figsize=(4,6))
|
| 214 |
df['Analysis on Subjectivity'].value_counts().plot(kind ='bar')
|
| 215 |
+
#plt.savefig('sentimentAnalysis2.png')
|
| 216 |
+
#plt.clf()
|
| 217 |
+
plt.tight_layout()
|
| 218 |
+
buf = io.BytesIO()
|
| 219 |
+
plt.savefig(buf)
|
| 220 |
+
buf.seek(0)
|
| 221 |
+
img2 = Image.open(buf)
|
| 222 |
+
plt.clf()
|
| 223 |
|
| 224 |
wordcloud = WordCloud(max_words=2000, background_color="white",mode="RGB").generate(text_Party)
|
| 225 |
plt.figure(figsize=(4,3))
|
|
|
|
| 231 |
fdist_Party=fDistance(text_Party)
|
| 232 |
fDistancePlot(text_Party)
|
| 233 |
|
| 234 |
+
#img1=cv2.imread('/sentimentAnalysis.png')
|
| 235 |
+
#img2=cv2.imread('/wordcloud.png')
|
| 236 |
+
img3=cv2.imread('/wordcloud.png')
|
| 237 |
img4=cv2.imread('/distplot.png')
|
| 238 |
|
| 239 |
searchRes=concordance(text_Party,Search)
|
| 240 |
searChRes=clean(searchRes)
|
| 241 |
searChRes=searchRes.replace(Search,"\u0332".join(Search))
|
| 242 |
+
return searChRes,fdist_Party,img1,img2,img3,img4
|
| 243 |
|
| 244 |
|
| 245 |
Search_txt=gr.inputs.Textbox()
|
|
|
|
| 252 |
plot3=gr.outputs.Image(label='Subjectivity')
|
| 253 |
plot4=gr.outputs.Image(label='Frequency Distribution')
|
| 254 |
|
| 255 |
+
io=gr.Interface(fn=analysis, inputs=[filePdf,Search_txt], outputs=[text,mfw,plot1,plot2,plot3,plot4], title='Manifesto Analysis',examples=[['./Bjp_Manifesto_2019.pdf','india'],['./Aap_Manifesto_2019.pdf',],['./Congress_Manifesto_2019.pdf',]])
|
| 256 |
io.launch(debug=False,share=True)
|
| 257 |
|
| 258 |
|