Home » lucene-3.0.1-src » org.apache.lucene.analysis.cn.smart.hhmm » [javadoc | source]

    1   /**
    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
    8    *
    9    *     http://www.apache.org/licenses/LICENSE-2.0
   10    *
   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.
   16    */
   17   
   18   package org.apache.lucene.analysis.cn.smart.hhmm;
   19   
   20   import java.util.Arrays;
   21   
   22   /**
   23    * A pair of tokens in {@link SegGraph}
   24    * <p><font color="#FF0000">
   25    * WARNING: The status of the analyzers/smartcn <b>analysis.cn.smart</b> package is experimental. 
   26    * The APIs and file formats introduced here might change in the future and will not be 
   27    * supported anymore in such a case.</font>
   28    * </p>
   29    */
   30   class SegTokenPair {
   31   
   32     public char[] charArray;
   33   
   34     /**
   35      * index of the first token in {@link SegGraph}
   36      */
   37     public int from;
   38   
   39     /**
   40      * index of the second token in {@link SegGraph}
   41      */
   42     public int to;
   43   
   44     public double weight;
   45   
   46     public SegTokenPair(char[] idArray, int from, int to, double weight) {
   47       this.charArray = idArray;
   48       this.from = from;
   49       this.to = to;
   50       this.weight = weight;
   51     }
   52   
   53     /**
   54      * @see java.lang.Object#hashCode()
   55      */
   56     @Override
   57     public int hashCode() {
   58       final int prime = 31;
   59       int result = 1;
   60       for(int i=0;i<charArray.length;i++) {
   61         result = prime * result + charArray[i];
   62       }
   63       result = prime * result + from;
   64       result = prime * result + to;
   65       long temp;
   66       temp = Double.doubleToLongBits(weight);
   67       result = prime * result + (int) (temp ^ (temp >>> 32));
   68       return result;
   69     }
   70   
   71     /**
   72      * @see java.lang.Object#equals(java.lang.Object)
   73      */
   74     @Override
   75     public boolean equals(Object obj) {
   76       if (this == obj)
   77         return true;
   78       if (obj == null)
   79         return false;
   80       if (getClass() != obj.getClass())
   81         return false;
   82       SegTokenPair other = (SegTokenPair) obj;
   83       if (!Arrays.equals(charArray, other.charArray))
   84         return false;
   85       if (from != other.from)
   86         return false;
   87       if (to != other.to)
   88         return false;
   89       if (Double.doubleToLongBits(weight) != Double
   90           .doubleToLongBits(other.weight))
   91         return false;
   92       return true;
   93     }
   94   
   95   }

Home » lucene-3.0.1-src » org.apache.lucene.analysis.cn.smart.hhmm » [javadoc | source]