📄 dec_read_0.tcl.in
字号:
#! @TCL@ -f## file: dec_read_0.tcl## procedures to read the data from file, and set up lists for each# line of data i.e. each word hypothesis## procedure to open and read file#proc read_proc {filename} { # declare globals # global hyp_list global phone_list global traces_new global traces_del global traces_tot # define local variables # global word_hyp global word_item global p # initialize word hypotheses list # set hyp_list {} set phone_list {} set flag 1 set wstart 0 # enable the text area # $p.stats configure -state normal $p.stats delete 1.0 end # make sure file exists # if {[file exists $filename] == 0} { $p.stats configure -state disabled return } # open the file # set fileptr [open $filename r] # read the trace statistics information first and display it # set ff 0 while {$flag == 1} { # read the file line by line # set str [gets $fileptr] set str [string trim $str] # read the trace statistics # if {$ff == 0} { scan $str "%s = %d\n" Time time } elseif {$ff == 1} { set str "\n" } elseif {$ff == 2} { scan $str "%s %s %s %s" w1 w2 w3 w4 set str [format "\t\t%8s\t%8s\t%8s\t%8s\n" $w1 $w2 $w3 $w4] $p.stats insert end $str } else { scan $str "%s %d %d %d %d" w1 w2 w3 w4 w5 set str [format "\t%-8s\t%8d\t%8d\t%8d\t%8d\n" $w1 $w2 $w3 $w4 $w5] $p.stats insert end $str } incr ff if {$ff == 6} { set flag 0 } } # disable the text area # $p.stats configure -state disabled # now read the path information # while {![eof $fileptr]} { # read the file line by line # set str [gets $fileptr] set str [string trim $str] if {[string match $str ""] == 0} { # create a new hypothesis # set wstart 0 set word_hyp {} set ph_sequence {} # only if this is not a blank line # while {[string match $str ""] == 0} { # scan the string for start and end time and phone # scan $str "%d %d %s %s" start_f end_f phstr score # set a phone item # set phone {} lappend phone $start_f $end_f $score $phstr lappend ph_sequence $phone # check if this is a word end # set ind [expr [string last $score $str] + \ [string length $score]] set score [format "%.6f" $score] if {$ind != -1} { incr ind set rest_str [string range $str $ind end] } else { set rest_str "" } set str [string trim $rest_str] if {[string match $str ""] == 0} { # scan the string for word data # scan $str "%s %f %f" word word_penalty score # create a word item # set word_item {} lappend word_item $wstart $end_f $score $word lappend word_hyp $word_item set wstart $end_f } # read the next line # set str [gets $fileptr] set str [string trim $str] } # append the word hypothesis to list of hyps # lappend hyp_list $word_hyp # append the phone hypothesis to the phone list # lappend phone_list $ph_sequence } } # close file # close $fileptr}# end of file#
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -