-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextStatistics.py
More file actions
33 lines (26 loc) · 845 Bytes
/
TextStatistics.py
File metadata and controls
33 lines (26 loc) · 845 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
27
28
29
30
31
32
33
def processing_count(word):
vowels = 0
consonant = 0
for char in word.lower():
if char.isalpha():
if char in ['a', 'e', 'i', 'o', 'u', 'y']:
vowels += 1
else:
consonant += 1
return vowels, consonant
def fun(path, chars, *args):
f = open(path, 'r')
myset = set()
for st in f.readlines():
for char in chars:
st = st.replace(char, '')
vowel_consonant_counter = list()
a = st.split(' ')
for word in a:
if word not in args:
count = processing_count(word)
if count not in vowel_consonant_counter:
vowel_consonant_counter.append(count)
myset.add(''.join(sorted(word)))
print(len(myset))
fun("words.txt", 'dfj', 'dfgf', )