|
@@ -5,7 +5,7 @@ package cn.winhc.elasticsearch.plugin.entity;
|
|
|
* 2021/11/8 09:03
|
|
|
*/
|
|
|
|
|
|
-public class Term {
|
|
|
+public class Term implements Comparable<Term> {
|
|
|
//词元的起始位移
|
|
|
private int offset;
|
|
|
//词元的相对起始位置
|
|
@@ -86,4 +86,10 @@ public class Term {
|
|
|
result = 31 * result + (text != null ? text.hashCode() : 0);
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int compareTo(Term o) {
|
|
|
+ int compare = Integer.compare(this.offset, o.offset);
|
|
|
+ return compare == 0 ? Integer.compare(this.end, o.end) : compare;
|
|
|
+ }
|
|
|
}
|