-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstats.py
More file actions
26 lines (24 loc) · 702 Bytes
/
stats.py
File metadata and controls
26 lines (24 loc) · 702 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
def getWordsCount(story):
wordCount = len(story.split())
return wordCount
def getCharacterFreq(story):
wordFrequency = {}
for c in story:
char = c.lower()
if char in wordFrequency:
freq = wordFrequency[char] # Get the current frequency of the character
wordFrequency.update({char: freq+1})
else:
wordFrequency[char] = 1
return wordFrequency
def getDictionaryList(dict):
dictList = []
for x in dict:
dataDict = {}
if x.isalpha():
dataDict["char"] = x
dataDict["num"] = dict[x]
dictList.append(dataDict)
else:
continue
return dictList