在创建wordcloud时使用阿拉伯语停用词

时间:2018-02-10 08:07:06

标签: python arabic

我是python的新手,并试图用阿拉伯语创建wordcloud。 wordcloud运行正常,但我无法弄清楚禁用词功能为什么不起作用。

我已使用此止损词: https://github.com/Alir3z4/python-stop-words

这是我的代码:

import numpy as np
from PIL import Image
from os import path
from wordcloud import WordCloud
import os
from arabic_reshaper import arabic_reshaper
from bidi.algorithm import get_display
from stop_words import get_stop_words

currdir = path.dirname(__file__)

arabicstop = get_stop_words('arabic')
stopset = set(arabicstop)

def create_wordcloud(text):
   mask = np.array(Image.open(os.path.join(currdir, "cloud.png")))
   wc = WordCloud(background_color="white",
               mask=mask,
               max_words=200,
               stopwords=stopset,
               font_path='C:/Users/lotem/PycharmProjects/new/Shoroq-
               Font.ttf')

   text = arabic_reshaper.reshape(text)
   text = get_display(text)
   wc.generate(text)
   wc.to_file(os.path.join(currdir, "wc.png"))

#main
t = input("Enter the text")
create_wordcloud(t)

我应该修复哪些部分以及如何处理?

由于

0 个答案:

没有答案