private static void writeSentences(TextAnnotation ta, JsonObject json) { JsonObject object = new JsonObject(); SpanLabelView sentenceView = (SpanLabelView) ta.getView(ViewNames.SENTENCE); writeString("generator", sentenceView.getViewGenerator(), object); writeDouble("score", sentenceView.getScore(), object); int numSentences = sentenceView.getNumberOfConstituents(); int[] sentenceEndPositions = new int[numSentences]; int id = 0; for (Sentence sentence : ta.sentences()) { sentenceEndPositions[id++] = sentence.getEndSpan(); } writeIntArray("sentenceEndPositions", sentenceEndPositions, object); json.add("sentences", object); }
private static void writeSentences(TextAnnotation ta, JsonObject json) { JsonObject object = new JsonObject(); SpanLabelView sentenceView = (SpanLabelView) ta.getView(ViewNames.SENTENCE); writeString("generator", sentenceView.getViewGenerator(), object); writeDouble("score", sentenceView.getScore(), object); int numSentences = sentenceView.getNumberOfConstituents(); int[] sentenceEndPositions = new int[numSentences]; int id = 0; for (Sentence sentence : ta.sentences()) { sentenceEndPositions[id++] = sentence.getEndSpan(); } writeIntArray("sentenceEndPositions", sentenceEndPositions, object); json.add("sentences", object); }
private static void writeSentences(TextAnnotation ta, TextAnnotationProto.Builder taBuilder) { SentenceProto.Builder sentenceBuilder = SentenceProto.newBuilder(); SpanLabelView sentenceView = (SpanLabelView) ta.getView(ViewNames.SENTENCE); sentenceBuilder.setGenerator(sentenceView.getViewGenerator()); sentenceBuilder.setScore(sentenceView.getScore()); for (Sentence sentence: ta.sentences()) { sentenceBuilder.addSentenceEndPositions(sentence.getEndSpan()); } taBuilder.setSentences(sentenceBuilder); }
private static void writeSentences(TextAnnotation ta, TextAnnotationProto.Builder taBuilder) { SentenceProto.Builder sentenceBuilder = SentenceProto.newBuilder(); SpanLabelView sentenceView = (SpanLabelView) ta.getView(ViewNames.SENTENCE); sentenceBuilder.setGenerator(sentenceView.getViewGenerator()); sentenceBuilder.setScore(sentenceView.getScore()); for (Sentence sentence: ta.sentences()) { sentenceBuilder.addSentenceEndPositions(sentence.getEndSpan()); } taBuilder.setSentences(sentenceBuilder); }