Index: FuzzyQuery.java
===================================================================
RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/FuzzyQuery.java,v
retrieving revision 1.4
diff -u -r1.4 FuzzyQuery.java
--- FuzzyQuery.java	29 Mar 2004 22:48:03 -0000	1.4
+++ FuzzyQuery.java	8 Aug 2004 14:47:49 -0000
@@ -20,14 +20,43 @@
 import org.apache.lucene.index.Term;
 import java.io.IOException;
 
-/** Implements the fuzzy search query */
+/** Implements the fuzzy search query. The similiarity measurement
+ * is based on the Levenshtein (edit distance) algorithm.
+ */
 public final class FuzzyQuery extends MultiTermQuery {
-  public FuzzyQuery(Term term) {
+  
+  private float minimumSimilarity;
+  
+  /**
+   * Create a new FuzzyQuery that will match terms with a similarity 
+   * of at least <code>minimumSimilarity</code> to <code>term</code>.
+   * 
+   * @param term the term to search for
+   * @param minimumSimilarity a value between 0 and 1 to set the required similarity
+   *  between the query term and the matching terms. For example, for a
+   *  <code>minimumSimilarity</code> of <code>0.5</code> a term of the same length
+   *  as the query term is considered similar to the query term if the edit distance
+   *  between both terms is less than <code>length(term)*0.5</code>.
+   * @throws IllegalArgumentException if minimumSimilarity is &gt; 1 or &lt; 0
+   */
+  public FuzzyQuery(Term term, float minimumSimilarity) throws IllegalArgumentException {
     super(term);
+    if (minimumSimilarity > 1.0f)
+      throw new IllegalArgumentException("minimumSimilarity > 1");
+    else if (minimumSimilarity < 0.0f)
+      throw new IllegalArgumentException("minimumSimilarity < 0");
+    this.minimumSimilarity = minimumSimilarity;
+  }
+
+  /**
+   * Calls {@link #FuzzyQuery(Term, float) FuzzyQuery(term, 0.5f)}.
+   */
+  public FuzzyQuery(Term term) {
+    this(term, 0.5f);
   }
     
   protected FilteredTermEnum getEnum(IndexReader reader) throws IOException {
-    return new FuzzyTermEnum(reader, getTerm());
+    return new FuzzyTermEnum(reader, getTerm(), minimumSimilarity);
   }
     
   public String toString(String field) {


