Sa-m commited on
Commit
d5beb0e
1 Parent(s): afae3ae

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -12
app.py CHANGED
@@ -242,13 +242,12 @@ def Image_Processed(path):
242
  ret, bw_img = cv2.threshold(img, 124, 255, cv2.THRESH_BINARY)
243
 
244
  return bw_img
245
-
246
- def WordCloud(orgIm,mask_img,text_Party_pr,maxWord=2000,colorGener=True,
247
  contCol='white',bckColor='white'):
248
  '''
249
- Generating word cloud
250
- '''
251
-
252
  mask =mask_img
253
  # Create and generate a word cloud image:
254
  wordcloud = WordCloud(max_words=maxWord, background_color=bckColor,
@@ -262,7 +261,7 @@ def WordCloud(orgIm,mask_img,text_Party_pr,maxWord=2000,colorGener=True,
262
  # create coloring from image
263
 
264
 
265
-
266
  if colorGener==True:
267
  image_colors = ImageColorGenerator(orgIm)
268
  plt.imshow(wordcloud.recolor(color_func= image_colors),interpolation="bilinear")
@@ -272,8 +271,8 @@ def WordCloud(orgIm,mask_img,text_Party_pr,maxWord=2000,colorGener=True,
272
  plt.imshow(wordcloud)
273
 
274
 
275
- plt.axis("off")
276
 
 
277
  def word_cloud_generator(parsed_text_name,text_Party):
278
  parsed=parsed_text_name.lower()
279
 
@@ -281,7 +280,7 @@ def word_cloud_generator(parsed_text_name,text_Party):
281
  orgImg=Original_Image('BJPMain.jpg')
282
  bwImg=Image_Processed('BJPMain.jpg')
283
  plt.figure(figsize=(5,4))
284
- wordCloud(orgImg,bwImg,text_Party,maxWord=3000,colorGener=True,
285
  contCol='white', bckColor='black')
286
  plt.tight_layout()
287
  buf = BytesIO()
@@ -296,7 +295,7 @@ def word_cloud_generator(parsed_text_name,text_Party):
296
  orgImg=Original_Image('congress3.jpeg')
297
  bwImg=Image_Processed('congress3.jpeg')
298
  plt.figure(figsize=(5,4))
299
- wordCloud(orgImg,bwImg,text_Party,maxWord=3000,colorGener=True)
300
 
301
  plt.tight_layout()
302
  buf = BytesIO()
@@ -312,7 +311,7 @@ def word_cloud_generator(parsed_text_name,text_Party):
312
  orgImg=Original_Image('aapMain2.jpg')
313
  bwImg=Image_Processed('aapMain2.jpg')
314
  plt.figure(figsize=(5,4))
315
- wordCloud(orgImg,bwImg,text_Party,maxWord=3000,colorGener=False,contCol='black')
316
 
317
  plt.tight_layout()
318
  buf = BytesIO()
@@ -406,8 +405,7 @@ plot5=gr.outputs.Image(label='Dispersion Plot')
406
  io=gr.Interface(fn=analysis, inputs=[filePdf,Search_txt], outputs=[text,mfw,plot1,plot2,plot3,plot4,plot5], title='Manifesto Analysis',examples=[['Example/Bjp_Manifesto_2019.pdf','modi'],['Example/AAP_Manifesto_2019.pdf','government'],['Example/Congress_Manifesto_2019.pdf','safety']],theme='peach')
407
  io.launch(debug=True,share=False)
408
 
409
- #,examples=[['./Bjp_Manifesto_2019.pdf','india'],['./AAP_Manifesto_2019.pdf',],['./Congress_Manifesto_2019.pdf',]]
410
- #allow_screenshot=False, allow_flagging="never",
411
 
 
412
  #examples=[['manifestos/Bjp_Manifesto_2019.pdf','modi'],['AAP_Manifesto_2019.pdf','delhi'],['manifestos/Congress_Manifesto_2019.pdf','safety']])
413
 
 
242
  ret, bw_img = cv2.threshold(img, 124, 255, cv2.THRESH_BINARY)
243
 
244
  return bw_img
245
+
246
+ def word_cloud(orgIm,mask_img,text_Party_pr,maxWord=2000,colorGener=True,
247
  contCol='white',bckColor='white'):
248
  '''
249
+ #Generating word cloud
250
+ '''
 
251
  mask =mask_img
252
  # Create and generate a word cloud image:
253
  wordcloud = WordCloud(max_words=maxWord, background_color=bckColor,
 
261
  # create coloring from image
262
 
263
 
264
+ plt.axis("off")
265
  if colorGener==True:
266
  image_colors = ImageColorGenerator(orgIm)
267
  plt.imshow(wordcloud.recolor(color_func= image_colors),interpolation="bilinear")
 
271
  plt.imshow(wordcloud)
272
 
273
 
 
274
 
275
+
276
  def word_cloud_generator(parsed_text_name,text_Party):
277
  parsed=parsed_text_name.lower()
278
 
 
280
  orgImg=Original_Image('BJPMain.jpg')
281
  bwImg=Image_Processed('BJPMain.jpg')
282
  plt.figure(figsize=(5,4))
283
+ word_cloud(orgImg,bwImg,text_Party,maxWord=3000,colorGener=True,
284
  contCol='white', bckColor='black')
285
  plt.tight_layout()
286
  buf = BytesIO()
 
295
  orgImg=Original_Image('congress3.jpeg')
296
  bwImg=Image_Processed('congress3.jpeg')
297
  plt.figure(figsize=(5,4))
298
+ word_cloud(orgImg,bwImg,text_Party,maxWord=3000,colorGener=True)
299
 
300
  plt.tight_layout()
301
  buf = BytesIO()
 
311
  orgImg=Original_Image('aapMain2.jpg')
312
  bwImg=Image_Processed('aapMain2.jpg')
313
  plt.figure(figsize=(5,4))
314
+ word_cloud(orgImg,bwImg,text_Party,maxWord=3000,colorGener=False,contCol='black')
315
 
316
  plt.tight_layout()
317
  buf = BytesIO()
 
405
  io=gr.Interface(fn=analysis, inputs=[filePdf,Search_txt], outputs=[text,mfw,plot1,plot2,plot3,plot4,plot5], title='Manifesto Analysis',examples=[['Example/Bjp_Manifesto_2019.pdf','modi'],['Example/AAP_Manifesto_2019.pdf','government'],['Example/Congress_Manifesto_2019.pdf','safety']],theme='peach')
406
  io.launch(debug=True,share=False)
407
 
 
 
408
 
409
+ #allow_screenshot=False,allow_flagging="never",
410
  #examples=[['manifestos/Bjp_Manifesto_2019.pdf','modi'],['AAP_Manifesto_2019.pdf','delhi'],['manifestos/Congress_Manifesto_2019.pdf','safety']])
411