# Praat script EDCDsuccessRate.praat # Paul Boersma, March 7, 2008 # This script is available from http://www.fon.hum.uva.nl/paul/gla/, # where you may find a newer version. form Success rate of learning algorithms natural left_Range_of_number_of_constraints 2 natural right_Range_of_number_of_constraints 20 natural left_Range_of_number_of_inputs 1 natural right_Range_of_number_of_inputs 20 natural left_Range_of_number_of_candidates 2 natural right_Range_of_number_of_candidates 20 natural left_Range_of_maximum_violations 1 natural right_Range_of_maximum_violations 5 natural Number_of_languages 1000 endform success_poolEDCD = 0 success_varEDCD = 0 success_minGLA = 0 success_maxGLA = 0 for itrial to number_of_languages repeat numberOfConstraints = randomInteger (left_Range_of_number_of_constraints, right_Range_of_number_of_constraints) numberOfInputs = randomInteger (left_Range_of_number_of_inputs, right_Range_of_number_of_inputs) maximumViolations = randomInteger (left_Range_of_maximum_violations, right_Range_of_maximum_violations) f$ = "kanweg.OTGrammar" text$ = """ooTextFile""'newline$'""OTGrammar 2""'newline$' 0.0'newline$'" text$ = text$ + "'numberOfConstraints''newline$'" for icons to numberOfConstraints text$ = text$ + """Con'icons'"" 0.0 0.0 1.0'newline$'" endfor text$ = text$ + "0 'numberOfInputs''newline$'" for iinput to numberOfInputs numberOfCandidates = randomInteger (left_Range_of_number_of_candidates, right_Range_of_number_of_candidates) text$ = text$ + " ""Input'iinput'"" 'numberOfCandidates''newline$'" for icand to numberOfCandidates line$ = """Cand'icand'""" for icons to numberOfConstraints numberOfViolations = randomInteger (0, maximumViolations) line$ = line$ + " 'numberOfViolations'" endfor text$ = text$ + " " + line$ + newline$ endfor endfor text$ > 'f$' grammar = Read from file... 'f$' # Create the target language. for icons to numberOfConstraints ranking = randomUniform (95.0, 105.0) Set ranking... icons ranking ranking endfor for iinput to numberOfInputs winner = Get winner... iinput winner'iinput'$ = Get candidate... iinput winner endfor # Create the non-varying environment that corresponds to the target language. d$ = "kanweg.PairDistribution" text$ = """ooTextFile""'newline$'""PairDistribution""'newline$''numberOfInputs''newline$'" for iinput to numberOfInputs winner$ = winner'iinput'$ text$ = text$ + " ""Input'iinput'"" ""'winner$'"" 1'newline$'" endfor text$ > 'd$' distribution = Read from file... 'd$' # Check whether the current grammar does generate the distribution; # this will fail if some optimal candidates have the same violation pattern. plus grammar correct = Get fraction correct... 0 1000 if correct < 1.0 Remove endif until correct = 1.0 # Learn. call learn poolEDCD 0.0 EDCD call learn varEDCD 1e-3 EDCD call learn minGLA 1e-3 "Demotion only" call learn maxGLA 1e-3 "Symmetric all" select grammar plus distribution Remove echo trial 'itrial' pool 'success_poolEDCD' var 'success_varEDCD' min 'success_minGLA' max 'success_maxGLA' endfor procedure learn method$ evaluationNoise rerankingStrategy$ select grammar if index (rerankingStrategy$, "vacation") Reset to random total ranking... 100.0 1.0 else Reset all rankings... 100.0 endif plus distribution epoch = 1 repeat noprogress Learn... evaluationNoise 'rerankingStrategy$' 1 100 1 1 0 no 1 fractionCorrect = Get fraction correct... 1e-3 1000 epoch += 1 until fractionCorrect = 1.0 or epoch > 1000 if fractionCorrect = 1.0 success_'method$' += 1 endif endproc