Word frequency in text
📁 exception, Advanced Python Topics, question, example, work
The above script in Python calculates the frequency of words in the text (continuous sequences of letters excluding punctuation marks) and displays the results.
It works correctly. The question is: is it possible to do the same thing more simply (for example, with fewer lines of code) in Python, Bash, PHP, Perl, or is this the best way?
import sys
import string
file = open(sys.argv[1], "r")
text = file.read()
file.close()
table = string.maketrans("", "") No answers yet.
Log in to leave an answer