package com.formulasearchengine.mathosphere.mlp.contracts;

import com.formulasearchengine.mathosphere.mlp.cli.FlinkMlpCommandConfig;
import com.formulasearchengine.mathosphere.mlp.pojos.ParsedWikiDocument;
import com.formulasearchengine.mathosphere.mlp.pojos.RawWikiDocument;

import org.junit.Test;

import java.util.List;

public class RussianWikiPipelineTest {

  @Test
  public void fullPipeline() throws Exception {
    String wikiRuFile = "com/formulasearchengine/mathosphere/mlp/wikirusample.xml";

    TextAnnotatorMapper textAnnotator = ruTextAnnotator();

    List<RawWikiDocument> docs = readDocs(wikiRuFile);

    for (RawWikiDocument doc : docs) {
      ParsedWikiDocument parsedDoc = textAnnotator.map(doc);
      System.out.println(parsedDoc);
    }
  }

  private List<RawWikiDocument> readDocs(String wikiRuFile) throws Exception {
    return TextAnnotatorMapperTest.readWikiTextDocuments(wikiRuFile);
  }

  private static TextAnnotatorMapper ruTextAnnotator() throws Exception {
    String[] params = {"--language", "ru", "-pos", ""};
    FlinkMlpCommandConfig config = FlinkMlpCommandConfig.from(params);

    TextAnnotatorMapper textAnnotator = new TextAnnotatorMapper(config);
    textAnnotator.open(null);
    return textAnnotator;
  }
}

@@ -270,17 +270,16 @@
 cument;%0A
-%0A
 import o
@@ -362,16 +362,422 @@
  %7B%0A%0A
+    private static TextAnnotatorMapper ruTextAnnotator() throws Exception %7B%0A        String%5B%5D params = %7B%22--language%22, %22ru%22, %22-pos%22, %22%22, %22-in%22, %22fake-input%22, %22-out%22, %22fake-output%22%7D;%0A        FlinkMlpCommandConfig config = FlinkMlpCommandConfig.from(params);%0A%0A        TextAnnotatorMapper textAnnotator = new TextAnnotatorMapper(config);%0A        textAnnotator.open(null);%0A        return textAnnotator;%0A    %7D%0A%0A  
   @Test%0A
   pu
@@ -772,16 +772,18 @@
   @Test%0A
+  
   public
@@ -814,32 +814,36 @@
 ows Exception %7B%0A
+    
     String wikiR
@@ -911,16 +911,20 @@
 .xml%22;%0A%0A
+    
     Text
@@ -971,24 +971,28 @@
 notator();%0A%0A
+    
     List%3CRaw
@@ -1031,24 +1031,28 @@
 kiRuFile);%0A%0A
+    
     for (Raw
@@ -1084,16 +1084,22 @@
 %7B%0A      
+    
+  
 ParsedWi
@@ -1141,24 +1141,30 @@
 r.map(doc);%0A
+      
       System
@@ -1192,19 +1192,27 @@
 c);%0A
+    
     %7D%0A
+  
   %7D%0A%0A
+  
   pr
@@ -1282,24 +1282,28 @@
 Exception %7B%0A
+    
     return T
@@ -1366,342 +1366,8 @@
 ;%0A  
-%7D%0A%0A  private static TextAnnotatorMapper ruTextAnnotator() throws Exception %7B%0A    String%5B%5D params = %7B%22--language%22, %22ru%22, %22-pos%22, %22%22%7D;%0A    FlinkMlpCommandConfig config = FlinkMlpCommandConfig.from(params);%0A%0A    TextAnnotatorMapper textAnnotator = new TextAnnotatorMapper(config);%0A    textAnnotator.open(null);%0A    return textAnnotator;%0A
   %7D%0A

Repair more broken cli tests