@Test public void testToString() { OdinSentence odinSentence = new OdinSentence( 1, sentence, ImmutableList.of(w1, w2), ImmutableList.of(Optional.of(e1), Optional.empty()), new String[] {"Test", "test"}, new int[] {0, 6}, new int[] {4, 10}); StringBuilder sb = new StringBuilder() .append("Tokens: Test test") .append("\n") .append("Start: [0, 6]") .append("\n") .append("End: [4, 10]") .append("\n") .append("Test___") .append("\n") .append("test___"); assertEquals(sb.toString().trim(), odinSentence.toString().trim()); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Tokens: " + String.join(" ", words())); sb.append("\n"); if (this.lemmas().isDefined()) { sb.append("Lemmas: " + String.join(" ", lemmas().get())); sb.append("\n"); } if (this.tags().isDefined()) { sb.append("POS tags: " + String.join(" ", tags().get())); sb.append("\n"); } if (this.chunks().isDefined()) { sb.append("Chunks: " + String.join(" ", chunks().get())); sb.append("\n"); } if (this.entities().isDefined()) { sb.append("Entities: " + String.join(" ", entities().get())); sb.append("\n"); } if (this.norms().isDefined()) { sb.append("Normalized: " + String.join(" ", norms().get())); sb.append("\n"); } sb.append("Start: " + Arrays.toString(startOffsets())); sb.append("\n"); sb.append("End: " + Arrays.toString(endOffsets())); sb.append("\n"); for (int i = 0; i < tokens.size(); i++) { sb.append(word(i)); sb.append("_"); sb.append(tag(i)); sb.append("_"); sb.append(lemma(i)); sb.append("_"); sb.append(entity(i)); sb.append("\n"); } if (this.dependencies().isDefined()) { sb.append("Syntactic dependencies:\n"); DirectedGraphEdgeIterator<String> iterator = new DirectedGraphEdgeIterator<>(this.dependencies().get()); while (iterator.hasNext()) { scala.Tuple3<Object, Object, String> dep = iterator.next(); sb.append( " head:" + dep._1() + ":" + word((int) dep._1()) + " modifier:" + dep._2() + ":" + word((int) dep._2()) + " label:" + dep._3()); sb.append("\n"); } } return sb.toString(); }
OdinSentence extends Sentence { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Tokens: " + String.join(" ", words())); sb.append("\n"); if (this.lemmas().isDefined()) { sb.append("Lemmas: " + String.join(" ", lemmas().get())); sb.append("\n"); } if (this.tags().isDefined()) { sb.append("POS tags: " + String.join(" ", tags().get())); sb.append("\n"); } if (this.chunks().isDefined()) { sb.append("Chunks: " + String.join(" ", chunks().get())); sb.append("\n"); } if (this.entities().isDefined()) { sb.append("Entities: " + String.join(" ", entities().get())); sb.append("\n"); } if (this.norms().isDefined()) { sb.append("Normalized: " + String.join(" ", norms().get())); sb.append("\n"); } sb.append("Start: " + Arrays.toString(startOffsets())); sb.append("\n"); sb.append("End: " + Arrays.toString(endOffsets())); sb.append("\n"); for (int i = 0; i < tokens.size(); i++) { sb.append(word(i)); sb.append("_"); sb.append(tag(i)); sb.append("_"); sb.append(lemma(i)); sb.append("_"); sb.append(entity(i)); sb.append("\n"); } if (this.dependencies().isDefined()) { sb.append("Syntactic dependencies:\n"); DirectedGraphEdgeIterator<String> iterator = new DirectedGraphEdgeIterator<>(this.dependencies().get()); while (iterator.hasNext()) { scala.Tuple3<Object, Object, String> dep = iterator.next(); sb.append( " head:" + dep._1() + ":" + word((int) dep._1()) + " modifier:" + dep._2() + ":" + word((int) dep._2()) + " label:" + dep._3()); sb.append("\n"); } } return sb.toString(); } }
OdinSentence extends Sentence { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Tokens: " + String.join(" ", words())); sb.append("\n"); if (this.lemmas().isDefined()) { sb.append("Lemmas: " + String.join(" ", lemmas().get())); sb.append("\n"); } if (this.tags().isDefined()) { sb.append("POS tags: " + String.join(" ", tags().get())); sb.append("\n"); } if (this.chunks().isDefined()) { sb.append("Chunks: " + String.join(" ", chunks().get())); sb.append("\n"); } if (this.entities().isDefined()) { sb.append("Entities: " + String.join(" ", entities().get())); sb.append("\n"); } if (this.norms().isDefined()) { sb.append("Normalized: " + String.join(" ", norms().get())); sb.append("\n"); } sb.append("Start: " + Arrays.toString(startOffsets())); sb.append("\n"); sb.append("End: " + Arrays.toString(endOffsets())); sb.append("\n"); for (int i = 0; i < tokens.size(); i++) { sb.append(word(i)); sb.append("_"); sb.append(tag(i)); sb.append("_"); sb.append(lemma(i)); sb.append("_"); sb.append(entity(i)); sb.append("\n"); } if (this.dependencies().isDefined()) { sb.append("Syntactic dependencies:\n"); DirectedGraphEdgeIterator<String> iterator = new DirectedGraphEdgeIterator<>(this.dependencies().get()); while (iterator.hasNext()) { scala.Tuple3<Object, Object, String> dep = iterator.next(); sb.append( " head:" + dep._1() + ":" + word((int) dep._1()) + " modifier:" + dep._2() + ":" + word((int) dep._2()) + " label:" + dep._3()); sb.append("\n"); } } return sb.toString(); } protected  OdinSentence(
      int sentenceIndex,
      uk.gov.dstl.baleen.types.language.Sentence baleenSentence,
      List<WordToken> tokens,
      List<Optional<Entity>> entities,
      String[] words,
      int[] startOffsets,
      int[] endOffsets); }
OdinSentence extends Sentence { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Tokens: " + String.join(" ", words())); sb.append("\n"); if (this.lemmas().isDefined()) { sb.append("Lemmas: " + String.join(" ", lemmas().get())); sb.append("\n"); } if (this.tags().isDefined()) { sb.append("POS tags: " + String.join(" ", tags().get())); sb.append("\n"); } if (this.chunks().isDefined()) { sb.append("Chunks: " + String.join(" ", chunks().get())); sb.append("\n"); } if (this.entities().isDefined()) { sb.append("Entities: " + String.join(" ", entities().get())); sb.append("\n"); } if (this.norms().isDefined()) { sb.append("Normalized: " + String.join(" ", norms().get())); sb.append("\n"); } sb.append("Start: " + Arrays.toString(startOffsets())); sb.append("\n"); sb.append("End: " + Arrays.toString(endOffsets())); sb.append("\n"); for (int i = 0; i < tokens.size(); i++) { sb.append(word(i)); sb.append("_"); sb.append(tag(i)); sb.append("_"); sb.append(lemma(i)); sb.append("_"); sb.append(entity(i)); sb.append("\n"); } if (this.dependencies().isDefined()) { sb.append("Syntactic dependencies:\n"); DirectedGraphEdgeIterator<String> iterator = new DirectedGraphEdgeIterator<>(this.dependencies().get()); while (iterator.hasNext()) { scala.Tuple3<Object, Object, String> dep = iterator.next(); sb.append( " head:" + dep._1() + ":" + word((int) dep._1()) + " modifier:" + dep._2() + ":" + word((int) dep._2()) + " label:" + dep._3()); sb.append("\n"); } } return sb.toString(); } protected  OdinSentence(
      int sentenceIndex,
      uk.gov.dstl.baleen.types.language.Sentence baleenSentence,
      List<WordToken> tokens,
      List<Optional<Entity>> entities,
      String[] words,
      int[] startOffsets,
      int[] endOffsets); String word(int index); String tag(int index); String lemma(int index); String entity(int index); @Override String toString(); }
OdinSentence extends Sentence { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Tokens: " + String.join(" ", words())); sb.append("\n"); if (this.lemmas().isDefined()) { sb.append("Lemmas: " + String.join(" ", lemmas().get())); sb.append("\n"); } if (this.tags().isDefined()) { sb.append("POS tags: " + String.join(" ", tags().get())); sb.append("\n"); } if (this.chunks().isDefined()) { sb.append("Chunks: " + String.join(" ", chunks().get())); sb.append("\n"); } if (this.entities().isDefined()) { sb.append("Entities: " + String.join(" ", entities().get())); sb.append("\n"); } if (this.norms().isDefined()) { sb.append("Normalized: " + String.join(" ", norms().get())); sb.append("\n"); } sb.append("Start: " + Arrays.toString(startOffsets())); sb.append("\n"); sb.append("End: " + Arrays.toString(endOffsets())); sb.append("\n"); for (int i = 0; i < tokens.size(); i++) { sb.append(word(i)); sb.append("_"); sb.append(tag(i)); sb.append("_"); sb.append(lemma(i)); sb.append("_"); sb.append(entity(i)); sb.append("\n"); } if (this.dependencies().isDefined()) { sb.append("Syntactic dependencies:\n"); DirectedGraphEdgeIterator<String> iterator = new DirectedGraphEdgeIterator<>(this.dependencies().get()); while (iterator.hasNext()) { scala.Tuple3<Object, Object, String> dep = iterator.next(); sb.append( " head:" + dep._1() + ":" + word((int) dep._1()) + " modifier:" + dep._2() + ":" + word((int) dep._2()) + " label:" + dep._3()); sb.append("\n"); } } return sb.toString(); } protected  OdinSentence(
      int sentenceIndex,
      uk.gov.dstl.baleen.types.language.Sentence baleenSentence,
      List<WordToken> tokens,
      List<Optional<Entity>> entities,
      String[] words,
      int[] startOffsets,
      int[] endOffsets); String word(int index); String tag(int index); String lemma(int index); String entity(int index); @Override String toString();  }