1 package eu.fbk.dkm.pikes.tintop.server;
2
3 import eu.fbk.dkm.pikes.rdf.RDFGenerator;
4 import eu.fbk.dkm.pikes.rdf.Renderer;
5 import eu.fbk.dkm.pikes.resources.NAFFilter;
6 import eu.fbk.dkm.pikes.tintop.AnnotationPipeline;
7 import ixa.kaflib.KAFDocument;
8 import org.glassfish.grizzly.http.server.Request;
9 import org.glassfish.grizzly.http.server.Response;
10 import org.eclipse.rdf4j.model.Model;
11
12 import java.io.StringReader;
13 import java.io.StringWriter;
14
15
16
17
18
19
20
21
22
23 public class NafVisualizeHandler extends AbstractHandler {
24
25 public NafVisualizeHandler(AnnotationPipeline pipeline) {
26 super(pipeline);
27 }
28
29 @Override
30 public void service(Request request, Response response) throws Exception {
31
32 super.service(request, response);
33
34 String naf = request.getParameter("naf");
35 KAFDocument document = KAFDocument.createFromStream(new StringReader(naf));
36
37 NAFFilter filter = NAFFilter.builder().withSRLRoleLinking(false, false).withOpinionLinking(false, false).build();
38 RDFGenerator generator = RDFGenerator.DEFAULT;
39 Renderer renderer = Renderer.DEFAULT;
40
41 filter.filter(document);
42 final Model model = generator.generate(document, null);
43 StringWriter writer = new StringWriter();
44 renderer.renderAll(writer, document, model, null, null);
45 String res = writer.toString();
46
47 super.writeOutput(response, "text/html", res);
48 }
49 }