| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- package org.cnnlp.data.splitter;
- import org.jetbrains.annotations.NotNull;
- import java.io.Serializable;
- import java.util.Objects;
- public class SubSequence implements Serializable {
- String text;
- int startOffset;
- int endOffset;
- public SubSequence() {
- }
- public SubSequence(String text, int startOffset, int endOffset) {
- this.text = text;
- this.startOffset = startOffset;
- this.endOffset = endOffset;
- }
- // @Override
- // public int compareTo(@NotNull SubSequence o) {
- // return startOffset - o.startOffset;
- // }
- public String getText() {
- return text;
- }
- public void setText(String text) {
- this.text = text;
- }
- public int getStartOffset() {
- return startOffset;
- }
- public void setStartOffset(int startOffset) {
- this.startOffset = startOffset;
- }
- public int getEndOffset() {
- return endOffset;
- }
- public void setEndOffset(int endOffset) {
- this.endOffset = endOffset;
- }
- public void incrementalOffset(int offset) {
- startOffset = startOffset + offset;
- endOffset = endOffset + offset;
- }
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- SubSequence that = (SubSequence) o;
- return startOffset == that.startOffset && endOffset == that.endOffset && Objects.equals(text, that.text);
- }
- @Override
- public int hashCode() {
- return Objects.hash(text, startOffset, endOffset);
- }
- @Override
- public String toString() {
- return "SubSequence{" +
- "text='" + text + '\'' +
- ", startOffset=" + startOffset +
- ", endOffset=" + endOffset +
- '}';
- }
- public static SubSequence build(String text, int startOffset, int endOffset) {
- SubSequence ss = new SubSequence(text, startOffset, endOffset);
- return ss;
- }
- }
|