Skip to content

Instantly share code, notes, and snippets.

@alinazhanguwo
Created April 24, 2019 16:09
Show Gist options
  • Save alinazhanguwo/5da08b1a0ebe1a7c63e89127ca5572b0 to your computer and use it in GitHub Desktop.
Save alinazhanguwo/5da08b1a0ebe1a7c63e89127ca5572b0 to your computer and use it in GitHub Desktop.
# Dictionary of all words from train corpus with their counts.
words_counts = {}
from collections import Counter
words_counts = Counter([word for line in X_train for word in line.split(' ')])
# Sorting
most_common_words = sorted(words_counts.items(), key=lambda x: x[1], reverse=True)[:10]
# Top 10
most_common_words[:10]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment