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   /**
   21    * SmartChineseAnalyzer internal node representation
   22    * <p>
   23    * Used by {@link BiSegGraph} to maximize the segmentation with the Viterbi algorithm.
   24    * </p>
   25    * <p><font color="#FF0000">
   26    * WARNING: The status of the analyzers/smartcn <b>analysis.cn.smart</b> package is experimental. 
   27    * The APIs and file formats introduced here might change in the future and will not be 
   28    * supported anymore in such a case.</font>
   29    * </p>
   30    */
   31   class PathNode implements Comparable<PathNode> {
   32     public double weight;
   33   
   34     public int preNode;
   35   
   36     public int compareTo(PathNode pn) {
   37       if (weight < pn.weight)
   38         return -1;
   39       else if (weight == pn.weight)
   40         return 0;
   41       else
   42         return 1;
   43     }
   44   
   45     /**
   46      * @see java.lang.Object#hashCode()
   47      */
   48     @Override
   49     public int hashCode() {
   50       final int prime = 31;
   51       int result = 1;
   52       result = prime * result + preNode;
   53       long temp;
   54       temp = Double.doubleToLongBits(weight);
   55       result = prime * result + (int) (temp ^ (temp >>> 32));
   56       return result;
   57     }
   58   
   59     /**
   60      * @see java.lang.Object#equals(java.lang.Object)
   61      */
   62     @Override
   63     public boolean equals(Object obj) {
   64       if (this == obj)
   65         return true;
   66       if (obj == null)
   67         return false;
   68       if (getClass() != obj.getClass())
   69         return false;
   70       PathNode other = (PathNode) obj;
   71       if (preNode != other.preNode)
   72         return false;
   73       if (Double.doubleToLongBits(weight) != Double
   74           .doubleToLongBits(other.weight))
   75         return false;
   76       return true;
   77     }
   78   }

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