# This patch file was generated by NetBeans IDE
# Following Index: paths are relative to: /data/home/hlavki/develop/workspaces/lucene/dev
# This patch can be applied using context Tools: Patch action on respective folder.
# It uses platform neutral UTF-8 encoding and \n newlines.
# Above lines and this line are ignored by the patching process.
Index: lucene/analysis/morfologik/src/java/org/apache/lucene/analysis/morfologik/MorfologikAnalyzer.java
--- lucene/analysis/morfologik/src/java/org/apache/lucene/analysis/morfologik/MorfologikAnalyzer.java Base (BASE)
+++ lucene/analysis/morfologik/src/java/org/apache/lucene/analysis/morfologik/MorfologikAnalyzer.java Locally Modified (Based On LOCAL)
@@ -31,16 +31,19 @@
  * @see <a href="http://morfologik.blogspot.com/">Morfologik project page</a>
  */
 public class MorfologikAnalyzer extends Analyzer {
+  private final String dictionary;
   private final Version version;
 
   /**
    * Builds an analyzer with the default Morfologik's dictionary (polimorf).
    * 
-   * @param version
-   *          Lucene compatibility version
+   * @param version Lucene compatibility version
+   * @param dictionary A constant specifying which dictionary to choose. See the Morfologik 
+   * documentation for details or use the default.
    */
-  public MorfologikAnalyzer(final Version version) {
+  public MorfologikAnalyzer(final Version version, final String dictionary) {
     this.version = version;
+      this.dictionary = dictionary;
   }
 
   /**
@@ -62,6 +65,6 @@
     
     return new TokenStreamComponents(
         src, 
-        new MorfologikFilter(new StandardFilter(this.version, src), this.version));
+        new MorfologikFilter(new StandardFilter(this.version, src), this.dictionary, this.version));
   }
 }
Index: lucene/analysis/morfologik/src/java/org/apache/lucene/analysis/morfologik/MorfologikFilter.java
--- lucene/analysis/morfologik/src/java/org/apache/lucene/analysis/morfologik/MorfologikFilter.java Base (BASE)
+++ lucene/analysis/morfologik/src/java/org/apache/lucene/analysis/morfologik/MorfologikFilter.java Locally Modified (Based On LOCAL)
@@ -65,7 +65,7 @@
    * @param in   input token stream
    * @param version Lucene version compatibility for lowercasing.
    */
-  public MorfologikFilter(final TokenStream in, final Version version) {
+  public MorfologikFilter(final TokenStream in, final String dict, final Version version) {
     super(in);
     this.input = in;
     
@@ -73,8 +73,8 @@
     Thread me = Thread.currentThread();
     ClassLoader cl = me.getContextClassLoader();
     try {
-      me.setContextClassLoader(PolishStemmer.class.getClassLoader());
-      this.stemmer = new PolishStemmer();
+      me.setContextClassLoader(MorfologikLemmatizer.class.getClassLoader());
+      this.stemmer = new MorfologikLemmatizer(dict);
       this.charUtils = CharacterUtils.getInstance(version);
       this.lemmaList = Collections.emptyList();
     } finally {
Index: lucene/analysis/morfologik/src/java/org/apache/lucene/analysis/morfologik/MorfologikFilterFactory.java
--- lucene/analysis/morfologik/src/java/org/apache/lucene/analysis/morfologik/MorfologikFilterFactory.java Base (BASE)
+++ lucene/analysis/morfologik/src/java/org/apache/lucene/analysis/morfologik/MorfologikFilterFactory.java Locally Modified (Based On LOCAL)
@@ -35,8 +35,13 @@
  * @see <a href="http://morfologik.blogspot.com/">Morfologik web site</a>
  */
 public class MorfologikFilterFactory extends TokenFilterFactory {
+
+  /**
+   * Dictionary resource
+   */
+  private final String dictionary;
+
   /** Schema attribute. */
-  @Deprecated
   public static final String DICTIONARY_SCHEMA_ATTRIBUTE = "dictionary";
 
   /** Creates a new MorfologikFilterFactory */
@@ -44,10 +49,9 @@
     super(args);
 
     // Be specific about no-longer-supported dictionary attribute.
-    String dictionaryName = get(args, DICTIONARY_SCHEMA_ATTRIBUTE);
-    if (dictionaryName != null && !dictionaryName.isEmpty()) {
-      throw new IllegalArgumentException("The " + DICTIONARY_SCHEMA_ATTRIBUTE + " attribute is no "
-          + "longer supported (Morfologik has one dictionary): " + dictionaryName);
+    dictionary = get(args, DICTIONARY_SCHEMA_ATTRIBUTE);
+    if (dictionary == null || dictionary.isEmpty()) {
+      throw new IllegalArgumentException("The " + DICTIONARY_SCHEMA_ATTRIBUTE + " attribute cannot be empty!");
     }
 
     if (!args.isEmpty()) {
@@ -57,6 +61,6 @@
 
   @Override
   public TokenStream create(TokenStream ts) {
-    return new MorfologikFilter(ts, luceneMatchVersion);
+    return new MorfologikFilter(ts, dictionary, luceneMatchVersion);
   }
 }
Index: lucene/analysis/morfologik/src/java/org/apache/lucene/analysis/morfologik/MorfologikLemmatizer.java
--- lucene/analysis/morfologik/src/java/org/apache/lucene/analysis/morfologik/MorfologikLemmatizer.java No Base Revision
+++ lucene/analysis/morfologik/src/java/org/apache/lucene/analysis/morfologik/MorfologikLemmatizer.java Locally New
@@ -0,0 +1,68 @@
+// -*- c-basic-offset: 2 -*-
+package org.apache.lucene.analysis.morfologik;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import java.util.Iterator;
+import java.util.List;
+import morfologik.stemming.Dictionary;
+import morfologik.stemming.DictionaryLookup;
+import morfologik.stemming.IStemmer;
+import morfologik.stemming.WordData;
+
+/**
+ * A dictionary-based stemmer for language. This stemmer requires an FSA-compiled dictionary to be present in
+ * classpath resources.
+ *
+ * <b>Objects of this class are not thread safe.</b>
+ *
+ * @see morfologik.stemming.DictionaryLookup
+ */
+public final class MorfologikLemmatizer implements IStemmer, Iterable<WordData> {
+
+  /**
+   * Dictionary lookup delegate.
+   */
+  private final DictionaryLookup delegate;
+
+  /**
+   * This constructor is initialized with a built-in dictionary or fails with a runtime exception if the
+   * dictionary is not available.
+   *
+   * @param dictionary A constant specifying which dictionary to choose. See the Morfologik documentation for
+   * details or use the default.
+   */
+  public MorfologikLemmatizer(String dictionary) {
+    delegate = new DictionaryLookup(Dictionary.getForLanguage(dictionary));
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public List<WordData> lookup(CharSequence word) {
+    return delegate.lookup(word);
+  }
+
+  /**
+   * Iterates over all dictionary forms stored in this stemmer.
+   */
+  @Override
+  public Iterator<WordData> iterator() {
+    return delegate.iterator();
+  }
+}
Index: lucene/analysis/morfologik/src/test/org/apache/lucene/analysis/morfologik/TestMorfologikAnalyzer.java
--- lucene/analysis/morfologik/src/test/org/apache/lucene/analysis/morfologik/TestMorfologikAnalyzer.java Base (BASE)
+++ lucene/analysis/morfologik/src/test/org/apache/lucene/analysis/morfologik/TestMorfologikAnalyzer.java Locally Modified (Based On LOCAL)
@@ -38,7 +38,7 @@
 public class TestMorfologikAnalyzer extends BaseTokenStreamTestCase {
 
   private Analyzer getTestAnalyzer() {
-    return new MorfologikAnalyzer(TEST_VERSION_CURRENT);
+    return new MorfologikAnalyzer(TEST_VERSION_CURRENT, "pl");
   }
 
   /** Test stemming of single tokens with Morfologik library. */
@@ -168,8 +168,9 @@
   /** */
   public final void testKeywordAttrTokens() throws IOException {
     final Version version = TEST_VERSION_CURRENT;
+    final String dictionary = "pl";
 
-    Analyzer a = new MorfologikAnalyzer(version) {
+    Analyzer a = new MorfologikAnalyzer(version, dictionary) {
       @Override
       protected TokenStreamComponents createComponents(String field, Reader reader) {
         final CharArraySet keywords = new CharArraySet(version, 1, false);
@@ -178,7 +179,7 @@
         final Tokenizer src = new StandardTokenizer(TEST_VERSION_CURRENT, reader);
         TokenStream result = new StandardFilter(TEST_VERSION_CURRENT, src);
         result = new SetKeywordMarkerFilter(result, keywords);
-        result = new MorfologikFilter(result, TEST_VERSION_CURRENT); 
+        result = new MorfologikFilter(result, dictionary, TEST_VERSION_CURRENT); 
 
         return new TokenStreamComponents(src, result);
       }
Index: lucene/analysis/morfologik/src/test/org/apache/lucene/analysis/morfologik/TestMorfologikFilterFactory.java
--- lucene/analysis/morfologik/src/test/org/apache/lucene/analysis/morfologik/TestMorfologikFilterFactory.java Base (BASE)
+++ lucene/analysis/morfologik/src/test/org/apache/lucene/analysis/morfologik/TestMorfologikFilterFactory.java Locally Modified (Based On LOCAL)
@@ -20,6 +20,7 @@
 import java.io.StringReader;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.Map;
 
 import org.apache.lucene.analysis.BaseTokenStreamTestCase;
 import org.apache.lucene.analysis.MockTokenizer;
@@ -31,7 +32,8 @@
 public class TestMorfologikFilterFactory extends BaseTokenStreamTestCase {
   public void testCreateDictionary() throws Exception {
     StringReader reader = new StringReader("rowery bilety");
-    MorfologikFilterFactory factory = new MorfologikFilterFactory(Collections.<String,String>emptyMap());
+    Map<String, String> args = new HashMap<String, String>(Collections.<String,String>singletonMap("dictionary", "pl"));
+    MorfologikFilterFactory factory = new MorfologikFilterFactory(args);
     TokenStream stream = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
     stream = factory.create(stream);
     assertTokenStreamContents(stream, new String[] {"rower", "bilet"});
@@ -41,6 +43,7 @@
   public void testBogusArguments() throws Exception {
     try {
       new MorfologikFilterFactory(new HashMap<String,String>() {{
+        put("dictionary", "pl");
         put("bogusArg", "bogusValue");
       }});
       fail();
