4 # Praat script handling configuration page
6 # SpeakGoodChinese: Config.praat loads the code needed for the
7 # settings and the Settings page of SpeakGoodChinese.
9 # Copyright (C) 2007-2010 R.J.J.H. van Son and 2010 the Netherlands Cancer Institute
10 # The SpeakGoodChinese team are:
11 # Guangqin Chen, Zhonyan Chen, Stefan de Koning, Eveline van Hagen,
12 # Rob van Son, Dennis Vierkant, David Weenink
14 # This program is free software; you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License as published by
16 # the Free Software Foundation; either version 2 of the License, or
17 # (at your option) any later version.
19 # This program is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write to the Free Software
26 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
29 ###############################################################
31 # Button Drawing Routines
33 ###############################################################
35 procedure DrawCredits .color$ .x .y .size
38 call adjustFontSizeOnHeight 'defaultFont$' 24 '.lineheight'
39 .currentFontSize = adjustFontSizeOnHeight.newFontSize
40 demo Paint circle... {0.2,0.2,0.8} '.x' '.y' '.size'
42 demo Text special... '.x' centre '.y' half Times '.currentFontSize' 0 i
45 call set_font_size 'defaultFontSize'
48 procedure DrawDeleteList .color$ .x .y .size
56 .displayWordList$ = replace_regex$(wordlistName$, "[_]", " ", 0)
59 .maxWidth = (.rightX - .leftX)
60 .currentFontSize = defaultFontSize
61 call adjustFontSizeOnWidth 'defaultFont$' '.currentFontSize' '.maxWidth' '.displayWordList$'
62 .currentFontSize = adjustFontSizeOnWidth.newFontSize
63 if adjustFontSizeOnWidth.diff > 0
64 .rightX += adjustFontSizeOnWidth.diff/2
65 .leftX -= adjustFontSizeOnWidth.diff/2
67 call set_font_size '.currentFontSize'
68 demo Paint rectangle... White '.leftX' '.rightX' '.botY' '.topY'
70 demo Text... '.x' Centre '.botY' Bottom '.displayWordList$'
73 call set_font_size 'defaultFontSize'
76 procedure DrawManual .color$ .x .y .size
79 call adjustFontSizeOnHeight 'defaultFont$' 24 '.lineheight'
80 .currentFontSize = adjustFontSizeOnHeight.newFontSize
81 demo Paint circle... {0.2,0.2,0.8} '.x' '.y' '.size'
83 demo Text special... '.x' centre '.y' half Times '.currentFontSize' 0 M
86 call set_font_size 'defaultFontSize'
89 procedure DrawSaveAudio .color$ .x .y .size
94 elsif .color$ = "Blue"
95 .color$ = "{0.5,0.5,1}"
99 demo Paint circle... '.color$' '.x' '.y' '.size'
102 ###############################################################
104 # Obligatory button Drawing Routines
106 # These MUST be defined
108 ###############################################################
110 procedure DrawReturn .color$ .x .y .size
111 call DrawConfig '.color$' '.x' '.y' '.size'
114 # Set the correct button states after redrawing the window
115 procedure setConfigMainPage
116 call Draw_button 'config$' +SaveAudio 'te.saveAudio'
119 ###############################################################
121 # Button Processing Routines
123 ###############################################################
125 procedure processConfigShuffleLists .clickX .clickY .pressed$
127 .label$ = "ShuffleLists"
128 config.shuffleLists = not config.shuffleLists
129 .displayButton = 2*config.shuffleLists
130 call Draw_button '.table$' '.label$' '.displayButton'
133 procedure processConfigUseSoundExample .clickX .clickY .pressed$
135 .label$ = "UseSoundExample"
136 config.useSoundExample = not config.useSoundExample
137 .displayButton = 2*config.useSoundExample
138 call Draw_button '.table$' '.label$' '.displayButton'
141 procedure processConfigSynthesis .tts$ .clickX .clickY .pressed$
143 .label$ = "Synthesis_'.tts$'"
144 if sgc2.synthesizer > 0 or (speakCommandFile$ <> "" and fileReadable(speakCommandFile$))
145 if config.synthesis$ = ""
146 config.synthesis$ = .tts$
149 config.synthesis$ = ""
153 config.synthesis$ = "_DISABLED_"
156 call Draw_button '.table$' '.label$' '.displayButton'
159 procedure processConfigStrict .clickX .clickY .pressed$
162 config.strict = not config.strict
168 # Change TTS for Strict!
170 call Draw_button '.table$' '.label$' '.displayButton'
173 procedure processConfigDisplayPinyin .clickX .clickY .pressed$
175 .label$ = "DisplayPinyin"
176 config.displayPinyin = not config.displayPinyin
177 .displayButton = 2*config.displayPinyin
178 call Draw_button '.table$' '.label$' '.displayButton'
181 procedure processConfigDisplayChar .clickX .clickY .pressed$
183 .label$ = "DisplayChar"
184 config.displayChar = not config.displayChar
185 .displayButton = 2*config.displayChar
186 call Draw_button 'table$' '.label$' '.displayButton'
189 procedure processConfigDisplayTrans .clickX .clickY .pressed$
191 .label$ = "DisplayTrans"
192 config.displayTrans = not config.displayTrans
193 .displayButton = 2*config.displayTrans
194 call Draw_button 'table$' '.label$' '.displayButton'
197 procedure processConfigDisplayNumbers .clickX .clickY .pressed$
199 .label$ = "DisplayNumbers"
200 config.displayNumbers = not config.displayNumbers
201 .displayButton = 2*config.displayNumbers
202 call Draw_button 'table$' '.label$' '.displayButton'
205 procedure processConfigLanguage .language$ .clickX .clickY .pressed$
207 .label$ = "Language_'.language$'"
208 call processLanguageCodes '.table$' '.label$'
211 procedure processConfigShowBackground .clickX .clickY .pressed$
213 .label$ = "ShowBackground"
214 config.showBackground = not config.showBackground
215 .displayButton = 2*config.showBackground
216 call Draw_button 'table$' '.label$' '.displayButton'
219 procedure processConfigInput .input$ .clickX .clickY .pressed$
221 .label$ = "Input_'.input$'"
222 call Draw_button '.table$' Input_'config.input$' 0
223 config.input$ = .input$
224 call Draw_button '.table$' Input_'config.input$' 2
227 procedure processConfigRegister .register .clickX .clickY .pressed$
229 .label$ = "Register_'.register'"
230 call setRegisterFromLabel '.table$' '.label$'
233 procedure setRegisterFromLabel .table$ .label$
234 call Draw_button '.table$' Register_'config.register' 0
235 call Draw_button '.table$' '.label$' 2
236 # Someone might have to use more than 3 chars for the config.register code
237 .numChars = length(.label$) - length("Register_")
238 .registerText$ = right$(.label$, .numChars)
239 config.register = '.registerText$'
242 procedure processConfigDeleteWordlist .clickX .clickY .pressed$
244 .label$ = "DeleteWordlist"
246 # Do not process undeletable word lists, only those stored in the
247 # preferencesDirectory$ can be deleted
248 if fileReadable("'sgc2wordlists$'/'wordlistName$'") or fileReadable("'sgc2wordlists$'/'wordlistName$'/wordlist.txt") or fileReadable("'sgc2wordlists$'/'wordlistName$'/wordlist.Table")
249 call findLabel '.table$' !'.label$'
251 select Table '.table$'
252 .alertText$ = Get value... 'findLabel.row' Text
253 .confirmKey$ = Get value... 'findLabel.row' Key
254 .popupText$ = Get value... 'findLabel.row' Helptext
256 exit Cannot find delete directive: '.table$' !'.label$'
258 call write_text_popup 'defaultFont$' 14 '.popupText$'
259 call Draw_button '.table$' '.label$' 2
260 alertText$ = .alertText$
261 call Draw_button '.table$' '.label$' 3
264 # Wait for confirmation
266 if demoInput(.confirmKey$)
267 .deleteWordListDir$ = wordlistName$
268 call load_word_list "'localWordlistDir$'" 1
269 call removeWordlist '.deleteWordListDir$'
270 call load_word_list "'localWordlistDir$'" 0
272 call Draw_button '.table$' '.label$' 0
273 call Draw_config_page
277 wordlistTag$ = "Wordlist name"
278 procedure processConfigInstallWordlist .clickX .clickY .pressed$
280 .label$ = "InstallWordlist"
281 call Draw_button '.table$' '.label$' 1
283 # Do not use the automatic sgc list option, ask for a wordlist NAME
285 call findLabel '.table$' '.label$'
287 select Table '.table$'
288 .openDialogue$ = Get value... '.row' Helptext
289 call convert_praat_to_latin1 '.openDialogue$'
290 .openDialogue$ = convert_praat_to_latin1.text$
291 .wordlistButton$ = replace$(wordlistTag$, " ", "_", 0)
292 .wordlistButton$ = replace_regex$(.wordlistButton$, "^.", "\l&", 0)
293 beginPause(.openDialogue$)
294 sentence (wordlistTag$, "")
295 clicked = endPause ("Cancel", "Open", 2, 1)
298 .wordlist_Name$ = '.wordlistButton$'$
300 call install_wordlists_by_name '.wordlist_Name$'
302 call sgc2wordlist 'homeDirectory$'
303 call sgc2wordlist 'homeDirectory$'/Downloads
304 call sgc2wordlist 'homeDirectory$'/Documents
305 call sgc2wordlist 'homeDirectory$'/My Documents
306 call sgc2wordlist 'homeDirectory$'/My Documents/Downloads
307 call sgc2wordlist 'homeDirectory$'/Desktop
308 call sgc2wordlist 'preferencesAppDir$'
310 call load_word_list "'localWordlistDir$'" 0
311 call Draw_button '.table$' '.label$' 0
312 call Draw_config_page
315 procedure processConfigOpenWordlist .clickX .clickY .pressed$
317 .label$ = "OpenWordlist"
318 call Draw_button '.table$' '.label$' 1
321 call findLabel '.table$' '.label$'
323 select Table '.table$'
324 .openDialogue$ = Get value... '.row' Helptext
325 call convert_praat_to_latin1 '.openDialogue$'
326 .openDialogue$ = convert_praat_to_latin1.text$
328 .wordlist_Name$ = chooseReadFile$ (.openDialogue$)
329 call install_wordlists_by_name '.wordlist_Name$'
330 call load_word_list "'localWordlistDir$'" 0
331 call Draw_button '.table$' '.label$' 0
332 call Draw_config_page
335 # Select the words to practise. This is quite a complex piece of code
336 procedure processConfigSelectWords .clickX .clickY .pressed$
338 .label$ = "SelectWords"
339 call Draw_button '.table$' '.label$' 1
342 call findLabel '.table$' '.label$'
344 select Table '.table$'
345 .helpText$ = Get value... '.row' Helptext
346 call convert_praat_to_latin1 '.helpText$'
347 .helpText$ = convert_praat_to_latin1.text$
350 select Table 'wordlist$'
351 .tmpOriginalWordlist = Copy: "Original_'wordlist$'"
355 select Table 'wordlist$'
356 te.numberOfWords = Get number of rows
357 .currentWord = te.currentWord
358 if .currentWord <= 0 or .currentWord > te.numberOfWords or config.shuffleLists
363 call get_feedback_text 'config.language$' Part
364 call convert_praat_to_latin1 'get_feedback_text.text$'
365 .partText$ = convert_praat_to_latin1.text$
366 call get_feedback_text 'config.language$' Tones
367 call convert_praat_to_latin1 'get_feedback_text.text$'
368 .toneText$ = convert_praat_to_latin1.text$
369 call get_feedback_text 'config.language$' Cancel
370 call convert_praat_to_latin1 'get_feedback_text.text$'
371 .cancelText$ = convert_praat_to_latin1.text$
372 call get_feedback_text 'config.language$' Clear
373 call convert_praat_to_latin1 'get_feedback_text.text$'
374 .clearText$ = convert_praat_to_latin1.text$
375 call get_feedback_text 'config.language$' All
376 call convert_praat_to_latin1 'get_feedback_text.text$'
377 .allText$ = convert_praat_to_latin1.text$
378 call get_feedback_text 'config.language$' Previous
379 call convert_praat_to_latin1 'get_feedback_text.text$'
380 .prevWord$ = convert_praat_to_latin1.text$
381 call get_feedback_text 'config.language$' Next
382 call convert_praat_to_latin1 'get_feedback_text.text$'
383 .nextWord$ = convert_praat_to_latin1.text$
384 call get_feedback_text 'config.language$' Continue
385 call convert_praat_to_latin1 'get_feedback_text.text$'
386 .continueText$ = convert_praat_to_latin1.text$
387 call get_feedback_text 'config.language$' Show
388 call convert_praat_to_latin1 'get_feedback_text.text$'
389 .showText$ = convert_praat_to_latin1.text$
391 .pinyinText$ = "Pinyin"
392 .characterText$ = "Character"
395 select Table 'wordlist$'
396 .lessonCol = Get column index: "Lesson"
399 # All shown keeps track whether all words are shown
400 # If so, selecting a lesson is preceded by a Clear All
402 # Sort words for consistent selection interface
403 if config.shuffleLists
404 # Allow subdivision in lessons
406 Sort rows... Lesson Pinyin
412 for .i to te.numberOfWords
413 .currentLesson$ = Get value: .i, "Lesson"
414 if .currentLesson$ <> "" and .currentLesson$ <> "-" and index_regex(.lessonList$, "\t'.currentLesson$'\t") <= 0
415 .lessonList$ = .lessonList$ + .currentLesson$ + tab$
417 .lessonName$['.numLessons'] = .currentLesson$
419 .shown$ = Get value: .i, "Show"
427 .numWordsPerScreen = 15
428 while clicked <> 6 and clicked <> 1
433 select Table 'wordlist$'
434 .lessonCol = Get column index: "Lesson"
435 # Sort words for consistent selection interface
436 if config.shuffleLists
437 # Allow subdivision in lessons
439 Sort rows... Lesson Pinyin
444 .max = .numWordsPerScreen - 1
445 if .currentWord + .max > te.numberOfWords
446 .max = te.numberOfWords - .currentWord
448 for .i from 0 to .numWordsPerScreen - 1
450 .pinyin$[.i] = Get value: .currentWord+.i, "Pinyin"
451 .character$[.i] = Get value: .currentWord+.i, "Character"
454 .lessonNum$[.i] = Get value: .currentWord+.i, "Lesson"
455 .lessonNum$[.i] = " : " + .lessonNum$[.i]
457 .showText$[.i] = .pinyin$['.i']
458 if .character$['.i'] <> "-"
459 .showText$[.i] = .pinyin$['.i']+" ("+.character$['.i']+.lessonNum$['.i']+")"
460 elsif .lessonNum$['.i'] <> ""
461 .showText$[.i] = .pinyin$['.i']+" ( -"+.lessonNum$['.i']+")"
463 .showValueText$[.i] = Get value: .currentWord+.i, "Show"
464 if .showValueText$[.i] = "-"
469 .showVariable$[.i] = replace_regex$(.pinyin$[.i], ".+", "\l&", 0)
470 .showVariable$[.i] = replace_regex$(.showVariable$[.i], " ", "_", 0)
471 .tmp$ = .showVariable$['.i']
472 '.tmp$' = .showValue[.i]
479 # The user text input window (beginPause .... endPause)
480 beginPause(.helpText$)
481 boolean (.showText$[0], .showValue[0])
482 boolean (.showText$[1], .showValue[1])
483 boolean (.showText$[2], .showValue[2])
484 boolean (.showText$[3], .showValue[3])
485 boolean (.showText$[4], .showValue[4])
486 boolean (.showText$[5], .showValue[5])
487 boolean (.showText$[6], .showValue[6])
488 boolean (.showText$[7], .showValue[7])
489 boolean (.showText$[8], .showValue[8])
490 boolean (.showText$[9], .showValue[9])
491 boolean (.showText$[10], .showValue[10])
492 boolean (.showText$[11], .showValue[11])
493 boolean (.showText$[12], .showValue[12])
494 boolean (.showText$[13], .showValue[13])
495 boolean (.showText$[14], .showValue[14])
497 optionMenu: .partText$, 1
500 for .j to .numLessons
501 option: .lessonName$['.j']
504 optionMenu: .toneText$, 1
511 clicked = endPause ("'.cancelText$'", "'.clearText$'", "'.allText$'", "'.prevWord$'", "'.nextWord$'", "'.continueText$'", 6, 1)
514 for .i to te.numberOfWords
515 Set string value: .i, "Show", "-"
519 for .i to te.numberOfWords
520 Set string value: .i, "Show", "+"
524 # Get selected Part BEFORE we do anything else
526 .tmp$ = replace_regex$(.partText$, "^(.)", "\l\1", 0)
527 .lessonSelected = '.tmp$' - 1
529 if .lessonSelected > 0
532 select Table 'wordlist$'
533 for .i to te.numberOfWords
534 # Keep track of whether all are shown
535 .shown$ = Get value: .i, "Show"
540 for .i to te.numberOfWords
542 .currentLesson$ = Get value: .i, "Lesson"
543 if .currentLesson$ = .lessonName$['.lessonSelected']
544 Set string value: .i, "Show", "+"
546 Set string value: .i, "Show", "-"
549 for .i to te.numberOfWords
550 # Keep track of whether all are shown
551 .shown$ = Get value: .i, "Show"
552 if .firstShown <=0 and .shown$ <> "-"
557 for .i from 0 to .max
558 .tmp$ = .showVariable$['.i']
559 .showValue['.i'] = '.tmp$'
560 .showWord$['.i'] = "-"
561 if .showValue['.i'] <> 0
562 .showWord$['.i'] = "+"
564 Set string value: .currentWord+.i, "Show", .showWord$['.i']
567 .tmp$ = replace_regex$(.toneText$, "^(.)", "\l\1", 0)
568 .toneSelected = '.tmp$' - 2
569 if .toneSelected >= 0
570 select Table 'wordlist$'
571 for .i to te.numberOfWords
572 .currentPinyin$ = Get value: .i, "Pinyin"
573 .tmp$ = Get value: .i, "Show"
574 if .tmp$ <> "-" and index(.currentPinyin$, "'.toneSelected'") > 0
575 Set string value: .i, "Show", "+"
577 Set string value: .i, "Show", "-"
585 .currentWord = (.firstShown div .numWordsPerScreen) * .numWordsPerScreen + 1
586 elsif .toneSelected < 0
587 .currentWord -= .numWordsPerScreen
590 .currentWord = (te.numberOfWords div .numWordsPerScreen) * .numWordsPerScreen + 1
594 .currentWord = (.firstShown div .numWordsPerScreen) * .numWordsPerScreen + 1
595 elsif .toneSelected < 0
596 .currentWord += .numWordsPerScreen
598 if .currentWord > te.numberOfWords
603 # Reset and go to the first selected word (can shuffle list)
612 select Table 'wordlist$'
614 select .tmpOriginalWordlist
617 select .tmpOriginalWordlist
619 call Draw_button '.table$' '.label$' 0
622 procedure processConfigPerfSummary .clickX .clickY .pressed$
624 .label$ = "PerfSummary"
626 call testLoadTable SummaryToneEvaluation
627 if testLoadTable.table > 0
628 call Draw_button '.table$' '.label$' 1
629 call loadTable SummaryToneEvaluation
630 call write_tabbed_table SummaryToneEvaluation Evaluation_'config.language$'
632 select Table SummaryToneEvaluation
635 call Draw_button '.table$' '.label$' 0
636 call Draw_config_page
640 # Wipe current performance table and initialize a new one
641 procedure processConfigClearSummary .clickX .clickY .pressed$
643 .label$ = "ClearSummary"
645 call Draw_button '.table$' '.label$' 1
647 select Table '.table$'
648 call findLabel '.table$' !'.label$'
650 .alertText$ = Get value... 'findLabel.row' Text
651 .confirmKey$ = Get value... 'findLabel.row' Key
652 .popupText$ = Get value... 'findLabel.row' Helptext
654 call write_text_popup 'defaultFont$' 14 '.popupText$'
655 call Draw_button '.table$' '.label$' 2
656 alertText$ = .alertText$
657 call Draw_button '.table$' '.label$' 3
660 # Wait for confirmation
662 if demoInput(.confirmKey$)
663 config.savePerf$ = ""
664 call initialize_toneevaluation_tables
668 call Draw_button '.table$' '.label$' 0
669 call Draw_config_page
673 procedure processConfigListPerf .clickX .clickY .pressed$
676 call Draw_button '.table$' '.label$' 1
678 select Table 'initialiseSGC2.toneevaluation_table$'
682 call Draw_button '.table$' '.label$' 0
683 call Draw_config_page
686 procedure processConfigOpenPerf .clickX .clickY .pressed$
689 call Draw_button '.table$' '.label$' 1
692 call findLabel '.table$' !'.label$'
694 select Table '.table$'
695 .openDialogue$ = Get value... '.row' Helptext
696 call convert_praat_to_latin1 '.openDialogue$'
697 .openDialogue$ = convert_praat_to_latin1.text$
698 .defaultName$= "Performance.tsv"
699 if config.savePerf$ <> ""
700 .defaultName$= config.savePerf$
702 .performance_Name$ = chooseReadFile$ (.openDialogue$)
703 if .performance_Name$ <> "" and fileReadable(.performance_Name$)
704 config.savePerf$ = .performance_Name$
705 call initialize_toneevaluation_tables
709 call Draw_button '.table$' '.label$' 0
710 call Draw_config_page
713 procedure processConfigSavePerf .clickX .clickY .pressed$
716 call Draw_button '.table$' '.label$' 1
719 call findLabel '.table$' '.label$'
721 select Table '.table$'
722 .openDialogue$ = Get value... '.row' Helptext
723 call convert_praat_to_latin1 '.openDialogue$'
724 .openDialogue$ = convert_praat_to_latin1.text$
725 .defaultName$= "Performance.tsv"
726 if config.savePerf$ <> ""
727 .defaultName$= config.savePerf$
729 .performance_Name$ = chooseWriteFile$ (.openDialogue$, .defaultName$)
730 if .performance_Name$ <> ""
731 select Table 'initialiseSGC2.toneevaluation_table$'
732 Write to table file... '.performance_Name$'
733 config.savePerf$ = .performance_Name$
736 call Draw_button '.table$' '.label$' 0
737 call Draw_config_page
740 procedure processConfigManual .clickX .clickY .pressed$
743 call Draw_button '.table$' '.label$' 1
744 if fileReadable("ManPages/SpeakGoodChinese_2.man")
745 Read from file... ManPages/SpeakGoodChinese_2.man
747 Go to manual page... SpeakGoodChinese 2
749 # Wait until the manual is put to the background
751 call Draw_button '.table$' '.label$' 0
753 call Draw_config_page
756 procedure processConfigSaveAudio .clickX .clickY .pressed$
758 .label$ = "SaveAudio"
759 call Draw_button '.table$' '.label$' 1
763 call findLabel '.table$' '.label$'
765 select Table '.table$'
766 .openDialogue$ = Get value... '.row' Helptext
767 call convert_praat_to_latin1 '.openDialogue$'
768 .openDialogue$ = convert_praat_to_latin1.text$
770 .audioDir_Name$ = chooseDirectory$ (.openDialogue$)
771 if .audioDir_Name$ <> ""
772 config.saveAudio$ = .audioDir_Name$
779 call Draw_button '.table$' '.label$' 'te.saveAudio'
780 call Draw_config_page
783 ###############################################################
785 # Obligatory button Processing Routines
787 # These MUST be defined
789 ###############################################################
791 procedure processConfigReturn .clickX .clickY .pressed$
794 call Draw_button '.table$' '.label$' 1
795 call write_preferences ""
798 procedure processConfigRefresh .clickX .clickY .pressed$
801 call Draw_config_page
804 procedure processConfigCredits .clickX .clickY .pressed$
807 call Draw_button '.table$' '.label$' 1
808 call write_text_table Credits_'config.language$'
810 call Draw_button '.table$' '.label$' 0
812 call Draw_config_page
815 procedure processConfigHelp .clickX .clickY .pressed$
818 call help_loop '.table$' Draw_config_page
821 ###############################################################
823 # Miscelaneous supporting code
825 ###############################################################
826 procedure install_wordlists_by_name .wordlist_Name$
827 if .wordlist_Name$ <> ""
828 if index(.wordlist_Name$, "wordlist.")
829 .wordlist_Name$ = replace_regex$(.wordlist_Name$, "[/\\]wordlist\.([^/\\]+)$", "", 0)
830 elsif index_regex(.wordlist_Name$, "(?i\.(wav|flac|iaf[fc]|mp3))")
831 .wordlist_Name$ = replace_regex$(.wordlist_Name$, "[/\\][^/\\]+$", "", 0)
833 if index_regex(.wordlist_Name$, "[/\\]")
834 .sourceDir$ = left$(.wordlist_Name$, rindex_regex(.wordlist_Name$, "[/\\]") -1)
835 .file$ = right$(.wordlist_Name$, length(.wordlist_Name$) - rindex_regex(.wordlist_Name$, "[/\\]"))
836 call readWordlist "'.sourceDir$'" '.file$'
839 if index(.wordlist_Name$, ".")
842 .extension1$ = ".sgc"
843 .extension2$ = ".Table"
844 .extension3$ = ".txt"
845 .extension4$ = ".tsv"
847 for .e from .start to 5
848 .currentExtension$ = .extension'.e'$
849 call readWordlist "'homeDirectory$'" '.wordlist_Name$''.currentExtension$'
850 call readWordlist "'homeDirectory$'/Downloads" '.wordlist_Name$''.currentExtension$'
851 call readWordlist "'homeDirectory$'/Documents" '.wordlist_Name$''.currentExtension$'
852 call readWordlist "'homeDirectory$'/My Documents/Downloads" '.wordlist_Name$''.currentExtension$'
853 call readWordlist "'homeDirectory$'/My Documents" '.wordlist_Name$''.currentExtension$'
854 call readWordlist "'homeDirectory$'/Desktop" '.wordlist_Name$''.currentExtension$'
855 call readWordlist "'preferencesAppDir$'" '.wordlist_Name$''.currentExtension$'
861 # Word lists: It is a VERY good idea to make sure that word-lists
863 procedure load_word_list .localdir$ .relnumber
866 # Remove old word list
868 select Table 'wordlist$'
870 call wipeArea 'wipeWordlistArea$'
874 # Create Table that will recieve the wordlists and directories
875 Create Table with column names... AllWordLists 0 Name Directory
876 .te.currentWordlistRow = 0
878 # First the global word lists
879 if fileReadable(globalwordlists$) or fileReadable("'globalwordlists$'/directory.txt")
880 Create Strings as directory list... WordList 'globalwordlists$'
881 .numLists = Get number of strings
883 select Strings WordList
884 .currentName$ = Get string... '.i'
885 if .currentName$ <> "directory.txt"
886 select Table AllWordLists
887 .listExist = Search column: "Name", .currentName$
890 .te.currentWordlistRow = Get number of rows
891 Set string value... '.te.currentWordlistRow' Name '.currentName$'
892 .currentDirectory$ = globalwordlists$+"/"+.currentName$
893 Set string value... '.te.currentWordlistRow' Directory '.currentDirectory$'
897 select Strings WordList
901 # Now the preferences word lists
902 if fileReadable(sgc2wordlists$) or fileReadable("'sgc2wordlists$'/directory.txt")
903 Create Strings as directory list... WordList 'sgc2wordlists$'
904 .numLists = Get number of strings
906 select Strings WordList
907 .currentName$ = Get string... '.i'
908 if .currentName$ <> "directory.txt"
909 select Table AllWordLists
910 .listExist = Search column: "Name", .currentName$
913 .te.currentWordlistRow = Get number of rows
914 Set string value... '.te.currentWordlistRow' Name '.currentName$'
915 .currentDirectory$ = sgc2wordlists$+"/"+.currentName$
916 Set string value... '.te.currentWordlistRow' Directory '.currentDirectory$'
920 select Strings WordList
924 # End with the word lists in the distribution
925 call CreateCreateWordlists
926 select Table CreateWordlists
927 .numLists = Get number of rows
929 select Table CreateWordlists
930 .currentName$ = Get value... '.i' Name
931 if .currentName$ <> "directory.txt"
932 select Table AllWordLists
933 .listExist = Search column: "Name", .currentName$
935 .procedureName$ = replace_regex$(.currentName$, "[^\w\-\.]", "_", 0)
936 select Table AllWordLists
938 .te.currentWordlistRow = Get number of rows
939 Set string value... '.te.currentWordlistRow' Name '.currentName$'
940 .currentDirectory$ = "*call Create'.procedureName$'"
941 Set string value... '.te.currentWordlistRow' Directory '.currentDirectory$'
945 select Table CreateWordlists
948 # Finally, the local word lists
949 if fileReadable(.localdir$) or fileReadable("'.localdir$'/directory.txt")
950 Create Strings as directory list... WordList '.localdir$'
951 .numLists = Get number of strings
953 select Strings WordList
954 .currentName$ = Get string... '.i'
955 if .currentName$ <> "directory.txt"
956 select Table AllWordLists
957 .listExist = Search column: "Name", .currentName$
960 .te.currentWordlistRow = Get number of rows
961 Set string value... '.te.currentWordlistRow' Name '.currentName$'
962 .currentDirectory$ = .localdir$+"/"+.currentName$
963 Set string value... '.te.currentWordlistRow' Directory '.currentDirectory$'
967 select Strings WordList
971 # Get the position of the current word list
972 select Table AllWordLists
974 .numLists = Get number of rows
976 if wordlistName$ <> ""
977 select Table AllWordLists
978 .currentNumber = Search column... Name 'wordlistName$'
981 wordlistNum = .currentNumber + .relnumber
982 if wordlistNum > .numLists
984 elsif wordlistNum < 1 and .numLists > 0
985 wordlistNum = .numLists
987 select Table AllWordLists
988 wordlistName$ = Get value... 'wordlistNum' Name
989 .dirWordlistName$ = Get value... 'wordlistNum' Directory
990 .dirString$ = replace_regex$(.dirWordlistName$, "[ ]", "&", 0)
992 # Read in full tables
993 if fileReadable("'.dirString$'/wordlist.Table")
994 call readTable '.dirString$'/wordlist.Table
995 if readTable.tableID > 0
996 Rename... 'wordlistName$'
997 # Praat wil change the name if it feels like it
998 wordlist$ = selected$("Table")
999 # Add a Sound column if it is not present
1000 .soundIndex = Get column index: "Sound"
1002 Append column: "Sound"
1008 # Handle (legacy) simple word lists
1009 elsif fileReadable("'.dirString$'/wordlist.txt")
1010 Create Table with column names... "'wordlistName$'" 0 Pinyin Character Sound Translation
1011 wordlist$ = selected$("Table")
1012 Read Strings from raw text file... '.dirString$'/wordlist.txt
1013 Rename... RawWordList
1014 .numWordStrings = Get number of strings
1015 for .i to .numWordStrings
1016 select Strings RawWordList
1019 .currentTrans$ = "-"
1020 .currentLine$ = Get string... '.i'
1021 # Remove leading whitespace
1022 .currentLine$ = replace_regex$(.currentLine$, "^[ \t]+", "", 0)
1023 .separatorIndex = index_regex(.currentLine$, "[ \t;\-]")
1024 if .separatorIndex <= 0
1025 .separatorIndex = length(.currentLine$) + 1
1027 .currentPinyin$ = left$(.currentLine$, .separatorIndex-1)
1028 .currentLine$ = right$(.currentLine$, length(.currentLine$) - .separatorIndex)
1029 # There is more on the line, but we do not know what
1030 if length(.currentLine$) > 0
1031 while length(.currentLine$) > 0
1032 .separatorIndex = index_regex(.currentLine$, "[\t;]")
1033 if .separatorIndex <= 0
1034 .separatorIndex = length(.currentLine$)+1
1036 .currentItem$ = left$(.currentLine$, .separatorIndex-1)
1037 .currentLine$ = right$(.currentLine$, length(.currentLine$) - .separatorIndex )
1038 if index_regex(.currentItem$, ".(spx|flac|wav|mp3)")
1040 .currentFile$ = .currentItem$
1041 elsif index_regex(.currentItem$, "[a-zA-Z0-9]") > 0
1043 .currentTrans$ = .currentItem$
1044 elsif index_regex(.currentItem$, "[^ \t\r\l]") > 0 && index_regex(.currentItem$, "[a-zA-Z0-9\-]") <= 0
1046 .currentChar$ = .currentItem$
1050 if .currentFile$ = "-"
1051 if fileReadable("'.dirString$'/'.currentPinyin$'.spx")
1052 .currentFile$ = .currentPinyin$+".spx"
1053 elsif fileReadable("'.dirString$'/'.currentPinyin$'.flac")
1054 .currentFile$ = .currentPinyin$+".flac"
1055 elsif fileReadable("'.dirString$'/'.currentPinyin$'.wav")
1056 .currentFile$ = .currentPinyin$+".wav"
1057 elsif fileReadable("'.dirString$'/'.currentPinyin$'.mp3")
1058 .currentFile$ = .currentPinyin$+".mp3"
1061 select Table 'wordlist$'
1063 Set string value... '.i' Pinyin '.currentPinyin$'
1064 Set string value... '.i' Sound '.currentFile$'
1065 Set string value... '.i' Character '.currentChar$'
1066 Set string value... '.i' Translation '.currentTrans$'
1068 select Strings RawWordList
1071 select Table 'wordlist$'
1072 elsif fileReadable(.dirString$) or fileReadable("'.dirString$'/directory.txt")
1073 Create Table with column names... "'wordlistName$'" 0 Pinyin Sound
1074 wordlist$ = selected$("Table")
1075 Create Strings as file list... RawWordList '.dirString$'/*
1076 .numWordStrings = Get number of strings
1078 for .j to .numWordStrings
1079 select Strings RawWordList
1080 .currentLine$ = Get string... '.j'
1081 .currentFile$ = extractWord$(.currentLine$, "")
1082 if index_regex(.currentFile$, "\.(spx|flac|wav|mp3)")
1083 .currentPinyin$ = left$(.currentFile$, index(.currentFile$, ".")-1)
1084 select Table 'wordlist$'
1087 Set string value... '.i' Pinyin '.currentPinyin$'
1088 Set string value... '.i' Sound '.currentFile$'
1091 select Strings RawWordList
1094 select Table 'wordlist$'
1095 elsif startsWith(.dirString$, "*call ")
1096 .callProcedure$ = right$(.dirString$, length(.dirString$)-1)
1098 wordlist$ = selected$("Table")
1105 # Can this wordlist be deleted?
1106 if fileReadable("'sgc2wordlists$'/'wordlistName$'") or fileReadable("'sgc2wordlists$'/'wordlistName$'/wordlist.txt") or fileReadable("'sgc2wordlists$'/'wordlistName$'/wordlist.Table")
1107 config.deleteWordlist = 0
1109 config.deleteWordlist = -1
1112 # Check first column name and add Character, Translation and Show columns if missing
1114 select Table 'wordlist$'
1115 # HAck to correct odd behavior of tables with unicode characters
1116 .firstColumn$ = Get column label: 1
1117 if index_regex(.firstColumn$, "^[^!-~]") > 0
1118 .firstColumn$ = replace_regex$(.firstColumn$, "^[^!-~]", "", 0)
1119 Set column label (index): 1, .firstColumn$
1122 te.numberOfWords = Get number of rows
1123 .characterColumn = Get column index... Character
1124 if not .characterColumn
1125 Append column... Character
1126 for .i to te.numberOfWords
1127 Set string value... '.i' Character -
1130 .translationColumn = Get column index... Translation
1131 if not .translationColumn
1132 Append column... Translation
1133 for .i to te.numberOfWords
1134 Set string value... '.i' Translation -
1137 .showColumn = Get column index... Show
1139 Append column... Show
1140 for .i to te.numberOfWords
1141 Set string value... '.i' Show +
1146 # Remove all rows without Pinyin
1147 .numRows = Get number of rows
1149 .rowNum = .numRows - i + 1
1150 .pinyinValue$ = Get value... '.rowNum' Pinyin
1151 if not index_regex(.pinyinValue$, "[a-zA-Z0-9]")
1152 Remove row... '.rowNum'
1155 te.numberOfWords = Get number of rows
1157 # Shuffle words if requested
1158 if config.shuffleLists
1164 select Table AllWordLists
1167 # There were no Word Lists
1170 wordlistName$ = wordlistName$+" No Word Lists available"
1172 Create Table with column names... "'wordlistName$'" 0 Pinyin Character Translation Sound
1173 wordlist$ = selected$("Table")
1177 Set string value... '.i' Pinyin ni3hao3
1178 Set string value... '.i' Character 你好
1179 Set string value... '.i' Translation hello
1180 Set string value... '.i' Sound -
1183 Set string value... '.i' Pinyin xie4xie0
1184 Set string value... '.i' Character 谢谢
1185 Set string value... '.i' Translation thanks
1186 Set string value... '.i' Sound -
1189 Set string value... '.i' Pinyin zai4jian4
1190 Set string value... '.i' Character 再见
1191 Set string value... '.i' Translation goodbye
1192 Set string value... '.i' Sound -
1193 te.numberOfWords = Get number of rows
1196 call set_window_title 'buttons$' 'wordlistName$'
1201 select Table 'wordlist$'
1203 if te.currentWord < 0 or te.currentWord > te.numberOfWords
1204 if config.shuffleLists
1209 while .showCurrent$ = "-" and te.currentWord <= te.numberOfWords
1211 if te.currentWord <= te.numberOfWords
1212 .showCurrent$ = Get value... 'te.currentWord' Show
1218 procedure previous_word
1220 select Table 'wordlist$'
1222 if te.currentWord <= 0
1223 if config.shuffleLists
1226 te.currentWord = te.numberOfWords + 1
1228 while .showCurrent$ = "-" and te.currentWord > 0
1230 if te.currentWord > 0
1231 .showCurrent$ = Get value... 'te.currentWord' Show
1237 procedure display_word_list_name
1241 .displayWordList$ = replace_regex$(wordlistName$, "[_]", " ", 0)
1242 call wipeArea 'wipeWordlistArea$'
1243 call adjustFontSizeOnHeight 'defaultFont$' 'defaultFontSize' 5
1244 .currentFontSize = adjustFontSizeOnHeight.newFontSize
1247 demo Text special... '.xtext' Centre '.ytext' Bottom 'defaultFont$' '.currentFontSize' 0 '.displayWordList$'
1250 call set_font_size 'defaultFontSize'
1253 procedure write_word_list
1254 # Write current Pinyin text
1255 call display_text Black
1257 # Write the current word list name
1258 call display_word_list_name
1261 procedure start_logging
1262 if fileReadable("'preferencesLogDir$'/logPerformance.txt")
1263 .logDirectory$ < 'preferencesLogDir$'/logPerformance.txt
1264 .logDirectory$ = extractWord$(.logDirectory$, "")
1265 if .logDirectory$ = "" or not (fileReadable(.logDirectory$) or fileReadable("'.logDirectory$'/directory.txt")
1266 .logDirectory$ = "'preferencesLogDir$'"
1268 currentLogDirectory$ = "'.logDirectory$'/log'logtimeStamp$'"
1269 createDirectory(currentLogDirectory$)
1270 if not fileReadable("'currentLogDirectory$'/wordlist.Table")
1271 .headerLine$ = "Pinyin'tab$'Character'tab$'Sound'newline$'"
1272 .headerLine$ > 'currentLogDirectory$'/wordlist.Table
1275 config.logPerformance = 1
1279 procedure log_command .logtext$
1281 fileappend "'currentLogDirectory$'/logFile.txt" '.logtext$''newline$'
1285 procedure log_performance .recordedSound$ .register .proficiency .pinyin$ .choice$
1287 .currentDate$ = date$()
1288 .timeStamp$ = replace_regex$(.currentDate$, "[^a-zA-Z0-9\-_]", "-", 0)
1289 .choiceText$ = replace_regex$(.choice$, "[^a-zA-Z0-9\-_]", "-", 0)
1291 if config.logPerformance and fileReadable("'preferencesLogDir$'/logPerformance.txt")
1292 .outfilename$ = .pinyin$+"_"+.choice$+"_'.register'_"+.timeStamp$+".wav"
1293 .logtext$ = "# #+.pinyin$+tab$+.choice$+tab$+"'.register'Hz"+tab$+.currentDate$+tab$+.outfilename$+newline$
1295 fileappend 'currentLogDirectory$'/logFile.txt '.logtext$'
1298 fileappend 'currentLogDirectory$'/wordlist.Table '.pinyin$''tab$''.choice$''tab$''.outfilename$''newline$'
1299 # The recorded sound
1300 select Sound 'recordedSound$'
1301 Write to WAV file... 'currentLogDirectory$'/'.outfilename$'
1305 procedure paint_saveAudio_light
1306 select Table 'config$'
1307 .row = Search column... Label SaveAudio
1309 exit Button Table Config does not have a row with label SaveAudio
1312 .leftX = Get value... '.row' LeftX
1313 .rightX = Get value... '.row' RightX
1314 .lowY = Get value... '.row' LowY
1315 .highY = Get value... '.row' HighY
1316 .buttonColor$ = Get value... '.row' Color
1317 # The button text and symbol
1318 .horWC = demo Horizontal mm to wc... 10.0
1319 .verWC = demo Vertical mm to wc... 10.0
1321 .verCoeff = .horWC / .verWC
1326 .centerX = (.leftX + .rightX)/2
1327 .centerY = .lowY + 0.6*(.highY-.lowY)
1328 .radius = min(.verCoeff * (.highY - .lowY ), (.rightX - .leftX))/3
1329 .wipeRadius = 1.1*.radius
1330 call DrawSaveAudio White '.centerX' '.centerY' '.wipeRadius'
1332 if te.saveAudio and config.saveAudio$ <> ""
1333 call DrawSaveAudio "DarkBlue" '.centerX' '.centerY' '.radius'
1338 # Uninstall word lists
1339 procedure removeWordlist .deletedWordlistName$
1341 if fileReadable("'sgc2wordlists$'/'.deletedWordlistName$'") or fileReadable("'sgc2wordlists$'/'.deletedWordlistName$'/wordlist.txt") or fileReadable("'sgc2wordlists$'/'.deletedWordlistName$'/wordlist.Table")
1342 .targetDir$ = "'sgc2wordlists$'/'.deletedWordlistName$'"
1344 if .targetDir$ <> ""
1345 Create Strings as file list... DeleteList '.targetDir$'
1346 .numdeleteFiles = Get number of strings
1347 for .i to .numdeleteFiles
1348 .file$ = Get string... '.i'
1349 deleteFile("'.targetDir$'/'.file$'")
1351 filedelete '.targetDir$'
1352 # Check whether the directory was actually deleted. Make sure this is a valid directory name!
1353 # That is, it does not contain funny characters, nor funny names
1354 if index_regex(.deletedWordlistName$, "[^a-zA-Z0-9_ .\-]") <= 0 and index(.deletedWordlistName$, "..") <= 0 and index_regex(.deletedWordlistName$, "[a-zA-Z]") > 0
1356 nocheck system rmdir "'.targetDir$'" /s /q
1357 elsif fileReadable(.targetDir$)
1358 system bash -rc -- 'rm -r -- "'.targetDir$'"'
1361 # Remove deleted word list
1362 select Strings DeleteList
1363 plus Table 'wordlist$'
1369 # Install word lists
1370 procedure sgc2wordlist .sourceDir$
1371 if startsWith(.sourceDir$, "preferencesDirectory$")
1372 .sourceDir$ = replace$(.sourceDir$, "preferencesDirectory$", preferencesDirectory$)
1375 .targetDirectory$ = "'sgc2wordlists$'"
1376 if fileReadable(.sourceDir$) or fileReadable("'.sourceDir$'/directory.txt")
1377 Create Strings as file list... PackageList '.sourceDir$'/*.sgc
1378 .numFiles = Get number of strings
1380 select Strings PackageList
1381 .file$ = Get string... '.i'
1382 call readWordlist '.sourceDir$' '.file$'
1385 select Strings PackageList
1390 # Debuggin remarks!!!
1391 # fileReadable(<directory>) does not work in Windows
1392 # The file paths / -> \\ must be performed on the filenames in Windows before the system_nocheck is given
1393 # And yet only the 7z decompression has been implemented
1394 windowsUnzipCommand$ = ""
1395 if fileReadable("C:\Program Files\7-Zip\7z.exe")
1396 windowsUnzipCommand$ = """C:\Program Files\7-Zip\7z.exe"" e"
1397 windowsUnzipDestDir$ = " -o"
1398 elsif fileReadable("C:\Program Files\WinZip\winzip32.exe")
1399 # !!! Find a way to include the output folder !!!
1400 windowsUnzipCommand$ = "C:\Program Files\WinZip\winzip32.exe"" -min -e "
1401 windowsUnzipDestDir$ = ""
1403 procedure readWordlist .sourceDir$ .file$
1404 # No use doing anything if the source does not exist
1405 if fileReadable("'.sourceDir$'/'.file$'") or fileReadable("'.sourceDir$'/'.file$'/wordlist.txt") or fileReadable("'.sourceDir$'/'.file$'/wordlist.Table")
1406 # What will be the target wordlist directory?
1407 .targetDirectory$ = "'sgc2wordlists$'"
1408 .dirname$ = left$(.file$, rindex(.file$, ".")-1)
1412 .wordlistDirectory$ = .targetDirectory$+"/"+.dirname$
1413 # Wordlist directory does not exist, neither locally nor in the preferences
1415 .tmpDirs = nocheck Create Strings as directory list... TMPWORDLISTS '.targetDirectory$'/
1416 if .tmpDirs != undefined and .tmpDirs > 0
1417 .numDirs = Get number of strings
1420 .currentString$ = Get string... '.d'
1421 if .currentString$ = .dirname$
1427 if not (.wordListExists or fileReadable(.dirname$) or fileReadable("'.dirname$'/directory.txt") or fileReadable(.wordlistDirectory$) or fileReadable("'.wordlistDirectory$'/directory.txt"))
1429 # Move source to destination
1430 if index(.file$, ".sgc") or index(.file$, ".zip")
1431 if index_regex(.wordlistDirectory$, "[^a-zA-Z0-9_\.\- /~\:]") <= 0 and index_regex(.dirname$, "[^a-zA-Z0-9_\.\- ]") <= 0 and not (windows and windowsUnzipCommand$ = "")
1432 # Create wordlist directory
1433 createDirectory(.wordlistDirectory$)
1435 if macintosh or unix
1436 system cd ''.wordlistDirectory$'';bash -rc -- 'unzip "'.file$'"' -d ''.wordlistDirectory$''
1437 elsif windows and windowsUnzipCommand$ <> ""
1438 .winWordListDirectory$ = replace_regex$(.wordlistDirectory$, "/", "\\", 0)
1439 .winSourceDirectory$ = replace_regex$("'.sourceDir$'\'.file$'", "/", "\\", 0)
1440 system mkdir "'.winWordListDirectory$'" & 'windowsUnzipCommand$' "'.winSourceDirectory$'" 'windowsUnzipDestDir$'"'.winWordListDirectory$'"
1443 # Remove if not valid!
1444 if fileReadable("'.wordlistDirectory$'/wordlist.Table") or fileReadable("'.wordlistDirectory$'/wordlist.txt") or fileReadable("'.wordlistDirectory$'/LICENSE.txt")
1445 if fileReadable("'.wordlistDirectory$'/wordlist.Table")
1446 call readTable '.sourceDir$'/'.file$'
1447 if readTable.tableID > 0
1448 select readTable.tableID
1449 # Hack around odd behavior of column index
1451 .firstColumn$ = Get column label: 1
1452 .firstColumn$ = replace_regex$(.firstColumn$, "^[^!-~]", "", 0)
1453 if .firstColumn$ = "Pinyin"
1456 .pinyinCol = Get column index... Pinyin
1459 # No Pinyin in table
1468 # None of wordlist.Table, wordlist.txt, nor LICENSE.txt
1471 ### REALLY DANGEROUS STUFF, SHOULD BE HANDLED BETTER
1473 # Remove newly created directory
1474 if index_regex(.wordlistDirectory$, "[^a-zA-Z0-9_\.\- /~\:]") <= 0 and index_regex(.dirname$, "[^a-zA-Z0-9_\.\- ]") <= 0 and index(.dirname$, "..") <= 0
1475 if macintosh or unix
1476 system bash -rc -- 'rm -r "'.wordlistDirectory$'/"'
1478 system rmdir /Q /S "'.winWordListDirectory$'/"
1482 elsif index_regex(.file$, "\.(Table|txt|tsv)")
1483 # Check whether this is a valid table
1484 call readTable '.sourceDir$'/'.file$'
1485 if readTable.tableID > 0
1486 select readTable.tableID
1487 # Hack around odd behavior of column index
1489 .firstColumn$ = Get column label: 1
1490 .firstColumn$ = replace_regex$(.firstColumn$, "^[^!-~]", "", 0)
1491 if .firstColumn$ = "Pinyin"
1494 .pinyinCol = Get column index... Pinyin
1499 # Create wordlist directory
1500 createDirectory(.wordlistDirectory$)
1502 .extension$ = replace_regex$(.file$, "^.+\.(Table|txt|tsv)$", "\1", 0)
1503 if .extension$ = "tsv"
1504 .extension$ = "Table"
1506 if macintosh or unix
1507 system bash -rc -- 'cp "'.sourceDir$'/'.file$'" "'.wordlistDirectory$'/wordlist.'.extension$'"'
1509 .winWordListDirectory$ = replace_regex$(.wordlistDirectory$, "/", "\\", 0)
1510 .winSourceDirectory$ = replace_regex$("'.sourceDir$'\'.file$'", "/", "\\", 0)
1511 system copy "'.winSourceDirectory$'" "'.winWordListDirectory$'\wordlist.'.extension$'" /q
1515 elsif fileReadable("'.sourceDir$'/'.file$'/wordlist.Table") or fileReadable("'.sourceDir$'/'.file$'/wordlist.txt") or fileReadable("'.sourceDir$'/'.file$'/LICENSE.txt")
1516 # Copy wordlist directory
1517 if index_regex(.file$, "[^a-zA-Z0-9_\.\- ]") <= 0
1519 if macintosh or unix
1520 system bash -rc -- 'cp -r "'.sourceDir$'/'.file$'" "'.wordlistDirectory$'"'
1522 createDirectory(.wordlistDirectory$)
1523 .winWordListDirectory$ = replace_regex$(.wordlistDirectory$, "/", "\\", 0)
1524 .winSourceDirectory$ = replace_regex$("'.sourceDir$'\'.file$'", "/", "\\", 0)
1525 system xcopy "'.winSourceDirectory$'" "'.winWordListDirectory$'" /s /e /q
1530 # Set current word list to read list
1532 wordlistName$ = .dirname$
1535 .label$ = "!NotAWordlist"
1538 call findLabel '.table$' '.label$'
1539 .row = findLabel.row
1540 select Table '.table$'
1541 .helpText$ = Get value... '.row' Helptext
1542 .filetext$ = replace_regex$("'.sourceDir$'/'.file$'", "_", "\\_ ", 0)
1543 call write_text_popup 'defaultFont$' 14 '.helpText$' "'.filetext$'"
1544 # Wait for confirmation