Exemplo n.º 1
0
 def word_count(self):
     with open(self.inputfile, "r") as string:
         string = string.read()
         list = re.split('\W+', string)
         my_dict = [str.lower(word) for word in list]
         numbers = Counter(my_dict).most_common(20)
     return numbers
Exemplo n.º 2
0
 def punct_count(self):
     with open(self.inputfile, "r") as string:
         string = string.read()
         my_dict = string.replace(" ", "").replace("  ", "").replace("\r\n", "").strip()
         list = re.split('\w+', my_dict)
         numbers = Counter(list).most_common(10)
     return numbers
Exemplo n.º 3
0
 def word_count(self):
     with open(self.inputfile, "r") as string:
         string = string.read()
         list = re.split('\W+', string)
         my_dict = [str.lower(word) for word in list]
         numbers = Counter(my_dict).most_common(20)
     return numbers
Exemplo n.º 4
0
 def punct_count(self):
     with open(self.inputfile, "r") as string:
         string = string.read()
         my_dict = string.replace(" ", "").replace("  ",
                                                   "").replace("\r\n",
                                                               "").strip()
         list = re.split('\w+', my_dict)
         numbers = Counter(list).most_common(10)
     return numbers
Exemplo n.º 5
0
 def word_count(self):
     with open(self.inputfile, "r") as string:
         string = string.read()
         list = re.split('\W+', string)
         #https://docs.python.org/2/library/re.html
         '''
         this took me forever to figure out and what to use
         since I previous got this wrong. this seems simple compared
         to previous attempted to break apart using string
         '''
         '''
         http://stackoverflow.com/questions/10134372/get-a-list-of-names-which-start-with-certain-letters
         First answer helped tell me how to put together a list comprehension.
         '''
         my_dict = [str.lower(word) for word in list]
         numbers = Counter(my_dict).most_common(20)
     return numbers
Exemplo n.º 6
0
 def word_count(self):
     with open(self.inputfile, "r") as string:
         string = string.read()
         list = re.split('\W+', string)
         #https://docs.python.org/2/library/re.html
         '''
         this took me forever to figure out and what to use
         since I previous got this wrong. this seems simple compared
         to previous attempted to break apart using string
         '''
         '''
         http://stackoverflow.com/questions/10134372/get-a-list-of-names-which-start-with-certain-letters
         First answer helped tell me how to put together a list comprehension.
         '''
         my_dict = [str.lower(word) for word in list]
         numbers = Counter(my_dict).most_common(20)
     return numbers
Exemplo n.º 7
0
 def word_totalcount(self):
     with open(self.inputfile, "r") as string:
         string = string.read()
         counters = len(string.split())
         print(counters)
Exemplo n.º 8
0
 def word_totalcount(self):
     with open(self.inputfile, "r") as string:
         string = string.read()
         counters = len(string.split())
         print(counters)
Exemplo n.º 9
0
def read_from_file(file_name):
	global original_file_name
	original_file_name = file_name
	with open(file_name, 'r') as string:
		string = string.read()
		return string