Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
548 views
in Technique[技术] by (71.8m points)

word cloud - How to un-stem 'Jesu' to get 'Jesus' in wordcloud?

Trying to get a .png image using wordcloud from a book on Bible. The word 'Jesus' is stemmed to 'Jesu'. Is there a way to give an exception to this one word alone? Strangely, 'Moses' is not stemmed.

{file_content = open("Wheres_Heaven.txt").read()}

{wordcloud = WordCloud(stopwords=None, background_color = 'white', width=1200, height=1000, max_words = 500, ).generate(file_content)}

{plt.figure( figsize=(20,10) )
{plt.imshow(wordcloud)}
{plt.axis('off')}
{plt.savefig('Heaven.png')}
{plt.show()}

Heaven.png

question from:https://stackoverflow.com/questions/65950719/how-to-un-stem-jesu-to-get-jesus-in-wordcloud

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If you have version 1.8.1 then you can put "Jesu" in stopwords.

The logic is when it sees both "Jesu" and "Jesus" in the text, the code assumes it is a plural. Apparently the text has no "Mose", which is why that was not treated as plural.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...