use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.coloring.ColoringServiceImpl in project webanno by webanno.
the class BratRendererTest method thatSentenceOrientedStrategyRenderCorrectly.
@Test
public void thatSentenceOrientedStrategyRenderCorrectly() throws Exception {
String jsonFilePath = "target/test-output/output-sentence-oriented.json";
String file = "src/test/resources/tcf04-karin-wl.xml";
CAS cas = JCasFactory.createJCas().getCas();
CollectionReader reader = createReader(TcfReader.class, TcfReader.PARAM_SOURCE_LOCATION, file);
reader.getNext(cas);
AnnotatorState state = new AnnotatorStateImpl(Mode.ANNOTATION);
state.setAllAnnotationLayers(schemaService.listAnnotationLayer(project));
state.setPagingStrategy(new SentenceOrientedPagingStrategy());
state.getPreferences().setWindowSize(10);
state.setFirstVisibleUnit(WebAnnoCasUtil.getFirstSentence(cas));
state.setProject(project);
VDocument vdoc = new VDocument();
preRenderer.render(vdoc, state.getWindowBeginOffset(), state.getWindowEndOffset(), cas, schemaService.listAnnotationLayer(project));
GetDocumentResponse response = new GetDocumentResponse();
BratRenderer renderer = new BratRenderer(schemaService, new ColoringServiceImpl(schemaService));
renderer.render(response, state, vdoc, cas);
JSONUtil.generatePrettyJson(response, new File(jsonFilePath));
assertThat(contentOf(new File("src/test/resources/output-sentence-oriented.json"), UTF_8)).isEqualToNormalizingNewlines(contentOf(new File(jsonFilePath), UTF_8));
}
use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.coloring.ColoringServiceImpl in project webanno by webanno.
the class BratRendererTest method thatLineOrientedStrategyRenderCorrectly.
/**
* generate brat JSON data for the document
*/
@Test
public void thatLineOrientedStrategyRenderCorrectly() throws Exception {
String jsonFilePath = "target/test-output/multiline.json";
String file = "src/test/resources/multiline.txt";
CAS cas = JCasFactory.createJCas().getCas();
CollectionReader reader = createReader(TextReader.class, TextReader.PARAM_SOURCE_LOCATION, file);
reader.getNext(cas);
AnalysisEngine segmenter = createEngine(BreakIteratorSegmenter.class);
segmenter.process(cas);
AnnotatorState state = new AnnotatorStateImpl(Mode.ANNOTATION);
state.setPagingStrategy(new LineOrientedPagingStrategy());
state.getPreferences().setWindowSize(10);
state.setFirstVisibleUnit(WebAnnoCasUtil.getFirstSentence(cas));
state.setProject(project);
VDocument vdoc = new VDocument();
preRenderer.render(vdoc, state.getWindowBeginOffset(), state.getWindowEndOffset(), cas, schemaService.listAnnotationLayer(project));
GetDocumentResponse response = new GetDocumentResponse();
BratRenderer renderer = new BratRenderer(schemaService, new ColoringServiceImpl(schemaService));
renderer.render(response, state, vdoc, cas);
JSONUtil.generatePrettyJson(response, new File(jsonFilePath));
assertThat(contentOf(new File("src/test/resources/multiline.json"), UTF_8)).isEqualToNormalizingNewlines(contentOf(new File(jsonFilePath), UTF_8));
}
Aggregations