Debian Codegraph @

dwtest/test_EditCostTable.praat

raw
1 # test_EditCostTable.praat
2 # djmw 20120522
3
4 printline test_EditCostTable
5
6 numberOfTargets = 4
7 numberOfSources = 4
8 table = Create empty EditCostsTable... editCosts numberOfTargets numberOfSources
9
10 printline 'tab$'Set values...
11
12 for i to numberOfTargets
13 targetSymbol$[i] = "t'i'"
14 Set target symbol (index)... i t'i'
15 Set insertion costs... t'i' numberOfSources*i
16 endfor
17 for i to numberOfSources
18 sourceSymbol$[i] = "s'i'"
19 Set source symbol (index)... i s'i'
20 Set deletion costs... s'i' numberOfTargets*i
21 endfor
22
23 cost = 0
24 for i to numberOfTargets
25 for j to numberOfSources
26 cost += 1
27 Set substitution costs... t'i' s'j' cost
28 endfor
29 endfor
30
31 for i to numberOfSources
32 Set substitution costs... nomatch s'i' 20
33 endfor
34 for i to numberOfTargets
35 Set substitution costs... t'i' nomatch 21
36 endfor
37 Set costs (others)... 1 2 3 4
38
39 costs = Get cost (others)... Insertion
40 assert costs = 1
41 costs = Get cost (others)... Deletion
42 assert costs = 2
43 costs = Get cost (others)... Equality
44 assert costs = 3
45 costs = Get cost (others)... Inequality
46 assert costs = 4
47
48 printline 'tab$'Get values...
49
50 for i to numberOfTargets
51 target$ = targetSymbol$[i]
52 index = Get target index... 'target$'
53 assert index = i
54 cost = Get insertion cost... 'target$'
55 assert cost = numberOfSources*i
56 endfor
57
58 for i to numberOfSources
59 source$ = sourceSymbol$[i]
60 index = Get source index... 'source$'
61 assert index = i
62 cost = Get deletion cost... 'source$'
63 assert cost = numberOfTargets*i
64 endfor
65
66 cost = 0
67 for i to numberOfTargets
68 target$ = targetSymbol$[i]
69 for j to numberOfSources
70 source$ = sourceSymbol$[j]
71 cost += 1
72 scost = Get substitution cost... 'target$' 'source$'
73 assert scost = cost; 'target$' 'source$'
74 endfor
75 endfor
76
77 for i to numberOfSources
78 source$ = sourceSymbol$[i]
79 cost = Get substitution cost... nomatch 'source$'
80 assert cost = 20
81 endfor
82
83 for i to numberOfTargets
84 target$ = targetSymbol$[i]
85 cost = Get substitution cost... 'target$' nomatch
86 assert cost = 21
87 endfor
88
89 Remove
90 printline test_EditCostTable OK