test_EditCostTable.praat 1.9 KB

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