-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_compare_CVC_CV.py
61 lines (55 loc) · 1.81 KB
/
test_compare_CVC_CV.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
from findCollisions import countCollisionsInList
data = []
def getData(cvc=False,cv=False):
inputFile = 'output_shortlist.txt'
data = []
with open(inputFile,'r') as f1:
for line in f1:
word = line.split(',')[0]
if cvc:
word = justTwoInitSylls_CVC(word)
elif cv:
word = justTwoInitSylls_CV(word)
data.append(word)
return data
def justTwoInitSylls_CVC(word):
beforeThisIndex = 0
for vowel1 in word:
if vowel1 in 'aeiou':
afterThisIndex = word.index(vowel1)
break
for vowel2 in word[afterThisIndex+1:]:
if vowel2 in 'aeiou':
beforeThisIndex = word[afterThisIndex+1:].index(vowel2)+1 + afterThisIndex+1
break
if beforeThisIndex!=0:
word = word[:beforeThisIndex+1]
return word
def justTwoInitSylls_CV(word):
beforeThisIndex = 0
for vowel1 in word:
if vowel1 in 'aeiou':
afterThisIndex = word.index(vowel1)
break
for vowel2 in word[afterThisIndex+1:]:
if vowel2 in 'aeiou':
beforeThisIndex = word[afterThisIndex+1:].index(vowel2)+1 + afterThisIndex+1
break
if beforeThisIndex!=0:
word = word[:beforeThisIndex]
return word
def compare_CVC_vs_CV():
print('____________________\nCVC:')
data = getData(cvc=True)
collisions_cvc = countCollisionsInList(data)
print('____________________\nCV:')
data = getData(cv=True)
collisions_cv = countCollisionsInList(data)
print('____________________\nWant less collisions?')
if collisions_cvc < collisions_cv:
print('Go with CVC')
elif collisions_cv < collisions_cvc:
print('Go with CV')
else:
print('There\'s no difference between CVC and CV.')
compare_CVC_vs_CV()