10 أسطر
495 B
Python
10 أسطر
495 B
Python
import re
|
|
TASHKEEL=re.compile(r'[\u064b-\u0652\u0670]')
|
|
STOP={'\u0641\u064a','\u0645\u0646','\u0639\u0644\u0649','\u0625\u0644\u0649','\u0639\u0646','\u0643\u0627\u0646','\u0647\u0630\u0627','\u0648','\u0644\u0627','\u0645\u0627','\u0643\u0644'}
|
|
def remove_tashkeel(t): return TASHKEEL.sub('',t)
|
|
def tokenize(t): return t.split()
|
|
def remove_stop_words(ts): return [t for t in ts if t not in STOP]
|
|
def clean_arabic(t):
|
|
t=remove_tashkeel(t)
|
|
return ' '.join(remove_stop_words(tokenize(t)))
|