diff --git a/dictionary-reader/src/main/java/org/apache/lucene/morphology/dictionary/StatiticsCollector.java b/dictionary-reader/src/main/java/org/apache/lucene/morphology/dictionary/StatiticsCollector.java index 77c4539..2e7952d 100644 --- a/dictionary-reader/src/main/java/org/apache/lucene/morphology/dictionary/StatiticsCollector.java +++ b/dictionary-reader/src/main/java/org/apache/lucene/morphology/dictionary/StatiticsCollector.java @@ -19,7 +19,7 @@ package org.apache.lucene.morphology.dictionary; import org.apache.lucene.morphology.Heuristic; import org.apache.lucene.morphology.LetterDecoderEncoder; -import org.apache.lucene.morphology.Morph; +import org.apache.lucene.morphology.Morphology; import java.io.IOException; import java.util.*; @@ -119,8 +119,8 @@ public class StatiticsCollector implements WordProccessor { prevSet = currentSet; } } - Morph morph = new Morph(ints, rulesId, heuristics, grammaReader.getGrammaInfoAsArray()); - morph.writeToFile(fileName); + Morphology morphology = new Morphology(ints, rulesId, heuristics, grammaReader.getGrammaInfoAsArray()); + morphology.writeToFile(fileName); } private String revertWord(String s) { diff --git a/dictionary-reader/src/main/java/org/apache/lucene/morphology/generator/EnglishHeuristicBuilder.java b/dictionary-reader/src/main/java/org/apache/lucene/morphology/generator/EnglishHeuristicBuilder.java index 35c26b2..748b040 100644 --- a/dictionary-reader/src/main/java/org/apache/lucene/morphology/generator/EnglishHeuristicBuilder.java +++ b/dictionary-reader/src/main/java/org/apache/lucene/morphology/generator/EnglishHeuristicBuilder.java @@ -28,7 +28,7 @@ import java.util.HashSet; public class EnglishHeuristicBuilder { public static void main(String[] args) throws IOException { - GrammaReader grammaInfo = new GrammaReader("dictonary/Dicts/Morph/egramtab.tab"); + GrammaReader grammaInfo = new GrammaReader("dictonary/Dicts/Morphology/egramtab.tab"); DictonaryReader dictonaryReader = new DictonaryReader("dictonary/Dicts/SrcMorph/EngSrc/morphs.mrd", new HashSet()); EnglishLetterDecoderEncoder decoderEncoder = new EnglishLetterDecoderEncoder(); diff --git a/dictionary-reader/src/main/java/org/apache/lucene/morphology/generator/RussianHeuristicBuilder.java b/dictionary-reader/src/main/java/org/apache/lucene/morphology/generator/RussianHeuristicBuilder.java index d706be8..e542634 100644 --- a/dictionary-reader/src/main/java/org/apache/lucene/morphology/generator/RussianHeuristicBuilder.java +++ b/dictionary-reader/src/main/java/org/apache/lucene/morphology/generator/RussianHeuristicBuilder.java @@ -27,7 +27,7 @@ import java.util.HashSet; public class RussianHeuristicBuilder { public static void main(String[] args) throws IOException { - GrammaReader grammaInfo = new GrammaReader("dictonary/Dicts/Morph/rgramtab.tab"); + GrammaReader grammaInfo = new GrammaReader("dictonary/Dicts/Morphology/rgramtab.tab"); DictonaryReader dictonaryReader = new DictonaryReader("dictonary/Dicts/SrcMorph/RusSrc/morphs.mrd", new HashSet()); RussianLetterDecoderEncoder decoderEncoder = new RussianLetterDecoderEncoder(); diff --git a/english/src/main/java/org/apache/lucene/morphology/english/EnglishLetterDecoderEncoder.java b/english/src/main/java/org/apache/lucene/morphology/english/EnglishLetterDecoderEncoder.java index e4e9a8a..b0c3501 100644 --- a/english/src/main/java/org/apache/lucene/morphology/english/EnglishLetterDecoderEncoder.java +++ b/english/src/main/java/org/apache/lucene/morphology/english/EnglishLetterDecoderEncoder.java @@ -22,7 +22,6 @@ import org.apache.lucene.morphology.WrongCharaterException; import java.util.ArrayList; -//todo extract supper class for common method with russian letter decoder public class EnglishLetterDecoderEncoder implements LetterDecoderEncoder { public static final int ENGLISH_SMALL_LETTER_OFFSET = 96; static public int SUFFIX_LENGTH = 6; diff --git a/english/src/main/java/org/apache/lucene/morphology/english/EnglishLuceneMorphology.java b/english/src/main/java/org/apache/lucene/morphology/english/EnglishLuceneMorphology.java new file mode 100644 index 0000000..780c5f7 --- /dev/null +++ b/english/src/main/java/org/apache/lucene/morphology/english/EnglishLuceneMorphology.java @@ -0,0 +1,28 @@ +/** + * Copyright 2009 Alexander Kuznetsov + * + * Licensed 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. + */ +package org.apache.lucene.morphology.english; + +import org.apache.lucene.morphology.LuceneMorphology; + +import java.io.IOException; + + +public class EnglishLuceneMorphology extends LuceneMorphology { + + public EnglishLuceneMorphology() throws IOException { + super(EnglishLuceneMorphology.class.getResourceAsStream("/org/apache/lucene/morphology/english/morph.info"), new EnglishLetterDecoderEncoder()); + } +} \ No newline at end of file diff --git a/english/src/main/java/org/apache/lucene/morphology/english/EnglishMorphology.java b/english/src/main/java/org/apache/lucene/morphology/english/EnglishMorphology.java new file mode 100644 index 0000000..6815667 --- /dev/null +++ b/english/src/main/java/org/apache/lucene/morphology/english/EnglishMorphology.java @@ -0,0 +1,28 @@ +/** + * Copyright 2009 Alexander Kuznetsov + * + * Licensed 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. + */ +package org.apache.lucene.morphology.english; + +import org.apache.lucene.morphology.Morphology; + +import java.io.IOException; + + +public class EnglishMorphology extends Morphology { + + public EnglishMorphology() throws IOException { + super(EnglishLuceneMorphology.class.getResourceAsStream("/org/apache/lucene/morphology/english/morph.info"), new EnglishLetterDecoderEncoder()); + } +} diff --git a/english/src/test/java/org/apache/lucene/morphology/english/EnglishLuceneMorphTest.java b/english/src/test/java/org/apache/lucene/morphology/english/EnglishLuceneMorphTest.java index d5c9601..461d1de 100644 --- a/english/src/test/java/org/apache/lucene/morphology/english/EnglishLuceneMorphTest.java +++ b/english/src/test/java/org/apache/lucene/morphology/english/EnglishLuceneMorphTest.java @@ -15,7 +15,7 @@ */ package org.apache.lucene.morphology.english; -import org.apache.lucene.morphology.LuceneMorph; +import org.apache.lucene.morphology.LuceneMorphology; import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat; import org.junit.Before; @@ -29,11 +29,11 @@ import java.util.HashSet; import java.util.Set; public class EnglishLuceneMorphTest { - private LuceneMorph luceneMorph; + private LuceneMorphology luceneMorph; @Before public void setUp() throws IOException { - luceneMorph = new LuceneMorph(this.getClass().getResourceAsStream("/org/apache/lucene/morphology/english/morph.info"), new EnglishLetterDecoderEncoder()); + luceneMorph = new LuceneMorphology(this.getClass().getResourceAsStream("/org/apache/lucene/morphology/english/morph.info"), new EnglishLetterDecoderEncoder()); } @Test diff --git a/morph/src/main/java/org/apache/lucene/morphology/LuceneMorph.java b/morph/src/main/java/org/apache/lucene/morphology/LuceneMorphology.java similarity index 90% rename from morph/src/main/java/org/apache/lucene/morphology/LuceneMorph.java rename to morph/src/main/java/org/apache/lucene/morphology/LuceneMorphology.java index 86e2db5..3c09d44 100644 --- a/morph/src/main/java/org/apache/lucene/morphology/LuceneMorph.java +++ b/morph/src/main/java/org/apache/lucene/morphology/LuceneMorphology.java @@ -23,13 +23,13 @@ import java.util.ArrayList; import java.util.List; -public class LuceneMorph extends Morph { +public class LuceneMorphology extends Morphology { - public LuceneMorph(String fileName, LetterDecoderEncoder decoderEncoder) throws IOException { + public LuceneMorphology(String fileName, LetterDecoderEncoder decoderEncoder) throws IOException { super(fileName, decoderEncoder); } - public LuceneMorph(InputStream inputStream, LetterDecoderEncoder decoderEncoder) throws IOException { + public LuceneMorphology(InputStream inputStream, LetterDecoderEncoder decoderEncoder) throws IOException { super(inputStream, decoderEncoder); } diff --git a/morph/src/main/java/org/apache/lucene/morphology/Morph.java b/morph/src/main/java/org/apache/lucene/morphology/Morphology.java similarity index 92% rename from morph/src/main/java/org/apache/lucene/morphology/Morph.java rename to morph/src/main/java/org/apache/lucene/morphology/Morphology.java index 3c42b31..46257b4 100644 --- a/morph/src/main/java/org/apache/lucene/morphology/Morph.java +++ b/morph/src/main/java/org/apache/lucene/morphology/Morphology.java @@ -21,7 +21,7 @@ import java.util.ArrayList; import java.util.List; -public class Morph { +public class Morphology { protected int[][] separators; protected short[] rulesId; protected Heuristic[][] rules; @@ -29,17 +29,17 @@ public class Morph { protected LetterDecoderEncoder decoderEncoder; - public Morph(String fileName, LetterDecoderEncoder decoderEncoder) throws IOException { + public Morphology(String fileName, LetterDecoderEncoder decoderEncoder) throws IOException { readFromFile(fileName); this.decoderEncoder = decoderEncoder; } - public Morph(InputStream inputStream, LetterDecoderEncoder decoderEncoder) throws IOException { + public Morphology(InputStream inputStream, LetterDecoderEncoder decoderEncoder) throws IOException { readFromInputStream(inputStream); this.decoderEncoder = decoderEncoder; } - public Morph(int[][] separators, short[] rulesId, Heuristic[][] rules, String[] grammaInfo) { + public Morphology(int[][] separators, short[] rulesId, Heuristic[][] rules, String[] grammaInfo) { this.separators = separators; this.rulesId = rulesId; this.rules = rules; diff --git a/morph/src/main/java/org/apache/lucene/morphology/analayzer/MorphlogyAnalayzer.java b/morph/src/main/java/org/apache/lucene/morphology/analayzer/MorphlogyAnalayzer.java index e429b31..fc6c750 100644 --- a/morph/src/main/java/org/apache/lucene/morphology/analayzer/MorphlogyAnalayzer.java +++ b/morph/src/main/java/org/apache/lucene/morphology/analayzer/MorphlogyAnalayzer.java @@ -22,21 +22,21 @@ import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.standard.StandardFilter; import org.apache.lucene.analysis.standard.StandardTokenizer; import org.apache.lucene.morphology.LetterDecoderEncoder; -import org.apache.lucene.morphology.LuceneMorph; +import org.apache.lucene.morphology.LuceneMorphology; import java.io.IOException; import java.io.InputStream; import java.io.Reader; public class MorphlogyAnalayzer extends Analyzer { - private LuceneMorph luceneMorph; + private LuceneMorphology luceneMorph; public MorphlogyAnalayzer(String pathToMorph, LetterDecoderEncoder letterDecoderEncoder) throws IOException { - luceneMorph = new LuceneMorph(pathToMorph, letterDecoderEncoder); + luceneMorph = new LuceneMorphology(pathToMorph, letterDecoderEncoder); } public MorphlogyAnalayzer(InputStream inputStream, LetterDecoderEncoder letterDecoderEncoder) throws IOException { - luceneMorph = new LuceneMorph(inputStream, letterDecoderEncoder); + luceneMorph = new LuceneMorphology(inputStream, letterDecoderEncoder); } public TokenStream tokenStream(String fieldName, Reader reader) { diff --git a/morph/src/main/java/org/apache/lucene/morphology/analayzer/MorphlogyFilter.java b/morph/src/main/java/org/apache/lucene/morphology/analayzer/MorphlogyFilter.java index 251b6fc..0f0076c 100644 --- a/morph/src/main/java/org/apache/lucene/morphology/analayzer/MorphlogyFilter.java +++ b/morph/src/main/java/org/apache/lucene/morphology/analayzer/MorphlogyFilter.java @@ -19,7 +19,7 @@ package org.apache.lucene.morphology.analayzer; import org.apache.lucene.analysis.Token; import org.apache.lucene.analysis.TokenFilter; import org.apache.lucene.analysis.TokenStream; -import org.apache.lucene.morphology.LuceneMorph; +import org.apache.lucene.morphology.LuceneMorphology; import java.io.IOException; import java.util.ArrayList; @@ -27,9 +27,9 @@ import java.util.List; public class MorphlogyFilter extends TokenFilter { - private LuceneMorph luceneMorph; + private LuceneMorphology luceneMorph; - public MorphlogyFilter(TokenStream tokenStream, LuceneMorph luceneMorph) { + public MorphlogyFilter(TokenStream tokenStream, LuceneMorphology luceneMorph) { super(tokenStream); this.luceneMorph = luceneMorph; } diff --git a/russian/src/main/java/org/apache/lucene/morphology/russian/RussianLuceneMorphology.java b/russian/src/main/java/org/apache/lucene/morphology/russian/RussianLuceneMorphology.java new file mode 100644 index 0000000..adeac54 --- /dev/null +++ b/russian/src/main/java/org/apache/lucene/morphology/russian/RussianLuceneMorphology.java @@ -0,0 +1,27 @@ +/** + * Copyright 2009 Alexander Kuznetsov + * + * Licensed 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. + */ +package org.apache.lucene.morphology.russian; + +import org.apache.lucene.morphology.LuceneMorphology; + +import java.io.IOException; + +public class RussianLuceneMorphology extends LuceneMorphology { + + public RussianLuceneMorphology() throws IOException { + super(RussianLuceneMorphology.class.getResourceAsStream("/org/apache/lucene/morphology/english/morph.info"), new RussianLetterDecoderEncoder()); + } +} \ No newline at end of file diff --git a/russian/src/main/java/org/apache/lucene/morphology/russian/RussianMorphology.java b/russian/src/main/java/org/apache/lucene/morphology/russian/RussianMorphology.java new file mode 100644 index 0000000..22b3762 --- /dev/null +++ b/russian/src/main/java/org/apache/lucene/morphology/russian/RussianMorphology.java @@ -0,0 +1,27 @@ +/** + * Copyright 2009 Alexander Kuznetsov + * + * Licensed 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. + */ +package org.apache.lucene.morphology.russian; + +import org.apache.lucene.morphology.Morphology; + +import java.io.IOException; + +public class RussianMorphology extends Morphology { + + public RussianMorphology() throws IOException { + super(RussianMorphology.class.getResourceAsStream("/org/apache/lucene/morphology/english/morph.info"), new RussianLetterDecoderEncoder()); + } +} diff --git a/russian/src/test/java/org/apache/lucene/morphology/russian/RussianLuceneMorphTest.java b/russian/src/test/java/org/apache/lucene/morphology/russian/RussianLuceneMorphTest.java index 291e446..9337521 100644 --- a/russian/src/test/java/org/apache/lucene/morphology/russian/RussianLuceneMorphTest.java +++ b/russian/src/test/java/org/apache/lucene/morphology/russian/RussianLuceneMorphTest.java @@ -15,7 +15,7 @@ */ package org.apache.lucene.morphology.russian; -import org.apache.lucene.morphology.LuceneMorph; +import org.apache.lucene.morphology.LuceneMorphology; import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat; import org.junit.Before; @@ -29,11 +29,11 @@ import java.util.HashSet; import java.util.Set; public class RussianLuceneMorphTest { - private LuceneMorph luceneMorph; + private LuceneMorphology luceneMorph; @Before public void setUp() throws IOException { - luceneMorph = new LuceneMorph(this.getClass().getResourceAsStream("/org/apache/lucene/morphology/russian/morph.info"), new RussianLetterDecoderEncoder()); + luceneMorph = new LuceneMorphology(this.getClass().getResourceAsStream("/org/apache/lucene/morphology/russian/morph.info"), new RussianLetterDecoderEncoder()); } @Test