I wonder how to read fscanf such as character string, I need to read in the word all, in .txt I need a count for each word. In this way, I can not have difficulty reading the final word. If you are using Python and GT, you can use It combines several ways like 'most unusual', which can be useful in this type of application. ) With f: for the line in f: c.update (line print 'most common:' in the letter, c.most_common (3)): print '% s:% 7d'% (letter, count) < / Code> - Although it counts the letter instead of the terminology, in the Edit: Here is the fastest way to remove punctuation: (The following question Borrowed from)
with collectwords = collections.defaultdict (int) Open ('DatoSO.txt', 'r') as filetxt: For characters in line: = str < = "V" = "v" "
collections.counter You can use. ; = 2.7
c.update line, you can change the
line.rstrip () .com
line.split () and perhaps want to replace some code to get rid of punctuation.
import import import string c = archive counter () Open ('Data SourcePT', 'RT') As F: f: c.update (for line transcript (string .maketrans ("", "", string.punctuation) .split))
Comments
Post a Comment