Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

YadaRanking.tcl

00001 # Copyright (C) 1997-2004 The CDG Team <cdg@nats.informatik.uni-hamburg.de> 00002 # 00003 # This file is free software; as a special exception the author gives 00004 # unlimited permission to copy and/or distribute it, with or without 00005 # modifications, as long as this notice is preserved. 00006 # 00007 # This program is distributed in the hope that it will be useful, but 00008 # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the 00009 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00010 00011 ## ---------------------------------------------------------------------------- 00012 ## YadaRanking - load sets of results. 00013 ## \ingroup YadaDocuments 00014 ## 00015 ## \author Michael Daum 00016 ## 00017 ## $Id: YadaRanking.tcl,v 1.18 2004/09/06 13:41:13 micha Exp $ 00018 ## ---------------------------------------------------------------------------- 00019 class YadaRanking { 00020 inherit YadaDocument 00021 00022 # variables ---------------------------------------------------------------- 00023 private variable _isRunning 0 00024 private variable _gotBreak 0 00025 private variable _typeOfColumn; ## \type TclArray 00026 private variable _rankingFormula "" 00027 private variable _experimentFilters {} 00028 private variable _followDataFlag 1 00029 private variable _lastSorting 1 00030 private variable _rankingOf "" 00031 private variable _totalTime 0 00032 private variable _totalExperiments 0 00033 private variable _runner; ## single runner object to load persistant experiment data from 00034 00035 # methods ------------------------------------------------------------------ 00036 public method init {} 00037 public method reload {} 00038 public method clear {} 00039 public method activationHandle {} 00040 public method breakProcess {} 00041 public method unbreakProcess {} 00042 public method interruptProcess {} 00043 public method sortRows {colNo args}; ## \type TclNumber, TclList 00044 public method resortRows {} 00045 public method toggleFollowData {} 00046 public method isFollowData {} 00047 public method toDOM {}; ## virtual 00048 public method fromDOM {node}; ## virtual \type domNode 00049 public method displayTitle {} 00050 public method getPersistanceFileName {} ; ## virtual 00051 00052 constructor {args} {}; ## \type TclList 00053 destructor {} 00054 00055 private method _getCurrentGrammar {} 00056 private method _selectGrammar {{grammarName ""}}; ## \type TclString 00057 private method _getActiveWork {} 00058 private method _getSelectedWork {} 00059 private method _getUndoneWork {} 00060 private method _getDoneWork {} 00061 private method _getWork {} 00062 private method _analyseDocument {document experiment wordgraph}; ## \type DomDocument, YadaExperiment, TclString 00063 private method _breakButtonAction {} 00064 private method _leaveTableCommand {} 00065 private method _escapeCommand {} 00066 private method _returnCommand {} 00067 private method _getRowOfExperimentName {experimentName}; ## \type TclString 00068 private method _insertData {experiment}; ## \type YadaExperiment 00069 private method _selectRanking {{formula ""}}; ## \type TclString 00070 private method _selectRankingCommand {} 00071 private method _selectFilter {{filters ""}}; ## \type TclString 00072 private method _selectFilterCommand {} 00073 private method _normalizeRankings {} 00074 private method _getRankingOfExperiment {experimentName}; ## \type TclString 00075 private method _setRankingOfExperiment {experimentName ranking}; ## \type TclString, TclNumber 00076 private method _unsetRankingOfExperiment {experimentName}; ## \type TclString 00077 private method _rowTagCommand {row}; ## \type TclNumber 00078 private method _computeStatistics {} 00079 private method _showStatistics {} 00080 #private method _loadUpdatedExperiments {{listOfExperimentNames ""}}; ## \type TclList, TclNumber 00081 private method _getRunners {runners listExperiments listExperimentsInDocument}; ## \type TclArray, TclList, TclList 00082 private method _reloadFromRunner {} 00083 00084 }; 00085 00086 ## ---------------------------------------------------------------------------- 00087 ## constructor 00088 ## ---------------------------------------------------------------------------- 00089 body YadaRanking::constructor {args} { 00090 00091 # Instantiate single runner object, serving as a delegate for evaluation of several experiments 00092 set _runner [YadaRunner ".main.#auto" -name Runner -hasView "false"] 00093 00094 # edit menu 00095 $itk_component(editMenu) add command \ 00096 -label "Clear" \ 00097 -underline 0 \ 00098 -command [code $this clear] 00099 $itk_component(editMenu) add command \ 00100 -label "Break" \ 00101 -underline 0 \ 00102 -command [code $this breakProcess] 00103 $itk_component(editMenu) add command \ 00104 -label "Interrupt" \ 00105 -underline 0 \ 00106 -command [code $this interruptProcess] 00107 00108 # view menu 00109 itk_component add sortIncMenu { 00110 menu $itk_component(viewMenu).sortIncMenu 00111 } { 00112 keep -background -cursor 00113 rename -borderwidth -menuborderwidth menuBorderwidth Borderwidth 00114 } 00115 00116 itk_component add sortDecMenu { 00117 menu $itk_component(viewMenu).sortDecMenu 00118 } { 00119 keep -background -cursor 00120 rename -borderwidth -menuborderwidth menuBorderwidth Borderwidth 00121 } 00122 $itk_component(viewMenu) add separator 00123 $itk_component(viewMenu) add cascade \ 00124 -label "Sort inc. by" \ 00125 -underline 0 \ 00126 -menu $itk_component(sortIncMenu) 00127 $itk_component(viewMenu) add cascade \ 00128 -label "Sort dec. by" \ 00129 -underline 0 \ 00130 -menu $itk_component(sortDecMenu) 00131 00132 # set types of columns 00133 array set _typeOfColumn { 00134 0 "dictionary" 00135 1 "real" 00136 2 "real" 00137 3 "real" 00138 4 "integer" 00139 5 "integer" 00140 6 "integer" 00141 } 00142 00143 # toolbar 00144 $itk_component(toolbar) add FlatButton reloadButton \ 00145 -image [YadaImages::get reload] \ 00146 -balloonstr "reload" \ 00147 -command [code $this reload] 00148 00149 $itk_component(toolbar) add FlatButton clearButton \ 00150 -image [YadaImages::get erase] \ 00151 -command [code $this clear] \ 00152 -balloonstr "clear" 00153 00154 $itk_component(toolbar) add FlatButton breakButton \ 00155 -image [YadaImages::get giveup] \ 00156 -command [code $this _breakButtonAction] \ 00157 -balloonstr "break" 00158 00159 $itk_component(toolbar) add FlatButton term \ 00160 -image [YadaImages::get stop] \ 00161 -command [code $this interruptProcess] \ 00162 -balloonstr "interrupt" 00163 00164 00165 # heading space 00166 itk_component add heading { 00167 frame $itk_component(childsite).heading 00168 } 00169 00170 # the grammar 00171 itk_component add grammarBoxLabel { 00172 label $itk_component(heading).grammarBoxLabel \ 00173 -text "Grammar:" \ 00174 -anchor w 00175 } {} 00176 00177 itk_component add grammarBox { 00178 iwidgets::combobox $itk_component(heading).grammarBox \ 00179 -completion false \ 00180 -borderwidth 2 \ 00181 -margin 4 \ 00182 -selectioncommand [code $this _selectGrammar] 00183 } {} 00184 00185 # the total time 00186 itk_component add totalTimeLabel { 00187 label $itk_component(heading).totalTimeLabel \ 00188 -text "Time:" \ 00189 -anchor w 00190 } {} 00191 00192 itk_component add totalTime { 00193 entry $itk_component(heading).totalTime \ 00194 -borderwidth 2 \ 00195 -state disabled \ 00196 -width 0 00197 } {} 00198 00199 # the total number of experiments 00200 itk_component add totalLabel { 00201 label $itk_component(heading).totalLabel \ 00202 -text "Total:" \ 00203 -anchor w 00204 } {} 00205 00206 itk_component add totalExperiments { 00207 entry $itk_component(heading).totalExperiments \ 00208 -borderwidth 2 \ 00209 -state disabled \ 00210 -textvariable [scope _totalExperiments] \ 00211 -width 0 00212 } {} 00213 00214 00215 # the sorting 00216 itk_component add sortingBoxLabel { 00217 label $itk_component(heading).sortingBoxLabel \ 00218 -text "Sort by:" \ 00219 -anchor w \ 00220 } {} 00221 00222 itk_component add sortingBox { 00223 iwidgets::combobox $itk_component(heading).sortingBox \ 00224 -completion false \ 00225 -borderwidth 2 \ 00226 -margin 4 \ 00227 -selectioncommand [code $this _selectRankingCommand] 00228 } {} 00229 $itk_component(sortingBox) insert entry 0 $_rankingFormula 00230 00231 # the experiment filter 00232 itk_component add experimentFilterLabel { 00233 label $itk_component(heading).experimentFilterLabel \ 00234 -text "Experiment Filter:" \ 00235 -anchor w \ 00236 } {} 00237 00238 itk_component add experimentFilterBox { 00239 iwidgets::combobox $itk_component(heading).experimentFilterBox \ 00240 -completion false \ 00241 -borderwidth 2 \ 00242 -margin 4 \ 00243 -selectioncommand [code $this _selectFilterCommand] 00244 } {} 00245 $itk_component(experimentFilterBox) insert entry 0 $_experimentFilters 00246 00247 00248 # the table 00249 itk_component add pane { 00250 iwidgets::panedwindow $itk_component(childsite).pane \ 00251 -orient horizontal \ 00252 -sashindent -8 \ 00253 -thickness 2 \ 00254 -sashheight 8 \ 00255 -sashwidth 18 00256 } { 00257 keep -background -cursor 00258 } 00259 $itk_component(pane) add top -margin 0 00260 set top [$itk_component(pane) childsite top] 00261 00262 itk_component add table { 00263 MyTable $top.table \ 00264 -exportselection 1 \ 00265 -selecttitles 1 \ 00266 -rowseparator "\n" \ 00267 -colseparator "\t" \ 00268 -rows 300 \ 00269 -cols 8 \ 00270 -state normal \ 00271 -cellanchor w \ 00272 -colstretchmode last \ 00273 -rowstretchmode none \ 00274 -selectmode extended \ 00275 -selecttype row \ 00276 -titlerows 1 \ 00277 -titlecols 0 \ 00278 -borderwidth 3 \ 00279 -outerborderwidth 2 \ 00280 -outerrelief sunk \ 00281 -selforeground "" \ 00282 -selbackground "" \ 00283 -font {-adobe-helvetica-medium-r-normal--12-*-*-*-*-*-*-*} \ 00284 -hscrollmode dynamic \ 00285 -rowtagcommand [code $this _rowTagCommand] 00286 } { 00287 keep -background -cursor 00288 } 00289 00290 # bindings 00291 set hull $itk_component(hull) 00292 set tableInTable [$itk_component(table) component table] 00293 bind $hull <Leave> [code $this _leaveTableCommand] 00294 bind $hull <FocusOut> [code $this _leaveTableCommand] 00295 bind $tableInTable <KeyPress-Escape> [code "$this _escapeCommand; break"] 00296 bind $tableInTable <KeyPress-Return> [code "$this _returnCommand; break"] 00297 set entry [$itk_component(sortingBox) component entry] 00298 bind $entry <KeyPress-Return> [code $this _selectRankingCommand] 00299 set entry [$itk_component(experimentFilterBox) component entry] 00300 bind $entry <KeyPress-Return> [code $this _selectFilterCommand] 00301 00302 # packing + gridding 00303 pack $itk_component(heading) -fill x -side top -anchor n 00304 pack $itk_component(pane) -fill both -expand 1 -padx 2 -pady 5 -side top 00305 pack $itk_component(table) -fill both -expand 1 -anchor n 00306 00307 grid columnconfigure $itk_component(heading) 1 -weight 1 00308 grid columnconfigure $itk_component(heading) 3 -weight 1 00309 grid columnconfigure $itk_component(heading) 5 -weight 1 00310 grid columnconfigure $itk_component(heading) 6 -weight 1 00311 00312 grid $itk_component(grammarBoxLabel) -row 0 -column 0 -sticky ew -pady 2 00313 grid $itk_component(grammarBox) -row 0 -column 1 -sticky ew -pady 2 -columnspan 3 00314 grid $itk_component(sortingBoxLabel) -row 0 -column 4 -sticky ew -pady 2 00315 grid $itk_component(sortingBox) -row 0 -column 5 -sticky ew -pady 2 -columnspan 2 00316 00317 grid $itk_component(totalLabel) -row 1 -column 0 -sticky ew -pady 2 00318 grid $itk_component(totalExperiments) -row 1 -column 1 -sticky ew -pady 2 00319 grid $itk_component(totalTimeLabel) -row 1 -column 2 -sticky ew -pady 2 00320 grid $itk_component(totalTime) -row 1 -column 3 -sticky ew -pady 2 00321 grid $itk_component(experimentFilterLabel) -row 1 -column 4 -sticky ew -pady 2 00322 grid $itk_component(experimentFilterBox) -row 1 -column 5 -sticky ew -pady 2 -columnspan 2 00323 00324 eval itk_initialize $args 00325 .main registerDocument $this 00326 } 00327 00328 00329 ## ---------------------------------------------------------------------------- 00330 ## Destructor 00331 ## ---------------------------------------------------------------------------- 00332 body YadaRanking::destructor {} { 00333 delete object $_runner 00334 } 00335 00336 00337 ## ---------------------------------------------------------------------------- 00338 ## clear 00339 ## ---------------------------------------------------------------------------- 00340 body YadaRanking::clear {} { 00341 set table $itk_component(table) 00342 set selection [$table curselection] 00343 set cmax [$table cget -cols] 00344 00345 # only delete the seleted rows 00346 if {$selection != ""} { 00347 set minRow 9999 00348 set maxRow 0 00349 00350 foreach index $selection { 00351 scan $index "%d,%d" row col 00352 00353 # delete ranking information 00354 set experimentName [$table getCell $row,0] 00355 _unsetRankingOfExperiment $experimentName 00356 00357 $table erase $row,0 $row,$cmax 00358 $table clear tags $row,0 $row,$cmax 00359 00360 } 00361 } else { 00362 00363 # reset the whole statistics 00364 $table clear tags 00365 $table delete rows -holddimensions 1 [$table cget -rows] 00366 set _rankingOf "" 00367 _getActiveWork 00368 } 00369 00370 # reset the table 00371 $table setCell \ 00372 0,0 "experiment" \ 00373 0,1 "ranking" \ 00374 0,2 "struct.recall" \ 00375 0,3 "label.recall" \ 00376 0,4 "lex.recall" \ 00377 0,5 "time" \ 00378 0,6 "sol.time" \ 00379 0,7 "soft time" \ 00380 00381 $table tag config title -font {-adobe-helvetica-medium-r-normal--12-*-*-*-*-*-*-*} 00382 $table tag config number -anchor e 00383 $table tag config sel -fg "" -bg "" -relief raised -bd 1 00384 $table tag config active -anchor w -fg black -bg gray -relief sunk -bd 1 00385 $table tag config colored -bg gray80 00386 $table tag config runner -fg red3 -bg #a3a3a3 00387 $table tag raise runner title 00388 $table tag col number 1 2 3 4 5 6 00389 $table width 0 45 1 10 2 9 3 9 4 9 5 25 6 25 7 25 00390 00391 .main printStatus "" 00392 _computeStatistics 00393 setModified 00394 } 00395 00396 ## ---------------------------------------------------------------------------- 00397 ## init 00398 ## ---------------------------------------------------------------------------- 00399 body YadaRanking::init {} { 00400 if {$_isInitialized} { 00401 return 00402 } 00403 chain 00404 clear 00405 _selectRanking {$lexicalRecall / (0.7 * log($time) + 0.2 * log($soltime) + 0.01 * log($softtime))} 00406 _selectFilter {*} 00407 00408 $itk_component(sortIncMenu) delete 0 end 00409 $itk_component(sortDecMenu) delete 0 end 00410 00411 set cmax [$itk_component(table) cget -cols] 00412 set headings [$itk_component(table) getCell 0,0 0,$cmax] 00413 set colNo 0 00414 foreach heading $headings { 00415 if {$heading != ""} { 00416 $itk_component(sortIncMenu) add command \ 00417 -label "$heading" \ 00418 -command [code $this sortRows $colNo -increasing] 00419 $itk_component(sortDecMenu) add command \ 00420 -label "$heading" \ 00421 -command [code $this sortRows $colNo -decreasing] 00422 } 00423 incr colNo 00424 } 00425 } 00426 00427 ## ---------------------------------------------------------------------------- 00428 ## activationHandle 00429 ## ---------------------------------------------------------------------------- 00430 body YadaRanking::activationHandle {} { 00431 chain 00432 00433 # get the previous selection 00434 set box $itk_component(grammarBox) 00435 set grammarName [$box get] 00436 00437 # default grammar to choose 00438 if {$grammarName == ""} { 00439 set grammarName "<none>" 00440 } 00441 00442 $box clear list 00443 eval $box insert list end [.main getGrammarNames] 00444 _selectGrammar $grammarName 00445 } 00446 00447 ## ---------------------------------------------------------------------------- 00448 ## _selectGrammar 00449 ## ---------------------------------------------------------------------------- 00450 body YadaRanking::_selectGrammar {{grammarName ""}} { 00451 set box $itk_component(grammarBox) 00452 if {$grammarName == ""} { 00453 set grammarName [$box get] 00454 if {$grammarName == ""} { 00455 set grammarName "<none>" 00456 } 00457 } 00458 00459 $box clear entry 00460 $box insert entry 0 $grammarName 00461 set listOfEntries [[$box component list] get 0 end] 00462 set index [lsearch $listOfEntries $grammarName] 00463 00464 if {$index < 0} { 00465 _selectGrammar "<none>" 00466 } else { 00467 $box selection set $index $index 00468 } 00469 00470 resortRows 00471 displayTitle 00472 } 00473 00474 ## ---------------------------------------------------------------------------- 00475 ## reload 00476 ## ---------------------------------------------------------------------------- 00477 body YadaRanking::reload {} { 00478 clear 00479 setModified 00480 _reloadFromRunner 00481 } 00482 00483 00484 ## ---------------------------------------------------------------------------- 00485 ## _getActiveWork 00486 ## ---------------------------------------------------------------------------- 00487 body YadaRanking::_getActiveWork {} { 00488 00489 # get the active set of experiments 00490 set experimentNames [_getSelectedWork] 00491 if {$experimentNames == ""} { 00492 set experimentNames [_getUndoneWork] 00493 if {$experimentNames == ""} { 00494 set experimentNames [_getWork] 00495 set doneWork [_getDoneWork] 00496 if {$experimentNames == $doneWork} { 00497 return "" 00498 } 00499 00500 # FIXME: do we want to set the table here? dirty! 00501 set rmax [llength $experimentNames] 00502 set _totalExperiments $rmax 00503 set table $itk_component(table) 00504 if {$rmax < 20} { 00505 set rmax 20 00506 } else { 00507 incr rmax 00508 } 00509 $table configure -rows $rmax 00510 set row 1 00511 foreach experimentName $experimentNames { 00512 $table setCell $row,0 $experimentName 00513 incr row 00514 } 00515 } 00516 } 00517 00518 00519 return $experimentNames 00520 } 00521 00522 ## ---------------------------------------------------------------------------- 00523 ## _getSelectedWork 00524 ## ---------------------------------------------------------------------------- 00525 body YadaRanking::_getSelectedWork {} { 00526 set table $itk_component(table) 00527 00528 set cells [$table curselection] 00529 00530 foreach index $cells { 00531 scan $index "%d,%d" row col 00532 set experimentName [$table getCell $row,0] 00533 if {$experimentName != ""} { 00534 set id($row,0) $experimentName 00535 } 00536 } 00537 00538 set experimentNames "" 00539 foreach index [array names id] { 00540 lappend experimentNames $id($index) 00541 } 00542 00543 00544 return [lsort -dictionary $experimentNames] 00545 } 00546 00547 ## ---------------------------------------------------------------------------- 00548 ## _getDoneWork 00549 ## ---------------------------------------------------------------------------- 00550 body YadaRanking::_getDoneWork {} { 00551 00552 set table $itk_component(table) 00553 set rmax [$table cget -rows] 00554 00555 set result "" 00556 foreach {experimentName ranking} [$table getCell 1,0 $rmax,1] { 00557 if {$experimentName != "" && $ranking != ""} { 00558 lappend result $experimentName 00559 } 00560 } 00561 00562 return $result 00563 } 00564 00565 ## ---------------------------------------------------------------------------- 00566 ## _getUndoneWork 00567 ## ---------------------------------------------------------------------------- 00568 body YadaRanking::_getUndoneWork {} { 00569 00570 set table $itk_component(table) 00571 set rmax [$table cget -rows] 00572 set experimentNames "" 00573 foreach {experimentName ranking} [$table getCell 1,0 $rmax,1] { 00574 if {$experimentName != "" && $ranking == ""} { 00575 lappend experimentNames $experimentName 00576 } 00577 } 00578 00579 return $experimentNames 00580 } 00581 00582 ## ---------------------------------------------------------------------------- 00583 ## _getWork 00584 ## ---------------------------------------------------------------------------- 00585 body YadaRanking::_getWork {} { 00586 00587 set grammarName [$itk_component(grammarBox) get] 00588 00589 # get all experiments using this grammar 00590 set experimentNames "" 00591 foreach experiment [.main getExperiments] { 00592 set experimentName [$experiment cget -name] 00593 if {$experimentName == "<none>" || 00594 ![regexp $grammarName [$experiment cget -grammarName]]} { 00595 continue 00596 } 00597 00598 set found 0 00599 foreach filter $_experimentFilters { 00600 if {[string match $filter $experimentName]} { 00601 set found 1 00602 break 00603 } 00604 } 00605 00606 if {!$found} { 00607 continue 00608 } 00609 00610 if {![$experiment cget -isComplete]} { 00611 .main printStatus "... checking experiment $experimentName" 00612 $experiment check 00613 } 00614 00615 if {![$experiment cget -isComplete]} { 00616 continue 00617 } 00618 00619 lappend experimentNames $experimentName 00620 } 00621 00622 return $experimentNames 00623 } 00624 00625 00626 ## ---------------------------------------------------------------------------- 00627 ## _breakButtonAction 00628 ## ---------------------------------------------------------------------------- 00629 body YadaRanking::_breakButtonAction {} { 00630 if {$_gotBreak} { 00631 unbreakProcess 00632 } else { 00633 breakProcess 00634 } 00635 } 00636 00637 ## ---------------------------------------------------------------------------- 00638 ## breakProcess 00639 ## ---------------------------------------------------------------------------- 00640 body YadaRanking::breakProcess {} { 00641 .main printStatus "INFO: break received" 00642 if {$_isRunning} { 00643 set _gotBreak 1 00644 $itk_component(toolbar) itemconfigure breakButton -background red3 00645 } 00646 } 00647 00648 ## ---------------------------------------------------------------------------- 00649 ## unbreakProcess 00650 ## ---------------------------------------------------------------------------- 00651 body YadaRanking::unbreakProcess {} { 00652 set _gotBreak 0 00653 $itk_component(toolbar) itemconfigure breakButton -background gray90 00654 } 00655 00656 ## ---------------------------------------------------------------------------- 00657 ## _leaveTableCommand 00658 ## ---------------------------------------------------------------------------- 00659 body YadaRanking::_leaveTableCommand {} { 00660 set table $itk_component(table) 00661 set lastActiveCell [$table tag cell active] 00662 if {$lastActiveCell == ""} { 00663 return 00664 } 00665 00666 scan $lastActiveCell "%d,%d" row col 00667 $table activate -1,-1 00668 } 00669 00670 ## ---------------------------------------------------------------------------- 00671 ## _escapeCommand 00672 ## ---------------------------------------------------------------------------- 00673 body YadaRanking::_escapeCommand {} { 00674 set table $itk_component(table) 00675 set lastActiveCell [$table tag cell active] 00676 scan $lastActiveCell "%d,%d" row col 00677 00678 if {$col == 0} { 00679 $table selection clear all 00680 } else { 00681 $table activate -1,-1 00682 } 00683 } 00684 00685 ## ---------------------------------------------------------------------------- 00686 ## interruptProcess 00687 ## ---------------------------------------------------------------------------- 00688 body YadaRanking::interruptProcess {} { 00689 breakProcess 00690 } 00691 00692 ## ---------------------------------------------------------------------------- 00693 ## _analyseDocument 00694 ## ---------------------------------------------------------------------------- 00695 body YadaRanking::_analyseDocument {document experiment wordgraph} { 00696 00697 # default values 00698 set lexicalHits 0 00699 set structHits 0 00700 set labelledHits 0 00701 set tries 0 00702 set score 0.0 00703 set totalTime 0 00704 set solutionTime 0 00705 set softTime 0 00706 set isOk 1 00707 00708 # get the cdgp logfile root element 00709 set cdgpNode [$document getElement "cdgp"] 00710 if {$cdgpNode == ""} { 00711 printMessage "ERROR: no cdgp logfile" error 00712 set isOk 0 00713 } else { 00714 # get the parse verification node 00715 set parseVerificationNode [$cdgpNode descendant 1 "parseverification"] 00716 if {$parseVerificationNode != ""} { 00717 foreach aspect {tries structHits labelledHits lexicalHits } { 00718 set $aspect [$parseVerificationNode selectNodes \ 00719 descendant::[string tolower $aspect]/number\[@name="SYN"\]/@value] 00720 00721 ## substitute key value pair with value 00722 regexp -expanded {^\{value[[:blank:]]+([^\}]+)} [subst \$$aspect] match $aspect 00723 00724 00725 #puts "tries: $tries" 00726 #puts "structHits: $structHits" 00727 #puts "labelledHits: $labelledHits" 00728 #puts "lexicalHits: $lexicalHits" 00729 } 00730 00731 # parse the statistics 00732 foreach aspect {score totalTime solutionTime softTime} { 00733 set $aspect [$cdgpNode selectNodes \ 00734 descendant::statistics/number\[@name="$aspect"\]/@value ] 00735 if {[subst \$$aspect] == ""} { 00736 set $aspect 0.0 00737 } 00738 00739 ## substitute key value pair with value 00740 regexp -expanded {^\{value[[:blank:]]+([^\}]+)} [subst \$$aspect] match $aspect 00741 } 00742 } else { 00743 set isOk 0 00744 } 00745 } 00746 # end of analysis 00747 00748 00749 00750 # verification fallback: compute tries from annotation 00751 if {!$isOk} { 00752 .main printStatus "ERROR: error in logfile of $wordgraph, consulting annotation" 00753 set grammar [.main getGrammarOfExperiment [$experiment cget -name]] 00754 $grammar scan; # CAUTION: might be costy 00755 set yadaWordgraph [$grammar getWordgraph $wordgraph] 00756 set tries [$yadaWordgraph cget -noAnnoEdges] 00757 if {$tries == 0} { 00758 .main printStatus "ERROR: no correct annotation for wordgraph '$wordgraph'" 00759 } 00760 } 00761 00762 # fix solution and soft time in case of no score 00763 if {$solutionTime == 0} { 00764 set solutionTime $totalTime 00765 } 00766 if {$softTime == 0} { 00767 set softTime $solutionTime 00768 } 00769 00770 # add the collected data to the experiment 00771 set sumScore [expr [$experiment cget -totalScore] + $score] 00772 set sumLabelledHits [expr [$experiment cget -labelledHits] + $labelledHits] 00773 set sumStructHits [expr [$experiment cget -structHits] + $structHits] 00774 set sumLexicalHits [expr [$experiment cget -lexicalHits] + $lexicalHits] 00775 set sumTime [expr [$experiment cget -totalTime] + $totalTime] 00776 set sumSolTime [expr [$experiment cget -totalSolTime] + $solutionTime] 00777 set sumSoftTime [expr [$experiment cget -totalSoftTime] + $softTime] 00778 set sumTries [expr [$experiment cget -totalTries] + $tries] 00779 00780 $experiment configure \ 00781 -totalScore $sumScore \ 00782 -totalTries $sumTries \ 00783 -totalTime $sumTime \ 00784 -totalSolTime $sumSolTime \ 00785 -totalSoftTime $sumSoftTime \ 00786 -structHits $sumStructHits \ 00787 -labelledHits $sumLabelledHits \ 00788 -lexicalHits $sumLexicalHits \ 00789 -totalTries $sumTries 00790 00791 return $isOk 00792 } 00793 00794 ## ---------------------------------------------------------------------------- 00795 ## _insertData 00796 ## ---------------------------------------------------------------------------- 00797 body YadaRanking::_insertData {experiment} { 00798 set score [expr double([$experiment cget -totalScore])] 00799 set lexicalHits [$experiment cget -lexicalHits] 00800 set labelledHits [$experiment cget -labelledHits] 00801 set structHits [$experiment cget -structHits] 00802 set tries [$experiment cget -totalTries] 00803 set lexicalRecall [expr $lexicalHits * 100.0 / $tries] 00804 set labelledRecall [expr $labelledHits * 100.0 / $tries] 00805 set structRecall [expr $structHits * 100.0 / $tries ] 00806 set time [expr double([$experiment cget -totalTime])] 00807 set soltime [expr double([$experiment cget -totalSolTime])] 00808 set softtime [expr double([$experiment cget -totalSoftTime])] 00809 set experimentName [$experiment cget -name] 00810 set ranking [expr $_rankingFormula] 00811 _setRankingOfExperiment $experimentName $ranking 00812 00813 # clear it 00814 set table $itk_component(table) 00815 set cmax [$table cget -cols] 00816 set row [_getRowOfExperimentName $experimentName] 00817 $table erase $row,1 $row,$cmax 00818 00819 # fill it 00820 $table setCell \ 00821 $row,1 [format "%4.3g" $ranking] \ 00822 $row,2 [format "%.2f" $structRecall] \ 00823 $row,3 [format "%.2f" $labelledRecall] \ 00824 $row,4 [format "%.2f" $lexicalRecall] \ 00825 $row,5 [timeToString $time] \ 00826 $row,6 [timeToString $soltime] \ 00827 $row,7 [timeToString $softtime] 00828 00829 # $row,4 [expr int($time)] \ 00830 # $row,5 [expr int($soltime)] \ 00831 # $row,6 [expr int($softtime)] 00832 00833 # show it 00834 if {$_followDataFlag} { 00835 $table see $row,1 00836 } 00837 00838 } 00839 00840 ## ---------------------------------------------------------------------------- 00841 ## _getRowOfExperimentName 00842 ## ---------------------------------------------------------------------------- 00843 body YadaRanking::_getRowOfExperimentName {experimentName} { 00844 00845 set table $itk_component(table) 00846 set rmax [$itk_component(table) cget -rows] 00847 set experimentNames [$itk_component(table) getCell 0,0 $rmax,0] 00848 set row [lsearch -exact $experimentNames $experimentName] 00849 00850 return $row 00851 } 00852 00853 ## ---------------------------------------------------------------------------- 00854 ## _returnCommand 00855 ## ---------------------------------------------------------------------------- 00856 body YadaRanking::_returnCommand {} { 00857 set table $itk_component(table) 00858 set lastActiveCell [$table tag cell active] 00859 scan $lastActiveCell "%d,%d" row col 00860 set colMax [expr [$table cget -cols] -1] 00861 if {$col == $colMax} { 00862 incr row 00863 set col 1 00864 } else { 00865 incr col 00866 } 00867 00868 $table activate $row,$col 00869 $table see $row,$col 00870 } 00871 00872 ## ---------------------------------------------------------------------------- 00873 ## sortRows 00874 ## ---------------------------------------------------------------------------- 00875 body YadaRanking::sortRows {colNo args} { 00876 set type $_typeOfColumn($colNo) 00877 eval $itk_component(table) sortRows $colNo -$type $args 00878 $itk_component(table) see 1,1 00879 set _lastSorting $colNo 00880 eval lappend _lastSorting $args 00881 } 00882 00883 ## ---------------------------------------------------------------------------- 00884 ## _selectRankingCommand 00885 ## ---------------------------------------------------------------------------- 00886 body YadaRanking::_selectRankingCommand {} { 00887 _selectRanking 00888 reload 00889 resortRows 00890 } 00891 00892 ## ---------------------------------------------------------------------------- 00893 ## _selectRanking 00894 ## ---------------------------------------------------------------------------- 00895 body YadaRanking::_selectRanking {{formula ""}} { 00896 00897 set box $itk_component(sortingBox) 00898 00899 if {$formula == ""} { 00900 set _rankingFormula [$box get] 00901 } else { 00902 set _rankingFormula $formula 00903 } 00904 00905 set entries [[$box component list] get 0 end] 00906 set index [lsearch $entries $_rankingFormula] 00907 if {$index < 0} { 00908 $box insert list 0 $_rankingFormula 00909 } 00910 $box delete entry 0 end 00911 $box insert entry 0 $_rankingFormula 00912 } 00913 00914 ## ---------------------------------------------------------------------------- 00915 ## _selectFilterCommand 00916 ## ---------------------------------------------------------------------------- 00917 body YadaRanking::_selectFilterCommand {} { 00918 _selectFilter 00919 clear 00920 } 00921 00922 ## ---------------------------------------------------------------------------- 00923 ## _selectFilter 00924 ## ---------------------------------------------------------------------------- 00925 body YadaRanking::_selectFilter {{filters ""}} { 00926 00927 set box $itk_component(experimentFilterBox) 00928 00929 if {$filters == ""} { 00930 set _experimentFilters [$box get] 00931 } else { 00932 set _experimentFilters $filters 00933 } 00934 00935 set entries [[$box component list] get 0 end] 00936 set index [lsearch $entries $_experimentFilters] 00937 if {$index < 0} { 00938 $box insert list 0 $_experimentFilters 00939 } 00940 $box delete entry 0 end 00941 $box insert entry 0 $_experimentFilters 00942 } 00943 00944 ## ---------------------------------------------------------------------------- 00945 ## isFollowData 00946 ## ---------------------------------------------------------------------------- 00947 body YadaRanking::isFollowData {} { 00948 return $_followDataFlag 00949 } 00950 00951 ## ---------------------------------------------------------------------------- 00952 ## toggleFollowData 00953 ## ---------------------------------------------------------------------------- 00954 body YadaRanking::toggleFollowData {} { 00955 if {$_followDataFlag == 1} { 00956 set _followDataFlag 0 00957 } else { 00958 set _followDataFlag 1 00959 } 00960 00961 return $_followDataFlag 00962 } 00963 00964 ## ---------------------------------------------------------------------------- 00965 ## _normalizeRankings 00966 ## ---------------------------------------------------------------------------- 00967 body YadaRanking::_normalizeRankings {} { 00968 .main printStatus "... normalizing rankings" 00969 00970 set sortedRanking [join [lsort -index 1 -decreasing -real $_rankingOf]] 00971 set table $itk_component(table) 00972 set rmax [$itk_component(table) cget -rows] 00973 set experimentNames [$itk_component(table) getCell 0,0 $rmax,0] 00974 00975 set normalizedRanking 0 00976 set lastRanking "" 00977 foreach {experimentName ranking} $sortedRanking { 00978 if {$ranking != $lastRanking} { 00979 incr normalizedRanking 00980 } 00981 00982 set row [lsearch -exact $experimentNames $experimentName] 00983 $table setCell $row,1 $normalizedRanking 00984 set lastRanking $ranking 00985 } 00986 00987 .main printStatus "" 00988 } 00989 00990 ## ---------------------------------------------------------------------------- 00991 ## _getRankingOfExperiment 00992 ## ---------------------------------------------------------------------------- 00993 body YadaRanking::_getRankingOfExperiment {experimentName} { 00994 foreach {lname ranking} $_rankingOf { 00995 if {$lname == $experimentName} { 00996 return $ranking 00997 } 00998 } 00999 } 01000 01001 ## ---------------------------------------------------------------------------- 01002 ## _setRankingOfExperiment 01003 ## ---------------------------------------------------------------------------- 01004 body YadaRanking::_setRankingOfExperiment {experimentName ranking} { 01005 _unsetRankingOfExperiment $experimentName 01006 lappend _rankingOf [list $experimentName $ranking] 01007 } 01008 01009 ## ---------------------------------------------------------------------------- 01010 ## _unsetRankingOfExperiment 01011 ## ---------------------------------------------------------------------------- 01012 body YadaRanking::_unsetRankingOfExperiment {experimentName} { 01013 set index 0 01014 foreach rank $_rankingOf { 01015 foreach {lname ranking} $rank { 01016 if {$lname == $experimentName} { 01017 set _rankingOf [lreplace $_rankingOf $index $index] 01018 } 01019 incr index 01020 } 01021 } 01022 01023 return 01024 } 01025 01026 ## ---------------------------------------------------------------------------- 01027 ## resortRows 01028 ## ---------------------------------------------------------------------------- 01029 body YadaRanking::resortRows {} { 01030 .main printStatus "... resorting rows" 01031 if {$_lastSorting != ""} { 01032 eval sortRows $_lastSorting 01033 } 01034 .main printStatus "" 01035 } 01036 01037 ## ---------------------------------------------------------------------------- 01038 ## _rowTagCommand 01039 ## ---------------------------------------------------------------------------- 01040 body YadaRanking::_rowTagCommand {row} { 01041 if {[expr $row % 2]} { 01042 return "colored" 01043 } else { 01044 return "default" 01045 } 01046 } 01047 01048 ## ---------------------------------------------------------------------------- 01049 ## _computeStatistics 01050 ## ---------------------------------------------------------------------------- 01051 body YadaRanking::_computeStatistics {} { 01052 .main printStatus "... computing statistics" 01053 set table $itk_component(table) 01054 set rmax [$table cget -rows] 01055 01056 set _totalTime 0 01057 01058 foreach experimentName [$table getCell 1,0 $rmax,0] { 01059 if {$experimentName == ""} { 01060 continue 01061 } 01062 set experiment [.main getExperiment $experimentName] 01063 set _totalTime [expr $_totalTime + [$experiment cget -totalTime]] 01064 } 01065 01066 .main printStatus "" 01067 _showStatistics 01068 } 01069 01070 ## ---------------------------------------------------------------------------- 01071 ## _showStatistics 01072 ## ---------------------------------------------------------------------------- 01073 body YadaRanking::_showStatistics {} { 01074 $itk_component(totalTime) configure -state normal 01075 $itk_component(totalTime) delete 0 end 01076 $itk_component(totalTime) insert 0 "[timeToString $_totalTime]" 01077 $itk_component(totalTime) configure -state disabled 01078 } 01079 01080 01081 ## ---------------------------------------------------------------------------- 01082 ## Serializes Object into a DOM-XML-Node 01083 ## @return root DOM node representing the Ranking-Document (root tag <yada>) 01084 ## ---------------------------------------------------------------------------- 01085 body YadaRanking::toDOM {} { 01086 set document [dom createDocument "yada"] 01087 set root [$document documentElement] 01088 01089 set nodeRanking [$document createElement "ranking"] 01090 set grammarName [_getCurrentGrammar] 01091 $nodeRanking setAttribute "name" $grammarName 01092 $nodeRanking setAttribute "totalTime" $_totalTime 01093 01094 01095 ## Add Filter Element 01096 set nodeFilter [$document createElement "filter"] 01097 set nodeFilterText [$document createTextNode $_experimentFilters] 01098 $nodeFilter appendChild $nodeFilterText 01099 $nodeRanking appendChild $nodeFilter 01100 01101 01102 ## Add Ranking Formula Element 01103 set nodeRankingFormula [$document createElement "rankingFormula"] 01104 set nodeRankingFormulaText [$document createTextNode $_rankingFormula] 01105 $nodeRankingFormula appendChild $nodeRankingFormulaText 01106 $nodeRanking appendChild $nodeRankingFormula 01107 01108 set table $itk_component(table) 01109 01110 01111 ## read data from table row by row 01112 for {set row 1} { [$table getCell $row,0] != "" } {incr row} { 01113 set nodeExperiment [$document createElement "experiment"] 01114 set experimentName [$table getCell $row,0] 01115 01116 set experiment [.main getExperiment $experimentName] 01117 01118 set rank [$table getCell $row,1] 01119 set structRecall [$table getCell $row,2] 01120 set labelRecall [$table getCell $row,3] 01121 set lexRecall [$table getCell $row,4] 01122 set time [$table getCell $row,5] 01123 set solTime [$table getCell $row,6] 01124 set softTime [$table getCell $row,7] 01125 01126 $nodeExperiment setAttribute "name" [string trim $experimentName " "] 01127 $nodeExperiment setAttribute "rank" [string trim $rank " "] 01128 $nodeExperiment setAttribute "structRecall" [string trim $structRecall " "] 01129 $nodeExperiment setAttribute "labelRecall" [string trim $labelRecall " "] 01130 $nodeExperiment setAttribute "lexRecall" [string trim $lexRecall " "] 01131 01132 ## get time statistics from experiment 01133 $nodeExperiment setAttribute "time" [$experiment cget -totalTime] 01134 $nodeExperiment setAttribute "solTime" [$experiment cget -totalSolTime] 01135 $nodeExperiment setAttribute "softTime" [$experiment cget -totalSoftTime] 01136 01137 $nodeRanking appendChild $nodeExperiment 01138 } 01139 01140 $root appendChild $nodeRanking 01141 return $root 01142 01143 01144 } 01145 01146 01147 ## ---------------------------------------------------------------------------- 01148 ## Implements specific load functionality using following policy: 01149 ## Try to load each completed experiment in the selected grammar. 01150 ## 1. If there is no data in ranking.xml, load from runner. 01151 ## 01152 ## 2. If a runner has updated data, i.e. the runner.xml has modification 01153 ## time later than ranking.xml, load runner document. 01154 ## 01155 ## 3. If runner.xml has no updated data, ignore it. 01156 ## 01157 ## 4. If a runner has no runner.xml file, regenerate it by loading from 01158 ## the runner object and use that data for the ranking document. 01159 ## 01160 ## If a runner has been loaded and is in a modified state after that, save 01161 ## it. 01162 ## 01163 ## @param rootNode root DOM-Node (Tag <yada>) 01164 ## ---------------------------------------------------------------------------- 01165 body YadaRanking::fromDOM {rootNode} { 01166 set xpath "/yada/ranking" 01167 01168 set nodeRanking [$rootNode selectNodes $xpath] 01169 if { $nodeRanking != "" } { 01170 set _totalTime [$nodeRanking getAttribute "totalTime"] 01171 _selectGrammar [$nodeRanking getAttribute "name"] 01172 } else { 01173 set _totalTime 0 01174 _selectGrammar "" 01175 } 01176 01177 set nodeFilter [$rootNode selectNodes $xpath/filter] 01178 if { $nodeFilter != "" } { 01179 _selectFilter [$nodeFilter text] 01180 } else { 01181 _selectFilter "" 01182 } 01183 01184 set nodeRankingFormula [$rootNode selectNodes $xpath/rankingFormula] 01185 if { $nodeRankingFormula != "" } { 01186 _selectRanking [$nodeRankingFormula text] 01187 } else { 01188 _selectRanking "" 01189 } 01190 01191 01192 01193 set nodesExperiments [$rootNode selectNodes $xpath/experiment] 01194 set _totalExperiments [llength $nodesExperiments] 01195 01196 set table $itk_component(table) 01197 set rmax [$table cget -rows] 01198 set cmax [$table cget -cols] 01199 $table erase 1,1 $rmax,$cmax 01200 01201 set listExperimentsInDOM {} 01202 01203 ## get list of experiment names in XML document 01204 foreach nodeExperiment $nodesExperiments { 01205 set experimentName [$nodeExperiment getAttribute "name"] 01206 lappend listExperimentsInDOM $experimentName 01207 } 01208 01209 ## set whole set of experiments to evaluate 01210 set activeExperimentNames [_getActiveWork] 01211 01212 #puts "Active Experiments: $activeExperimentNames" 01213 01214 _getRunners runners $activeExperimentNames $listExperimentsInDOM 01215 01216 foreach experimentInDOM $listExperimentsInDOM { 01217 if { [lsearch -exact $activeExperimentNames $experimentInDOM] < 0 } { 01218 setModified 01219 #puts "** Experiment $experimentInDOM will not be loaded" 01220 break 01221 } 01222 } 01223 01224 foreach experimentName $activeExperimentNames { 01225 set row [_getRowOfExperimentName $experimentName] 01226 01227 if { $runners($experimentName) == "load" } { 01228 #puts "*** Loading Experiment $experimentName from runner ***" 01229 $_runner configure -selectedExperiment [.main getExperiment $experimentName] 01230 01231 catch {$_runner load} 01232 set structRecall [$_runner getTotalStructRecall] 01233 set labelRecall [$_runner getTotalLabelRecall] 01234 set lexicalRecall [$_runner getTotalLexRecall] 01235 set time [$_runner getTotalTime] 01236 set solTime [$_runner getTotalSolTime] 01237 set softTime [$_runner getTotalSoftTime] 01238 setModified 01239 01240 if { [$_runner isModified] } { 01241 #puts "* Runner $experimentName modified *" 01242 $_runner save 01243 } else { 01244 #puts "* Runner $experimentName not modified *" 01245 } 01246 01247 } else { 01248 set nodeExperiment [$rootNode find "name" $experimentName] 01249 #puts "*** Loading Experiment $experimentName from document ***" 01250 set structRecall [$nodeExperiment getAttribute "structRecall"] 01251 set labelRecall [$nodeExperiment getAttribute "labelRecall"] 01252 set lexicalRecall [$nodeExperiment getAttribute "lexRecall"] 01253 set time [$nodeExperiment getAttribute "time"] 01254 set solTime [$nodeExperiment getAttribute "solTime"] 01255 set softTime [$nodeExperiment getAttribute "softTime"] 01256 01257 } 01258 01259 ## set total time attribute of each experiment, so that method 01260 ## _computeStatistics may use that information 01261 set currentExperiment [.main getExperiment $experimentName] 01262 $currentExperiment configure -totalTime $time 01263 01264 $currentExperiment configure -totalSolTime $solTime 01265 $currentExperiment configure -totalSoftTime $softTime 01266 01267 set rank [expr $_rankingFormula] 01268 _setRankingOfExperiment $experimentName $rank 01269 01270 # fill it 01271 $table setCell \ 01272 $row,0 $experimentName\ 01273 $row,1 [format "%4.3g" $rank] \ 01274 $row,2 [format "%.2f" $structRecall] \ 01275 $row,3 [format "%.2f" $labelRecall] \ 01276 $row,4 [format "%.2f" $lexicalRecall] \ 01277 $row,5 [timeToString $time] \ 01278 $row,6 [timeToString $solTime] \ 01279 $row,7 [timeToString $softTime] 01280 } 01281 01282 _normalizeRankings 01283 resortRows 01284 01285 01286 if { [isModified] } { 01287 #puts "*** Statistics need to be recomputed ***" 01288 _computeStatistics 01289 } else { 01290 #puts "*** Show saved statistics ***" 01291 _showStatistics 01292 } 01293 } 01294 01295 ## ---------------------------------------------------------------------------- 01296 ## Update toolbar, menubar and titlebar 01297 ## ---------------------------------------------------------------------------- 01298 body YadaRanking::displayTitle {} { 01299 if { [info exists itk_component(grammarBox)] } { 01300 set box $itk_component(grammarBox) 01301 set grammarName [$box get] 01302 } else { 01303 set grammarName "<none>" 01304 } 01305 01306 if { $grammarName != "<none>" } { 01307 set title "$name-$grammarName" 01308 } else { 01309 set title "$name" 01310 } 01311 01312 if { [isModified] && $grammarName != "<none>" } { 01313 wm title . "$title *** changed *** " 01314 } else { 01315 wm title . "$title" 01316 } 01317 01318 set loadButton [$itk_component(toolbar) component loadButton] 01319 set saveButton [$itk_component(toolbar) component saveButton] 01320 01321 if { [hasSavedState] } { 01322 $itk_component(fileMenu) entryconfigure 0 -state normal 01323 $loadButton configure -state normal 01324 } else { 01325 $itk_component(fileMenu) entryconfigure 0 -state disabled 01326 $loadButton configure -state disabled 01327 } 01328 01329 if { [isModified] && [string compare $name "<none>"] != 0 } { 01330 $itk_component(fileMenu) entryconfigure 1 -state normal 01331 $saveButton configure -state normal 01332 } else { 01333 $itk_component(fileMenu) entryconfigure 1 -state disabled 01334 $saveButton configure -state disabled 01335 } 01336 } 01337 01338 01339 ## ---------------------------------------------------------------------------- 01340 ## Gets unique file name from YadaMain application object to save object state 01341 ## ---------------------------------------------------------------------------- 01342 body YadaRanking::getPersistanceFileName {} { 01343 if { [info exists itk_component(grammarBox)] } { 01344 set box $itk_component(grammarBox) 01345 set grammarName [$box get] 01346 } else { 01347 set grammarName "<none>" 01348 } 01349 01350 return [.main getPersistanceFileNameForRanking $name-$grammarName] 01351 01352 } 01353 01354 ## ---------------------------------------------------------------------------- 01355 ## Returns name of currently selected grammar or the empty string, 01356 ## if selection box not initialized yet 01357 ## ---------------------------------------------------------------------------- 01358 body YadaRanking::_getCurrentGrammar {} { 01359 if { [info exists itk_component(grammarBox)] } { 01360 return [$itk_component(grammarBox) get] 01361 } else { 01362 return "" 01363 } 01364 } 01365 01366 01367 ## ---------------------------------------------------------------------------- 01368 ## Loads experiments, that are selected but for which there is neither data in 01369 ## the document's XML file nor in any runner document, so the wordgraph XML 01370 ## files have to be (re)evaluated (this method is almost identical to the 01371 ## original load method) 01372 ## @param listOfExperimentNames if equal to "", whole active work will be 01373 ## reanalysed, otherwise only elements of list will be used instead 01374 ## ---------------------------------------------------------------------------- 01375 #body YadaRanking::_loadUpdatedExperiments {{listOfExperimentNames ""}} { 01376 # set _isRunning 1 01377 # set noLoadedFiles 0 01378 # set noExperiments 0 01379 # set errorFiles "" 01380 # set noErrors 0 01381 01382 # if { $listOfExperimentNames == "" } { 01383 # set experimentNamesToAnalyse [_getActiveWork] 01384 # } else { 01385 # set experimentNamesToAnalyse $listOfExperimentNames 01386 # } 01387 01388 01389 01390 # load all experiments 01391 # foreach experimentName $experimentNamesToAnalyse { 01392 01393 # set experiment [.main getExperiment $experimentName] 01394 # set grammar [.main getGrammar [$experiment cget -grammarName]] 01395 # .main printStatus "... loading experiment `$experimentName'" 01396 01397 # did we already collect the sums 01398 # if {![$experiment cget -isUpToDate]} { 01399 01400 # reset experiment statistics 01401 # $experiment resetStatistics 01402 01403 # load all wordgraphs 01404 # foreach wordgraph [$grammar getSelection] { 01405 01406 # check if the file is present 01407 # set file [$experiment getXmlFileName $wordgraph] 01408 # if {![file exists $file]} { 01409 # continue 01410 # } 01411 01412 # .main printStatus "... loading experiment `$experimentName', wordgraph `$wordgraph', $noErrors errors" 01413 # update 01414 01415 # analyse the file 01416 # set fd [open "|zcat $file" r] 01417 # set data [read $fd] 01418 # close $fd 01419 # set document [dom parse $data] 01420 # set isOk [_analyseDocument $document $experiment $wordgraph] 01421 # if {!$isOk} { 01422 # incr noErrors 01423 # lappend errorFiles $file 01424 # } 01425 01426 # $document delete 01427 # set document "" 01428 01429 # incr noLoadedFiles 01430 # } 01431 # $experiment configure -isUpToDate 1 01432 # } 01433 01434 # insert the data into the table 01435 # _insertData $experiment 01436 01437 # did we press the break button 01438 # if {$_gotBreak} { 01439 # unbreakProcess 01440 # .main printStatus "WARNING: interrupted loading after $noLoadedFiles files" 01441 # break 01442 # } 01443 01444 # incr noExperiments 01445 01446 # } 01447 01448 # if we had errors in some files the notify the user 01449 # if {[llength $errorFiles] > 0} { 01450 # set listDialog [ListDialog .#auto \ 01451 -title "Yada - Message" \ 01452 -labeltext "The following files had errors:" \ 01453 -modality application \ 01454 -height 480 \ 01455 -width 640 \ 01456 -master . 01457 # ] 01458 # eval $listDialog insert list 0 $errorFiles 01459 # $listDialog activate 01460 # itcl::delete object $listDialog 01461 # } 01462 01463 # we tried to load nothing ... 01464 # if {$noExperiments == 0} { 01465 # printMessage "No experiments found!" 01466 # } 01467 01468 # update the display 01469 # _normalizeRankings 01470 # resortRows 01471 # _computeStatistics 01472 # .main printStatus "INFO: loaded $noLoadedFiles files" 01473 # set _isRunning 0 01474 01475 #} 01476 01477 ## ---------------------------------------------------------------------------- 01478 ## Returns array with entries for all experiment names, that identify those 01479 ## runner instances, that have to be loaded 01480 ## 01481 ## @param runners output argument array; when method returns, array contains 01482 ## entry for each experiment name from the list of experiment names: 01483 ## $runners(<experimentName>) == "ignore" => runner has not been updated; 01484 ## $runners(<experimentName>) == "load" => runner has to be loaded (includes case, 01485 ## where runner has no corresponding runner.xml, so that this file has to be generated!) 01486 ## 01487 ## @param listExperimentNames experiment names to find corresponding runners 01488 ## 01489 ## @param listExperimentsInDocument experiments that are saved in the document's 01490 ## XML file 01491 ## ---------------------------------------------------------------------------- 01492 body YadaRanking::_getRunners {runners listExperimentNames listExperimentsInDocument} { 01493 upvar $runners resultRunners 01494 01495 01496 foreach experimentName $listExperimentNames { 01497 01498 $_runner configure -selectedExperiment [.main getExperiment $experimentName] 01499 01500 ## experiment is contained in ranking DOM node 01501 if { [lsearch -exact $listExperimentsInDocument $experimentName] >= 0 } { 01502 if { [$_runner hasSavedState] } { 01503 if { [$_runner lastChanged] <= [lastChanged] } { ## runner has no new data 01504 set resultRunners($experimentName) "ignore" 01505 } else { ## runner has potentially new data 01506 set resultRunners($experimentName) "load" 01507 } 01508 } else { 01509 set resultRunners($experimentName) "load" 01510 } 01511 01512 } else { ## use runner object anyway 01513 set resultRunners($experimentName) "load" 01514 } 01515 } 01516 } 01517 01518 ## ---------------------------------------------------------------------------- 01519 ## Reloads currently selected experiments from corresponding runner documents 01520 ## ---------------------------------------------------------------------------- 01521 body YadaRanking::_reloadFromRunner {} { 01522 set experimentNamesToAnalyse [_getActiveWork] 01523 set table $itk_component(table) 01524 01525 set oldCursors [setBusy] 01526 01527 # load all experiments 01528 foreach experimentName $experimentNamesToAnalyse { 01529 set experiment [.main getExperiment $experimentName] 01530 set row [_getRowOfExperimentName $experimentName] 01531 01532 #puts "*** Reloading Experiment $experimentName from runner ***" 01533 $_runner configure -selectedExperiment $experiment 01534 01535 catch {$_runner load} 01536 set structRecall [$_runner getTotalStructRecall] 01537 set labelRecall [$_runner getTotalLabelRecall] 01538 set lexicalRecall [$_runner getTotalLexRecall] 01539 set time [$_runner getTotalTime] 01540 set solTime [$_runner getTotalSolTime] 01541 set softTime [$_runner getTotalSoftTime] 01542 setModified 01543 01544 if { [$_runner isModified] } { 01545 $_runner save 01546 } 01547 01548 ## set total time attribute of each experiment, so that method 01549 ## _computeStatistics may use that information 01550 set currentExperiment [.main getExperiment $experimentName] 01551 $currentExperiment configure -totalTime $time 01552 01553 $currentExperiment configure -totalSolTime $solTime 01554 $currentExperiment configure -totalSoftTime $softTime 01555 01556 set rank [expr $_rankingFormula] 01557 _setRankingOfExperiment $experimentName $rank 01558 01559 # fill it 01560 $table setCell \ 01561 $row,0 $experimentName\ 01562 $row,1 [format "%4.3g" $rank] \ 01563 $row,2 [format "%.2f" $structRecall] \ 01564 $row,3 [format "%.2f" $labelRecall] \ 01565 $row,4 [format "%.2f" $lexicalRecall] \ 01566 $row,5 [timeToString $time] \ 01567 $row,6 [timeToString $solTime] \ 01568 $row,7 [timeToString $softTime] 01569 } 01570 01571 01572 01573 # update the display 01574 _normalizeRankings 01575 resortRows 01576 _computeStatistics 01577 01578 resetBusy $oldCursors 01579 } 01580

YADA 2.0-alpha (20 Oct 2004)