2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 package org.apache.lucene.analysis.cn.smart.hhmm;
20 import java.util.Arrays;
22 import org.apache.lucene.analysis.cn.smart.WordType; // for javadocs
25 * SmartChineseAnalyzer internal token
26 * @lucene.experimental
28 public class SegToken {
30 * Character array containing token text
32 public char[] charArray;
35 * start offset into original sentence
37 public int startOffset;
40 * end offset into original sentence
45 * {@link WordType} of the text
55 * during segmentation, this is used to store the index of the token in the token list table
60 * Create a new SegToken from a character array.
62 * @param idArray character array containing text
63 * @param start start offset of SegToken in original sentence
64 * @param end end offset of SegToken in original sentence
65 * @param wordType {@link WordType} of the text
66 * @param weight word frequency
68 public SegToken(char[] idArray, int start, int end, int wordType, int weight) {
69 this.charArray = idArray;
70 this.startOffset = start;
72 this.wordType = wordType;
77 * @see java.lang.Object#hashCode()
80 public int hashCode() {
83 for(int i=0;i<charArray.length;i++) {
84 result = prime * result + charArray[i];
86 result = prime * result + endOffset;
87 result = prime * result + index;
88 result = prime * result + startOffset;
89 result = prime * result + weight;
90 result = prime * result + wordType;
95 * @see java.lang.Object#equals(java.lang.Object)
98 public boolean equals(Object obj) {
103 if (getClass() != obj.getClass())
105 SegToken other = (SegToken) obj;
106 if (!Arrays.equals(charArray, other.charArray))
108 if (endOffset != other.endOffset)
110 if (index != other.index)
112 if (startOffset != other.startOffset)
114 if (weight != other.weight)
116 if (wordType != other.wordType)