Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -153,8 +153,13 @@ def fDistancePlot(text2Party,plotN=30):
|
|
153 |
fdistance = FreqDist(word_tokens_party)
|
154 |
plt.figure(figsize=(4,6))
|
155 |
fdistance.plot(plotN)
|
156 |
-
plt.
|
157 |
-
|
|
|
|
|
|
|
|
|
|
|
158 |
|
159 |
|
160 |
|
@@ -200,7 +205,7 @@ def analysis(Manifesto,Search):
|
|
200 |
plt.title('Sentiment Analysis')
|
201 |
plt.xlabel('Sentiment')
|
202 |
plt.ylabel('Counts')
|
203 |
-
plt.figure(figsize=(4,
|
204 |
df['Analysis on Polarity'].value_counts().plot(kind ='bar')
|
205 |
#plt.savefig('./sentimentAnalysis.png')
|
206 |
#plt.clf()
|
@@ -211,7 +216,7 @@ def analysis(Manifesto,Search):
|
|
211 |
img1 = Image.open(buf)
|
212 |
plt.clf()
|
213 |
|
214 |
-
plt.figure(figsize=(4,
|
215 |
df['Analysis on Subjectivity'].value_counts().plot(kind ='bar')
|
216 |
#plt.savefig('sentimentAnalysis2.png')
|
217 |
#plt.clf()
|
@@ -225,17 +230,21 @@ def analysis(Manifesto,Search):
|
|
225 |
wordcloud = WordCloud(max_words=2000, background_color="white",mode="RGB").generate(text_Party)
|
226 |
plt.figure(figsize=(4,3))
|
227 |
plt.imshow(wordcloud, interpolation="bilinear")
|
228 |
-
plt.axis("off")
|
229 |
-
plt.
|
230 |
-
|
|
|
|
|
|
|
|
|
231 |
|
232 |
fdist_Party=fDistance(text_Party)
|
233 |
-
fDistancePlot(text_Party)
|
234 |
|
235 |
#img1=cv2.imread('/sentimentAnalysis.png')
|
236 |
#img2=cv2.imread('/wordcloud.png')
|
237 |
-
img3=cv2.imread('/wordcloud.png')
|
238 |
-
img4=cv2.imread('/distplot.png')
|
239 |
|
240 |
searchRes=concordance(text_Party,Search)
|
241 |
searChRes=clean(searchRes)
|
@@ -249,24 +258,12 @@ text = gr.outputs.Textbox(label='SEARCHED OUTPUT')
|
|
249 |
mfw=gr.outputs.Label(label="Most Relevant Topics")
|
250 |
# mfw2=gr.outputs.Image(label="Most Relevant Topics Plot")
|
251 |
plot1=gr.outputs. Image(label='Sentiment Analysis')
|
252 |
-
plot2=gr.outputs.Image(label='
|
253 |
-
plot3=gr.outputs.Image(label='
|
254 |
plot4=gr.outputs.Image(label='Frequency Distribution')
|
255 |
|
256 |
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',]])
|
257 |
io.launch(debug=False,share=True)
|
258 |
|
259 |
|
260 |
-
#examples=[['/Bjp_Manifesto_2019.pdf',],['/Aap_Manifesto_2019.pdf',]],
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
|
|
|
153 |
fdistance = FreqDist(word_tokens_party)
|
154 |
plt.figure(figsize=(4,6))
|
155 |
fdistance.plot(plotN)
|
156 |
+
plt.tight_layout()
|
157 |
+
buf = BytesIO()
|
158 |
+
plt.savefig(buf)
|
159 |
+
buf.seek(0)
|
160 |
+
img1 = Image.open(buf)
|
161 |
+
plt.clf()
|
162 |
+
return img1
|
163 |
|
164 |
|
165 |
|
|
|
205 |
plt.title('Sentiment Analysis')
|
206 |
plt.xlabel('Sentiment')
|
207 |
plt.ylabel('Counts')
|
208 |
+
plt.figure(figsize=(4,3))
|
209 |
df['Analysis on Polarity'].value_counts().plot(kind ='bar')
|
210 |
#plt.savefig('./sentimentAnalysis.png')
|
211 |
#plt.clf()
|
|
|
216 |
img1 = Image.open(buf)
|
217 |
plt.clf()
|
218 |
|
219 |
+
plt.figure(figsize=(4,3))
|
220 |
df['Analysis on Subjectivity'].value_counts().plot(kind ='bar')
|
221 |
#plt.savefig('sentimentAnalysis2.png')
|
222 |
#plt.clf()
|
|
|
230 |
wordcloud = WordCloud(max_words=2000, background_color="white",mode="RGB").generate(text_Party)
|
231 |
plt.figure(figsize=(4,3))
|
232 |
plt.imshow(wordcloud, interpolation="bilinear")
|
233 |
+
plt.axis("off")
|
234 |
+
plt.tight_layout()
|
235 |
+
buf = BytesIO()
|
236 |
+
plt.savefig(buf)
|
237 |
+
buf.seek(0)
|
238 |
+
img3 = Image.open(buf)
|
239 |
+
plt.clf()
|
240 |
|
241 |
fdist_Party=fDistance(text_Party)
|
242 |
+
img4=fDistancePlot(text_Party)
|
243 |
|
244 |
#img1=cv2.imread('/sentimentAnalysis.png')
|
245 |
#img2=cv2.imread('/wordcloud.png')
|
246 |
+
#img3=cv2.imread('/wordcloud.png')
|
247 |
+
#img4=cv2.imread('/distplot.png')
|
248 |
|
249 |
searchRes=concordance(text_Party,Search)
|
250 |
searChRes=clean(searchRes)
|
|
|
258 |
mfw=gr.outputs.Label(label="Most Relevant Topics")
|
259 |
# mfw2=gr.outputs.Image(label="Most Relevant Topics Plot")
|
260 |
plot1=gr.outputs. Image(label='Sentiment Analysis')
|
261 |
+
plot2=gr.outputs.Image(label='Subjectivity Analysis')
|
262 |
+
plot3=gr.outputs.Image(label='Word Cloud')
|
263 |
plot4=gr.outputs.Image(label='Frequency Distribution')
|
264 |
|
265 |
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',]])
|
266 |
io.launch(debug=False,share=True)
|
267 |
|
268 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
269 |
|