# Praat script GLAsuccessRateVar.praat # Paul Boersma, June 13, 2007 # 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 algorithm comment First define your set of target languages; comment they will be generated from noisy rankings or weights. natural Number_of_constraints 11 natural Number_of_tableaus 11 natural Number_of_candidates 11 natural Maximum_number_of_violations 3 comment comment Then define your learning settings. optionmenu Decision_strategy 1 option OptimalityTheory option HarmonicGrammar option LinearOT option ExponentialHG option MaximumEntropy option PositiveHG real Initial_ranking 10.0 real Evaluation_noise 2.0 optionmenu Reranking_strategy 3 option Demotion only option Symmetric one option Symmetric all option Weighted uncancelled option Weighted all option EDCD option Weighted all up, highest down positive Initial_plasticity 1.0 real Relative_plasticity_spreading 0.1 boolean Check_learning_settings yes comment comment Finally: how sure do you want to be? natural Number_of_trials 20 endform nsuccess = 0 if check_learning_settings if evaluation_noise = 0 exit Cannot learn variation if there is no evaluation noise. endif endif clearinfo for itrial to number_of_trials f$ = "kanweg.OTGrammar" text$ = """ooTextFile""'newline$'""OTGrammar 1""'newline$'<'decision_strategy$'>'newline$'" text$ = text$ + "'number_of_constraints''newline$'" for icons to number_of_constraints text$ = text$ + """Con'icons'"" 0.0 0.0'newline$'" endfor text$ = text$ + "0 'number_of_tableaus''newline$'" for itab to number_of_tableaus text$ = text$ + " ""Input'itab'"" 'number_of_candidates''newline$'" for icand to number_of_candidates line$ = """Cand'icand'""" for icons to number_of_constraints numberOfViolations = randomInteger (0, maximum_number_of_violations) line$ = line$ + " 'numberOfViolations'" endfor text$ = text$ + " " + line$ + newline$ endfor endfor text$ > 'f$' grammar = Read from file... 'f$' # Create the target language. for icons to number_of_constraints ranking = randomUniform (initial_ranking - 2.0, initial_ranking + 2.0) Set ranking... icons ranking ranking endfor # Create the varying environment that corresponds to the target language. distribution = noprogress To PairDistribution... 10000 evaluation_noise probabilityMatchingFractionCorrect = Get fraction correct (probability matching) maximumLikelihoodFractionCorrect = Get fraction correct (maximum likelihood) numberOfPairs = Get number of pairs for pair to numberOfPairs weight'pair' = Get weight... pair endfor # Learn. select grammar Reset all rankings... initial_ranking Set decision strategy... 'decision_strategy$' plus distribution noprogress Learn... evaluation_noise "'reranking_strategy$'" ... initial_plasticity 100000 0.1 4 relative_plasticity_spreading no 1 fractionCorrect = Get fraction correct... evaluation_noise 10000 select grammar output = noprogress To PairDistribution... 10000 evaluation_noise distance = 0.0 for pair to numberOfPairs weight = Get weight... pair distance += abs (weight - weight'pair') endfor distance /= 10000 * number_of_tableaus if abs (distance) < 0.050 nsuccess += 1 plus grammar plus distribution Remove endif printline 'nsuccess'/'itrial' 'probabilityMatchingFractionCorrect:3' 'fractionCorrect:3' 'maximumLikelihoodFractionCorrect:3' D='distance:3' endfor