use of de.tudarmstadt.ukp.clarin.webanno.brat.message.GetCollectionInformationResponse in project webanno by webanno.
the class CasToBratJsonTest method testGenerateBratJsonGetCollection.
/**
* generate BRAT JSON for the collection informations
*
* @throws IOException
* if an I/O error occurs.
*/
@Test
public void testGenerateBratJsonGetCollection() throws IOException {
MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter();
String jsonFilePath = "target/test-output/output_cas_to_json_collection.json";
GetCollectionInformationResponse collectionInformation = new GetCollectionInformationResponse();
List<AnnotationLayer> layerList = new ArrayList<>();
AnnotationLayer layer = new AnnotationLayer();
layer.setId(1l);
layer.setDescription("span annoattion");
layer.setName("pos");
layer.setType(WebAnnoConst.SPAN_TYPE);
TagSet tagset = new TagSet();
tagset.setId(1l);
tagset.setDescription("pos");
tagset.setLanguage("de");
tagset.setName("STTS");
Tag tag = new Tag();
tag.setId(1l);
tag.setDescription("noun");
tag.setName("NN");
tag.setTagSet(tagset);
layerList.add(layer);
collectionInformation.addCollection("/Collection1/");
collectionInformation.addCollection("/Collection2/");
collectionInformation.addCollection("/Collection3/");
collectionInformation.addDocument("/Collection1/doc1");
collectionInformation.addDocument("/Collection2/doc1");
collectionInformation.addDocument("/Collection3/doc1");
collectionInformation.addDocument("/Collection1/doc2");
collectionInformation.addDocument("/Collection2/doc2");
collectionInformation.addDocument("/Collection3/doc2");
collectionInformation.setSearchConfig(new ArrayList<>());
List<String> tagSetNames = new ArrayList<>();
tagSetNames.add(de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.POS);
tagSetNames.add(de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.DEPENDENCY);
tagSetNames.add(de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.NAMEDENTITY);
tagSetNames.add(de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.COREFERENCE);
tagSetNames.add(de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.COREFRELTYPE);
JSONUtil.generatePrettyJson(jsonConverter, collectionInformation, new File(jsonFilePath));
assertThat(linesOf(new File("src/test/resources/output_cas_to_json_collection_expected.json"), "UTF-8")).isEqualTo(linesOf(new File(jsonFilePath), "UTF-8"));
}
use of de.tudarmstadt.ukp.clarin.webanno.brat.message.GetCollectionInformationResponse in project webanno by webanno.
the class SuggestionViewPanel method getCollectionInformation.
private String getCollectionInformation(AnnotationSchemaService aAnnotationService, CurationContainer aCurationContainer) throws IOException {
GetCollectionInformationResponse info = new GetCollectionInformationResponse();
info.setEntityTypes(BratRenderer.buildEntityTypes(aCurationContainer.getAnnotatorState().getAnnotationLayers(), aAnnotationService));
return JSONUtil.toInterpretableJsonString(info);
}
use of de.tudarmstadt.ukp.clarin.webanno.brat.message.GetCollectionInformationResponse in project webanno by webanno.
the class BratAnnotationEditor method bratLoadCollectionCommand.
private String bratLoadCollectionCommand() {
GetCollectionInformationResponse response = new GetCollectionInformationResponse();
response.setEntityTypes(BratRenderer.buildEntityTypes(getModelObject().getAnnotationLayers(), annotationService));
String json = toJson(response);
return "Wicket.$('" + vis.getMarkupId() + "').dispatcher.post('collectionLoaded', [" + json + "]);";
}
Aggregations