@@ -40,7 +40,8 @@ public Demo(StatAlign<Translation> aligner) {
40
40
stat = aligner ;
41
41
splitter = new GermanEnglishSplitter (stat .getWordParser ());
42
42
43
- commands .addAll (List (new Exit (), new Help (), new Corpus (), new Show (), new Break (), new Details ()));
43
+ commands .addAll (List (new Exit (), new Help (), new Corpus (),
44
+ new Show (), new Break (), new Details (), new Align ()));
44
45
45
46
try {
46
47
out = new PrintStream (System .out , true , "UTF8" );
@@ -93,7 +94,7 @@ public void run(String[] args) {
93
94
94
95
public void showCommands () {
95
96
out .println ("+-----------------------------------------------------------------------------+" );
96
- out .println ("| line-up ==== Commands ===== 09 .08.2013 |" );
97
+ out .println ("| line-up ==== Commands ===== 23 .08.2013 |" );
97
98
out .println ("+-----------------------------------------------------------------------------+" );
98
99
out .println ("| |" );
99
100
out .println ("| help - all this |" );
@@ -412,4 +413,36 @@ public void perform(String input) {
412
413
showCommands ();
413
414
}
414
415
}
416
+
417
+ class Align implements Command {
418
+ public boolean respondTo (String input ) {
419
+ return input .startsWith ("align" );
420
+ }
421
+
422
+ public void perform (String input ) {
423
+ if (input .equals ("align" )) { // reset
424
+ int index = random .nextInt (stat .getCorpus ().size ());
425
+ System .out .println (index );
426
+ System .out .println ();
427
+ NtoNTranslation translation = stat .getCorpus ().get (index );
428
+ List <PossibleTranslations > pts = ptsCache = stat .associate (translation );
429
+ Tuple <Sentences , Sentences > sent = Sentences .wire (
430
+ translation , pts , getMaxTranslationDistance (), stat .getWordParser ());
431
+
432
+ System .out .println (mkString (translation .getSourceSentences (), " " ));
433
+ System .out .println ();
434
+ System .out .println (mkString (translation .getTargetSentences (), " " ));
435
+ System .out .println ();
436
+
437
+ for (Word word : sent ._1 .getWords ()) {
438
+ System .out .print (word .getIndex () + "-" + word .getValue () + " " );
439
+ }
440
+ System .out .println (); System .out .println ();
441
+ for (Word word : sent ._2 .getWords ()) {
442
+ System .out .print (word .getIndex () + "-" + word .getValue () + " " );
443
+ }
444
+ System .out .println ();
445
+ }
446
+ }
447
+ }
415
448
}
0 commit comments