Python Find Most Common Words in a Document

preview_player
Показать описание
In this Python tutorial, we will go over how to find the most common words in a document (i.e.- text doc) using the collections module and counter function and the re module (regular expressions).
Рекомендации по теме
Комментарии
Автор

# PYTHON FIND THE MOST COMMON WORDS IN A TXT FILE
# Visual Studio Code or Atom may be easier to use than TextEdit
# Some text may require some clean-up
# if won't work with Word docx document, etc., try converting to txt file

import collections
# The re module provides regular expression matching operations
import re

# ensure open path is correct or put in full path to text document
words = re.findall(r'\w+',
most_common =
print(most_common)

RyanNoonan
Автор

... I've been trying to do this all day. I've been messaging former coworkers for advice. I've been browsing forums and documentation. I follow the instructions in your video - and it works. Are you a witch?

NeuroticPixieSlasher
Автор

hi there im currently working on a program however when printing the most common word, the program prints "[ ]" i believe this is because the new lines are the most common character therefore it decides this is the most common word. Anyone have an idea to ignore this new line to get an accurate soloution?

callumsaxon
Автор

Is it possible to do this with 2 - 5 word phrases instead of single words?

stevesvideos
Автор

Is it possible to show the words in the form of a list from most frequent to least frequent?
I like everything that you showed here, but one part that I wish I knew how to do differently is to organize those generated words in a list, where each word is in its own line.
I also prefer if it’s just a simple list that’s not numbered.
Is there a way to do this in Python?

This is the single most important thing that I want to learn how to do, so any help on this would be greatly appreciated. I’m new to Python, and I don’t know that much about it, but I’m very interested in learning how to use it to find the most frequent words in a document, and organize those words in a list form. This would be the most useful task for me to learn how to do.

Thank you very much 🙏🏻

chariotsx
Автор

Hi I am trying to search for the most common words in a specific column. Its the column 'genres' for a movies dataset. Do you have any idea how I could do that?

lordruperteverton
Автор

Where do i need to save my text file on my pc for it to find it?

JohnCarrFitness
Автор

Sir could you Pleasee guide me how to sort number of frequent words used in pdf document. because i want to learn the most important major words for exam would be very helpful 🙏🏽🙏🏽.

sharma
Автор

When I type in my code, it shows the most commonly used letter. How do I fix that?

burnerzenforce
Автор

do you have the code? im not able to see the little letters

tortilladmaiz