Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve clean tweet #11

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions twc.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ def remove_emoji(tweet):
def clean_tweet(tweet):
tweet = str(tweet)
tweet = tweet.lower()
tweet = tweet.replace("#", "") # remove # so we preserve hashtags for the cloud
tweet = tp.clean(tweet)
tweet = remove_emoji(tweet)
normalizer = Normalizer()
tweet = normalizer.normalize(tweet)
tweet = re.sub(r'ن?می[‌]\S+','',tweet) # removes verbs such as می‌شود or نمی‌گویند
tokens = word_tokenize(tweet)
tokens = [token for token in tokens if token not in stopwords.persian]
tokens = [token for token in tokens if token not in stopwords.english]
Expand Down