01: package org.apache.lucene.search.spell;
02:
03: /**
04: * Licensed to the Apache Software Foundation (ASF) under one or more
05: * contributor license agreements. See the NOTICE file distributed with
06: * this work for additional information regarding copyright ownership.
07: * The ASF licenses this file to You under the Apache License, Version 2.0
08: * (the "License"); you may not use this file except in compliance with
09: * the License. You may obtain a copy of the License at
10: *
11: * http://www.apache.org/licenses/LICENSE-2.0
12: *
13: * Unless required by applicable law or agreed to in writing, software
14: * distributed under the License is distributed on an "AS IS" BASIS,
15: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16: * See the License for the specific language governing permissions and
17: * limitations under the License.
18: */
19:
20: /**
21: * SuggestWord, used in suggestSimilar method in SpellChecker class.
22: *
23: *
24: */
25: final class SuggestWord {
26: /**
27: * the score of the word
28: */
29: public float score;
30:
31: /**
32: * The freq of the word
33: */
34: public int freq;
35:
36: /**
37: * the suggested word
38: */
39: public String string;
40:
41: public final int compareTo(SuggestWord a) {
42: // first criteria: the edit distance
43: if (score > a.score) {
44: return 1;
45: }
46: if (score < a.score) {
47: return -1;
48: }
49:
50: // second criteria (if first criteria is equal): the popularity
51: if (freq > a.freq) {
52: return 1;
53: }
54:
55: if (freq < a.freq) {
56: return -1;
57: }
58: return 0;
59: }
60: }
|