@Override public String toString() { StringBuilder documentBuilder = new StringBuilder(); documentBuilder.append(section.toString() + ": "); documentBuilder.append(document.substring(section.getStart(), section.getEnd())); for (WordSpan sentSpan : words) { documentBuilder.append(","); documentBuilder.append(sentSpan.getCoveredText(document)); } return documentBuilder.toString(); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } else if (obj instanceof SentenceSpan) { SentenceSpan a = (SentenceSpan) obj; return getSentence().equals(a.getSentence()) && section.equals(a.section) && Arrays.equals(getWords(), a.getWords()); } else { return false; } }
/** * Retrieves the document. * * @return the document */ public String getSentence() { return document.substring(section.getStart(), section.getEnd()); }
@Override public int hashCode() { return getSentence().hashCode() ^ section.hashCode() ^ getWords().hashCode(); }