Untitled

mail@pastecode.io avatar
unknown
plain_text
14 days ago
1.1 kB
3
Indexable
Never
import pandas as pd
from wordcloud import WordCloud
import matplotlib.pyplot as plt

# Step 1: Fill missing values with empty strings to avoid null issues
authentic_df['Original_Content_Text'].fillna("", inplace=True)

# Step 2: Combine all the text from the column into a single string
combined_content_bangla = " ".join(authentic_df['Original_Content_Text'].astype(str))

# Step 3: Check if combined_content_bangla is actually a string
if isinstance(combined_content_bangla, str):
    print("Text successfully combined.")

# Step 4: Generate the word cloud using the correct font path
wordcloud_bangla = WordCloud(width=800, height=400, background_color='white',
                             collocations=False, font_path='/kaggle/input/solaimanlipitff/other/default/1/SolaimanLipi(25-Apr-2012)CustomizedBy-Saif.ttf').generate(combined_content_bangla)

# Step 5: Plot the word cloud
plt.figure(figsize=(10, 5))
plt.imshow(wordcloud_bangla, interpolation='bilinear')
plt.axis('off')
plt.title("Word Cloud for Bangla News Content", fontsize=16)
plt.show()
Leave a Comment