Last active
April 23, 2022 12:32
-
-
Save audhiaprilliant/6a08770e34712fe159e323dcf6e83220 to your computer and use it in GitHub Desktop.
How to Automatically Build Stopwords
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # How to get a list of top words | |
| def getTopWords( | |
| text: str | |
| ): | |
| # Split text by its whitespace | |
| list_words = text.split() | |
| # Count the word frequencies | |
| word_freq = collections.Counter(list_words) | |
| # Get top n words that have highest frequencies | |
| top_words = word_freq.most_common() | |
| return top_words | |
| # Get a list top words | |
| top_words = getTopWords( | |
| text = text_clean | |
| ) | |
| # Show the top words | |
| top_words |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment