public TextAnnotation preProcessText(String text) throws Exception { TextAnnotation ta; ta = annotator.createBasicTextAnnotation("", "", text); addViews(ta); return ta; }
public TextAnnotation preProcessText(String text) throws Exception { TextAnnotation ta; if (useCurator) { ta = annotator.createBasicTextAnnotation("", "", text); } else { ta = taBuilder.createTextAnnotation(text); } return preProcessText(ta); }
public TextAnnotation preProcessText(String text) throws Exception { TextAnnotation ta; if (useCurator) { ta = annotator.createBasicTextAnnotation("", "", text); } else { ta = taBuilder.createTextAnnotation(text); } return preProcessText(ta); }
private static String annotateText(AnnotatorService finalPipeline, String text, String views, Logger logger) throws AnnotatorException { if (views == null || text == null) { return "The parameters 'text' and/or 'views' are not specified. Here is a sample input: \n ?text=\"This is a sample sentence. I'm happy.\"&views=POS,NER"; } else { logger.info("------------------------------"); logger.info("Text: " + text); logger.info("Views to add: " + views); String[] viewsInArray = views.split(","); logger.info("Adding the basic annotations . . . "); TextAnnotation ta = finalPipeline.createBasicTextAnnotation("", "", text); for (String vuName : viewsInArray) { logger.info("Adding the view: ->" + vuName.trim() + "<-"); try { finalPipeline.addView(ta, vuName.trim()); } catch (Exception e) { e.printStackTrace(); } printMemoryDetails(logger); } logger.info("Done adding the views. Deserializing the view now."); String output = SerializationHelper.serializeToJson(ta); logger.info("Done. Sending the result back. "); return output; } }
private static String annotateText(AnnotatorService finalPipeline, String text, String views, Logger logger) throws AnnotatorException { if (views == null || text == null) { return "The parameters 'text' and/or 'views' are not specified. Here is a sample input: \n ?text=\"This is a sample sentence. I'm happy.\"&views=POS,NER"; } else { logger.info("------------------------------"); logger.info("Text: " + text); logger.info("Views to add: " + views); String[] viewsInArray = views.split(","); logger.info("Adding the basic annotations . . . "); TextAnnotation ta = finalPipeline.createBasicTextAnnotation("", "", text); for (String vuName : viewsInArray) { logger.info("Adding the view: ->" + vuName.trim() + "<-"); try { finalPipeline.addView(ta, vuName.trim()); } catch (Exception e) { e.printStackTrace(); } printMemoryDetails(logger); } logger.info("Done adding the views. Deserializing the view now."); String output = SerializationHelper.serializeToJson(ta); logger.info("Done. Sending the result back. "); return output; } }
private static String annotateText(AnnotatorService finalPipeline, String text, String views, Logger logger) throws AnnotatorException { if (views == null || text == null) { return "The parameters 'text' and/or 'views' are not specified. Here is a sample input: \n ?text=\"This is a sample sentence. I'm happy.\"&views=POS,NER"; } else { logger.info("------------------------------"); logger.info("Text: " + text); logger.info("Views to add: " + views); String[] viewsInArray = views.split(","); logger.info("Adding the basic annotations . . . "); TextAnnotation ta = finalPipeline.createBasicTextAnnotation("", "", text); for (String vuName : viewsInArray) { logger.info("Adding the view: ->" + vuName.trim() + "<-"); try { finalPipeline.addView(ta, vuName.trim()); } catch (Exception e) { e.printStackTrace(); } printMemoryDetails(logger); } logger.info("Done adding the views. Deserializing the view now."); String output = SerializationHelper.serializeToJson(ta); logger.info("Done. Sending the result back. "); return output; } }
private static String annotateText(AnnotatorService finalPipeline, String text, String views, Logger logger) throws AnnotatorException { if (views == null || text == null) { return "The parameters 'text' and/or 'views' are not specified. Here is a sample input: \n ?text=\"This is a sample sentence. I'm happy.\"&views=POS,NER"; } else { logger.info("------------------------------"); logger.info("Text: " + text); logger.info("Views to add: " + views); String[] viewsInArray = views.split(","); logger.info("Adding the basic annotations . . . "); TextAnnotation ta = finalPipeline.createBasicTextAnnotation("", "", text); for (String vuName : viewsInArray) { logger.info("Adding the view: ->" + vuName.trim() + "<-"); try { finalPipeline.addView(ta, vuName.trim()); } catch (Exception e) { e.printStackTrace(); } printMemoryDetails(logger); } logger.info("Done adding the views. Deserializing the view now."); String output = SerializationHelper.serializeToJson(ta); logger.info("Done. Sending the result back. "); return output; } }
public static void main (String[] args) throws Exception { /*Load data*/ byte[] encoded = Files.readAllBytes(Paths.get(args[0])); String text = new String(encoded, StandardCharsets.UTF_8); /*Create textannotation*/ AnnotatorService annotator = CuratorFactory.buildCuratorClient(); TextAnnotation ta = annotator.createBasicTextAnnotation("corpus", "id", text); /*Add part-of-speech*/ annotator.addView(ta, ViewNames.POS); /*ChunkerAnnotator*/ ChunkerAnnotator ca = new ChunkerAnnotator(true); ca.initialize(new ChunkerConfigurator().getDefaultConfig()); ca.addView(ta); /*Output to file*/ List<String> lines = new ArrayList<>(); lines.add(ta.getView(ViewNames.SHALLOW_PARSE).toString()); lines.add(ta.getView(ViewNames.POS).toString()); Path file = Paths.get(args[1]); Files.write(file,lines, Charset.forName("UTF-8")); } }
public static void main (String[] args) throws Exception { /*Load data*/ byte[] encoded = Files.readAllBytes(Paths.get(args[0])); String text = new String(encoded, StandardCharsets.UTF_8); /*Create textannotation*/ AnnotatorService annotator = CuratorFactory.buildCuratorClient(); TextAnnotation ta = annotator.createBasicTextAnnotation("corpus", "id", text); /*Add part-of-speech*/ annotator.addView(ta, ViewNames.POS); /*ChunkerAnnotator*/ ChunkerAnnotator ca = new ChunkerAnnotator(true); ca.initialize(new ChunkerConfigurator().getDefaultConfig()); ca.addView(ta); /*Output to file*/ List<String> lines = new ArrayList<>(); lines.add(ta.getView(ViewNames.SHALLOW_PARSE).toString()); lines.add(ta.getView(ViewNames.POS).toString()); Path file = Paths.get(args[1]); Files.write(file,lines, Charset.forName("UTF-8")); } }