| 77 | } |
| 78 | |
| 79 | public static Pair<Integer,Integer> test(LangDescriptor language, |
| 80 | List<InputDocument> others, |
| 81 | InputDocument testDoc) |
| 82 | throws Exception |
| 83 | { |
| 84 | long train_start = System.nanoTime(); |
| 85 | Corpus corpus = new Corpus(others, language); |
| 86 | corpus.train(); |
| 87 | long train_stop = System.nanoTime(); |
| 88 | |
| 89 | long format_start = System.nanoTime(); |
| 90 | Formatter formatter = new Formatter(corpus, language.indentSize, Formatter.DEFAULT_K, |
| 91 | FEATURES_INJECT_WS, FEATURES_HPOS); |
| 92 | formatter.format(testDoc, false); |
| 93 | long format_stop = System.nanoTime(); |
| 94 | |
| 95 | long train_time = (train_stop-train_start)/1_000_000; |
| 96 | long format_time = (format_stop-format_start)/1_000_000; |
| 97 | |
| 98 | System.out.printf("%s training of %s = %dms formatting = %dms\n", |
| 99 | language.name, |
| 100 | testDoc.fileName, |
| 101 | train_time, |
| 102 | format_time); |
| 103 | |
| 104 | return new Pair<>((int)train_time, (int)format_time); |
| 105 | } |
| 106 | } |