From 44958e0c94dc1592ad1ef78ea9a09cfbeaca7dc8 Mon Sep 17 00:00:00 2001 From: Rob van Son Date: Fri, 13 Feb 2015 11:18:51 +0100 Subject: [PATCH] Implemented an adaptive (automatic) deselection of words that go well --- Config.praat | 92 ++++++++++++++++++++++++++-------------------------- InitialiseSGC2.praat | 14 +++++--- MainPage.praat | 53 ++++++++++++++++++++---------- sgc2.praat | 10 +++--- 4 files changed, 96 insertions(+), 73 deletions(-) diff --git a/Config.praat b/Config.praat index eb70f58..b61c9ec 100644 --- a/Config.praat +++ b/Config.praat @@ -358,9 +358,9 @@ procedure processConfigSelectWords .clickX .clickY .pressed$ # Set current word select Table 'wordlist$' - te.numberOfWords = Get number of rows - .currentWord = te.currentWord - if .currentWord <= 0 or .currentWord > te.numberOfWords or config.shuffleLists + sgc.numberOfWords = Get number of rows + .currentWord = sgc.currentWord + if .currentWord <= 0 or .currentWord > sgc.numberOfWords or config.shuffleLists .currentWord = 1 endif @@ -414,7 +414,7 @@ procedure processConfigSelectWords .clickX .clickY .pressed$ endif endif if .lessonCol > 0 - for .i to te.numberOfWords + for .i to sgc.numberOfWords .currentLesson$ = Get value: .i, "Lesson" if .currentLesson$ <> "" and .currentLesson$ <> "-" and index_regex(.lessonList$, "\t'.currentLesson$'\t") <= 0 .lessonList$ = .lessonList$ + .currentLesson$ + tab$ @@ -447,8 +447,8 @@ procedure processConfigSelectWords .clickX .clickY .pressed$ endif endif .max = .numWordsPerScreen - 1 - if .currentWord + .max > te.numberOfWords - .max = te.numberOfWords - .currentWord + if .currentWord + .max > sgc.numberOfWords + .max = sgc.numberOfWords - .currentWord endif for .i from 0 to .numWordsPerScreen - 1 if .i <= .max @@ -516,12 +516,12 @@ procedure processConfigSelectWords .clickX .clickY .pressed$ clicked = endPause ("'.cancelText$'", "'.clearText$'", "'.allText$'", "'.prevWord$'", "'.nextWord$'", "'.continueText$'", 6, 1) if clicked = 2 - for .i to te.numberOfWords + for .i to sgc.numberOfWords Set string value: .i, "Show", "-" endfor .allShown = 0 elsif clicked = 3 - for .i to te.numberOfWords + for .i to sgc.numberOfWords Set string value: .i, "Show", "+" endfor .allShown = 1 @@ -535,14 +535,14 @@ procedure processConfigSelectWords .clickX .clickY .pressed$ .allShown = 1 .firstShown = -1 select Table 'wordlist$' - for .i to te.numberOfWords + for .i to sgc.numberOfWords # Keep track of whether all are shown .shown$ = Get value: .i, "Show" if .shown$ = "-" .allShown = 0 endif endfor - for .i to te.numberOfWords + for .i to sgc.numberOfWords # Lessons .currentLesson$ = Get value: .i, "Lesson" if .currentLesson$ = .lessonName$['.lessonSelected'] @@ -551,7 +551,7 @@ procedure processConfigSelectWords .clickX .clickY .pressed$ Set string value: .i, "Show", "-" endif endfor - for .i to te.numberOfWords + for .i to sgc.numberOfWords # Keep track of whether all are shown .shown$ = Get value: .i, "Show" if .firstShown <=0 and .shown$ <> "-" @@ -573,7 +573,7 @@ procedure processConfigSelectWords .clickX .clickY .pressed$ .toneSelected = '.tmp$' - 2 if .toneSelected >= 0 select Table 'wordlist$' - for .i to te.numberOfWords + for .i to sgc.numberOfWords .currentPinyin$ = Get value: .i, "Pinyin" .tmp$ = Get value: .i, "Show" if .tmp$ <> "-" and index(.currentPinyin$, "'.toneSelected'") > 0 @@ -592,7 +592,7 @@ procedure processConfigSelectWords .clickX .clickY .pressed$ .currentWord -= .numWordsPerScreen endif if .currentWord <= 0 - .currentWord = (te.numberOfWords div .numWordsPerScreen) * .numWordsPerScreen + 1 + .currentWord = (sgc.numberOfWords div .numWordsPerScreen) * .numWordsPerScreen + 1 endif elsif clicked = 5 if .firstShown > 0 @@ -600,14 +600,14 @@ procedure processConfigSelectWords .clickX .clickY .pressed$ elsif .toneSelected < 0 .currentWord += .numWordsPerScreen endif - if .currentWord > te.numberOfWords + if .currentWord > sgc.numberOfWords .currentWord = 1 endif endif endif # Reset and go to the first selected word (can shuffle list) if clicked = 6 - te.currentWord = -1 + sgc.currentWord = -1 call next_word endif endwhile @@ -920,7 +920,7 @@ procedure load_word_list .localdir$ .relnumber # Create Table that will recieve the wordlists and directories Create Table with column names... AllWordLists 0 Name Directory - .te.currentWordlistRow = 0 + .sgc.currentWordlistRow = 0 # First the global word lists if fileReadable(globalwordlists$) or fileReadable("'globalwordlists$'/directory.txt") @@ -934,10 +934,10 @@ procedure load_word_list .localdir$ .relnumber .listExist = Search column: "Name", .currentName$ if not .listExist Append row - .te.currentWordlistRow = Get number of rows - Set string value... '.te.currentWordlistRow' Name '.currentName$' + .sgc.currentWordlistRow = Get number of rows + Set string value... '.sgc.currentWordlistRow' Name '.currentName$' .currentDirectory$ = globalwordlists$+"/"+.currentName$ - Set string value... '.te.currentWordlistRow' Directory '.currentDirectory$' + Set string value... '.sgc.currentWordlistRow' Directory '.currentDirectory$' endif endif endfor @@ -957,10 +957,10 @@ procedure load_word_list .localdir$ .relnumber .listExist = Search column: "Name", .currentName$ if not .listExist Append row - .te.currentWordlistRow = Get number of rows - Set string value... '.te.currentWordlistRow' Name '.currentName$' + .sgc.currentWordlistRow = Get number of rows + Set string value... '.sgc.currentWordlistRow' Name '.currentName$' .currentDirectory$ = sgc2wordlists$+"/"+.currentName$ - Set string value... '.te.currentWordlistRow' Directory '.currentDirectory$' + Set string value... '.sgc.currentWordlistRow' Directory '.currentDirectory$' endif endif endfor @@ -982,10 +982,10 @@ procedure load_word_list .localdir$ .relnumber .procedureName$ = replace_regex$(.currentName$, "[^\w\-\.]", "_", 0) select Table AllWordLists Append row - .te.currentWordlistRow = Get number of rows - Set string value... '.te.currentWordlistRow' Name '.currentName$' + .sgc.currentWordlistRow = Get number of rows + Set string value... '.sgc.currentWordlistRow' Name '.currentName$' .currentDirectory$ = "*call Create'.procedureName$'" - Set string value... '.te.currentWordlistRow' Directory '.currentDirectory$' + Set string value... '.sgc.currentWordlistRow' Directory '.currentDirectory$' endif endif endfor @@ -1004,10 +1004,10 @@ procedure load_word_list .localdir$ .relnumber .listExist = Search column: "Name", .currentName$ if not .listExist Append row - .te.currentWordlistRow = Get number of rows - Set string value... '.te.currentWordlistRow' Name '.currentName$' + .sgc.currentWordlistRow = Get number of rows + Set string value... '.sgc.currentWordlistRow' Name '.currentName$' .currentDirectory$ = .localdir$+"/"+.currentName$ - Set string value... '.te.currentWordlistRow' Directory '.currentDirectory$' + Set string value... '.sgc.currentWordlistRow' Directory '.currentDirectory$' endif endif endfor @@ -1166,25 +1166,25 @@ procedure load_word_list .localdir$ .relnumber Set column label (index): 1, .firstColumn$ endif - te.numberOfWords = Get number of rows + sgc.numberOfWords = Get number of rows .characterColumn = Get column index... Character if not .characterColumn Append column... Character - for .i to te.numberOfWords + for .i to sgc.numberOfWords Set string value... '.i' Character - endfor endif .translationColumn = Get column index... Translation if not .translationColumn Append column... Translation - for .i to te.numberOfWords + for .i to sgc.numberOfWords Set string value... '.i' Translation - endfor endif .showColumn = Get column index... Show if not .showColumn Append column... Show - for .i to te.numberOfWords + for .i to sgc.numberOfWords Set string value... '.i' Show + endfor endif @@ -1199,7 +1199,7 @@ procedure load_word_list .localdir$ .relnumber Remove row... '.rowNum' endif endfor - te.numberOfWords = Get number of rows + sgc.numberOfWords = Get number of rows # Shuffle words if requested if config.shuffleLists @@ -1237,7 +1237,7 @@ procedure load_word_list .localdir$ .relnumber Set string value... '.i' Character 再见 Set string value... '.i' Translation goodbye Set string value... '.i' Sound - - te.numberOfWords = Get number of rows + sgc.numberOfWords = Get number of rows endif call set_window_title 'buttons$' 'wordlistName$' @@ -1247,16 +1247,16 @@ procedure next_word if wordlist$ <> "" select Table 'wordlist$' .showCurrent$ = "-" - if te.currentWord < 0 or te.currentWord > te.numberOfWords + if sgc.currentWord < 0 or sgc.currentWord > sgc.numberOfWords if config.shuffleLists Randomize rows endif - te.currentWord = 0 + sgc.currentWord = 0 endif - while .showCurrent$ = "-" and te.currentWord <= te.numberOfWords - te.currentWord += 1 - if te.currentWord <= te.numberOfWords - .showCurrent$ = Get value... 'te.currentWord' Show + while .showCurrent$ = "-" and sgc.currentWord <= sgc.numberOfWords + sgc.currentWord += 1 + if sgc.currentWord <= sgc.numberOfWords + .showCurrent$ = Get value... 'sgc.currentWord' Show endif endwhile endif @@ -1266,16 +1266,16 @@ procedure previous_word if wordlist$ <> "" select Table 'wordlist$' .showCurrent$ = "-" - if te.currentWord <= 0 + if sgc.currentWord <= 0 if config.shuffleLists Randomize rows endif - te.currentWord = te.numberOfWords + 1 + sgc.currentWord = sgc.numberOfWords + 1 endif - while .showCurrent$ = "-" and te.currentWord > 0 - te.currentWord -= 1 - if te.currentWord > 0 - .showCurrent$ = Get value... 'te.currentWord' Show + while .showCurrent$ = "-" and sgc.currentWord > 0 + sgc.currentWord -= 1 + if sgc.currentWord > 0 + .showCurrent$ = Get value... 'sgc.currentWord' Show endif endwhile endif diff --git a/InitialiseSGC2.praat b/InitialiseSGC2.praat index b220b33..9ada356 100644 --- a/InitialiseSGC2.praat +++ b/InitialiseSGC2.praat @@ -54,8 +54,8 @@ sgc2.popUp_backgroundcolor$ = "{0.9,0.9,1}" # Initialize parameters alertText$ = "" -te.currentWord = 1 -te.numberOfWords = 0 +sgc.currentWord = 1 +sgc.numberOfWords = 0 sgc.recordedSound = 0 sgc.saveAudioOn = 0 sgc.writeAll = 0 @@ -67,6 +67,8 @@ config$ = "" wordlistNum = 1 wordlistName$ = "" wordlist$ = "" +sgc.autoselectWords = 1 +sgc.failedAttempts = 0 mainPage.play = -1 config.deleteWordlist = -1 config.displayNumbers = 1 @@ -208,8 +210,8 @@ procedure init_window if recordedSound$ = "" and sgc.saveAudio$ <> "" sgc.pinyin$ = "" select Table 'wordlist$' - if te.currentWord > 0 and te.currentWord <= te.numberOfWords - sgc.pinyin$ = Get value... 'te.currentWord' Pinyin + if sgc.currentWord > 0 and sgc.currentWord <= sgc.numberOfWords + sgc.pinyin$ = Get value... 'sgc.currentWord' Pinyin .outputName$ = "'sgc.saveAudio$'/'sgc.pinyin$'.wav" if fileReadable(.outputName$) sgc.recordedSound = Read from file: .outputName$ @@ -249,6 +251,7 @@ procedure init_window call paint_saveAudio_light # Set play button + sgc.failedAttempts = 0 endproc # Make sure all Preferences directories are available @@ -615,12 +618,15 @@ procedure add_feedback_to_toneevaluation .table$ call increment_toneevaluation_value 'sgc.pinyin$' Total if .tones$ = .recognized$ call increment_toneevaluation_value 'sgc.pinyin$' Correct + .result = 1 else call increment_toneevaluation_value 'sgc.pinyin$' Wrong + .result = 0 endif if index_regex(.label$, "(Correct|Wrong)") <= 0 call increment_toneevaluation_value 'sgc.pinyin$' '.label$' call increment_toneevaluation_value 'sgc.pinyin$' Commented + .result = 0 endif # Update performance table when SaveAudio is on diff --git a/MainPage.praat b/MainPage.praat index e3f82c1..9590c1d 100644 --- a/MainPage.praat +++ b/MainPage.praat @@ -183,6 +183,8 @@ procedure processMainPagePrevious .clickX .clickY .pressed$ # Draw the contour call wipeArea 'wipeFeedbackArea$' call display_text Black + + sgc.failedAttempts = 0 endproc procedure processMainPageNext .clickX .clickY .pressed$ @@ -287,6 +289,21 @@ procedure processMainPageRecord .clickX .clickY .pressed$ call write_feedback Feedback select Table Feedback Remove + + # Do not exercise words that are going well (autoSelect) + if add_feedback_to_toneevaluation.result > 0 + if sgc.autoselectWords > 0 and sgc.failedAttempts < 2 + # Deselect current word + select Table 'wordlist$' + .i = Search column: "Pinyin", sgc.pinyin$ + if .i > 0 + Set string value: .i, "Show", "-" + endif + endif + sgc.failedAttempts = 0 + else + sgc.failedAttempts += 1 + endif endproc @@ -299,10 +316,10 @@ endproc # The example procedure generate_example select Table 'wordlist$' - if te.currentWord > 0 and te.currentWord <= te.numberOfWords + if sgc.currentWord > 0 and sgc.currentWord <= sgc.numberOfWords select Table 'wordlist$' - .sound$ = Get value... 'te.currentWord' Sound - sgc.pinyin$ = Get value... 'te.currentWord' Pinyin + .sound$ = Get value... 'sgc.currentWord' Sound + sgc.pinyin$ = Get value... 'sgc.currentWord' Pinyin if .sound$ = "-" or .sound$ = "" .sound$ = sgc.pinyin$+".wav" endif @@ -346,9 +363,9 @@ endproc # Draw a tone contour procedure draw_tone_contour select Table 'wordlist$' - if te.currentWord > 0 and te.currentWord <= te.numberOfWords - .sound$ = Get value... 'te.currentWord' Sound - sgc.pinyin$ = Get value... 'te.currentWord' Pinyin + if sgc.currentWord > 0 and sgc.currentWord <= sgc.numberOfWords + .sound$ = Get value... 'sgc.currentWord' Sound + sgc.pinyin$ = Get value... 'sgc.currentWord' Pinyin call drawToneContour 'sgc.pinyin$' 'config.register' call reset_viewport @@ -361,14 +378,14 @@ endproc procedure recognizeTone select Table 'wordlist$' - if te.currentWord > 0 and te.currentWord <= te.numberOfWords + if sgc.currentWord > 0 and sgc.currentWord <= sgc.numberOfWords .strict = 0 if index_regex(config.strict$, "[^0-9]") <= 0 .strict = ('config.strict$' >= sgc.highestLevel) endif - .sound$ = Get value... 'te.currentWord' Sound - sgc.pinyin$ = Get value... 'te.currentWord' Pinyin + .sound$ = Get value... 'sgc.currentWord' Sound + sgc.pinyin$ = Get value... 'sgc.currentWord' Pinyin call align_recordedSound 'sgc.pinyin$' call sgc_ToneProt 'recordedSound$' 'sgc.pinyin$' 'config.register' '.strict' 'config.language$' # sgc_ToneProt manipulates the sound given. Reconnect @@ -417,23 +434,23 @@ endproc # Text display procedure display_text .color$ select Table 'wordlist$' - if te.currentWord < 0 or te.currentWord > te.numberOfWords+1 + if sgc.currentWord < 0 or sgc.currentWord > sgc.numberOfWords+1 call clean_up_sound if config.shuffleLists Randomize rows endif - if te.currentWord < 0 - te.currentWord = te.numberOfWords + if sgc.currentWord < 0 + sgc.currentWord = sgc.numberOfWords else - te.currentWord = 1 + sgc.currentWord = 1 endif endif - if te.currentWord > 0 and te.currentWord <= te.numberOfWords + if sgc.currentWord > 0 and sgc.currentWord <= sgc.numberOfWords .displayText$ = "" - .displayPinyin$ = Get value... 'te.currentWord' Pinyin - .displayChar$ = Get value... 'te.currentWord' Character - .displayTrans$ = Get value... 'te.currentWord' Translation + .displayPinyin$ = Get value... 'sgc.currentWord' Pinyin + .displayChar$ = Get value... 'sgc.currentWord' Character + .displayTrans$ = Get value... 'sgc.currentWord' Translation if .displayPinyin$ <> "-" and (config.displayPinyin or sgc.writeAll) if not config.displayNumbers call numbers2pinyin '.displayPinyin$' @@ -449,7 +466,7 @@ procedure display_text .color$ if .displayTrans$ <> "-" and (config.displayTrans or sgc.writeAll) .displayText$ = .displayText$ + " \s{%%"+ .displayTrans$ + "%}" endif - elsif te.currentWord = 0 or te.currentWord = te.numberOfWords+1 + elsif sgc.currentWord = 0 or sgc.currentWord = sgc.numberOfWords+1 call clean_up_sound .displayText$ = "---" endif diff --git a/sgc2.praat b/sgc2.praat index 554f914..a6f65f5 100644 --- a/sgc2.praat +++ b/sgc2.praat @@ -712,9 +712,9 @@ procedure count_syllables .number = 0 .pinyin$ = "" select Table 'wordlist$' - if te.currentWord > 0 and te.currentWord <= te.numberOfWords - .sound$ = Get value... 'te.currentWord' Sound - .pinyin$ = Get value... 'te.currentWord' Pinyin + if sgc.currentWord > 0 and sgc.currentWord <= sgc.numberOfWords + .sound$ = Get value... 'sgc.currentWord' Sound + .pinyin$ = Get value... 'sgc.currentWord' Pinyin endif call add_missing_neutral_tones '.pinyin$' .pinyin$ = add_missing_neutral_tones.pinyin$ @@ -825,8 +825,8 @@ procedure record_sound .recordingTime if sgc.savePerf$ <> "" and fileReadable(sgc.savePerf$) .pinyin$ = "" select Table 'wordlist$' - if te.currentWord > 0 and te.currentWord <= te.numberOfWords - .pinyin$ = Get value... 'te.currentWord' Pinyin + if sgc.currentWord > 0 and sgc.currentWord <= sgc.numberOfWords + .pinyin$ = Get value... 'sgc.currentWord' Pinyin .outputName$ = "'sgc.saveAudio$'/'.pinyin$'.wav" select sgc.recordedSound Save as WAV file: .outputName$ -- 2.11.4.GIT