working on better interface
git-svn-id: https://russianmorphology.googlecode.com/svn/trunk@91 d817d54c-26ab-11de-abc9-2f7d1455ff7a
This commit is contained in:
parent
ce2e2daf7b
commit
36012f2943
@ -47,7 +47,7 @@ public class EnglishLuceneMorphTest {
|
|||||||
for (int i = 1; i < qa.length; i++) {
|
for (int i = 1; i < qa.length; i++) {
|
||||||
result.add(qa[i]);
|
result.add(qa[i]);
|
||||||
}
|
}
|
||||||
Set<String> stringList = new HashSet<String>(luceneMorph.getMorhInfo(qa[0]));
|
Set<String> stringList = new HashSet<String>(luceneMorph.getNormalForms(qa[0]));
|
||||||
assertThat(stringList, equalTo(result));
|
assertThat(stringList, equalTo(result));
|
||||||
s = bufferedReader.readLine();
|
s = bufferedReader.readLine();
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ import java.io.BufferedReader;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
public class LuceneMorphology extends MorphologyImpl {
|
public class LuceneMorphology extends MorphologyImpl {
|
||||||
@ -33,17 +32,6 @@ public class LuceneMorphology extends MorphologyImpl {
|
|||||||
super(inputStream, decoderEncoder);
|
super(inputStream, decoderEncoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getMorhInfo(String s) {
|
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
|
||||||
int[] ints = decoderEncoder.encodeToArray(revertWord(s));
|
|
||||||
int ruleId = findRuleId(ints);
|
|
||||||
for (Heuristic h : rules[rulesId[ruleId]]) {
|
|
||||||
result.add(h.transofrmWord(s));
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void readRules(BufferedReader bufferedReader) throws IOException {
|
protected void readRules(BufferedReader bufferedReader) throws IOException {
|
||||||
String s;
|
String s;
|
||||||
Integer amount;
|
Integer amount;
|
||||||
|
@ -20,6 +20,8 @@ import java.util.List;
|
|||||||
|
|
||||||
public interface Morphology {
|
public interface Morphology {
|
||||||
|
|
||||||
List<String> getMorhInfo(String s);
|
List<String> getNormalForms(String s);
|
||||||
|
|
||||||
|
List<String> getMorfInfo(String s);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,17 @@ public class MorphologyImpl implements Morphology {
|
|||||||
return grammaInfo;
|
return grammaInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getMorhInfo(String s) {
|
public List<String> getNormalForms(String s) {
|
||||||
|
ArrayList<String> result = new ArrayList<String>();
|
||||||
|
int[] ints = decoderEncoder.encodeToArray(revertWord(s));
|
||||||
|
int ruleId = findRuleId(ints);
|
||||||
|
for (Heuristic h : rules[rulesId[ruleId]]) {
|
||||||
|
result.add(h.transofrmWord(s));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getMorfInfo(String s) {
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<String>();
|
||||||
int[] ints = decoderEncoder.encodeToArray(revertWord(s));
|
int[] ints = decoderEncoder.encodeToArray(revertWord(s));
|
||||||
int ruleId = findRuleId(ints);
|
int ruleId = findRuleId(ints);
|
||||||
|
@ -56,7 +56,7 @@ public class MorphlogyFilter extends TokenFilter {
|
|||||||
if (!luceneMorph.checkString(nextToken.term())) {
|
if (!luceneMorph.checkString(nextToken.term())) {
|
||||||
return nextToken;
|
return nextToken;
|
||||||
}
|
}
|
||||||
stack = luceneMorph.getMorhInfo(nextToken.term());
|
stack = luceneMorph.getNormalForms(nextToken.term());
|
||||||
index = 0;
|
index = 0;
|
||||||
current = (Token) nextToken.clone();
|
current = (Token) nextToken.clone();
|
||||||
nextToken = createToken(stack.get(index++), current, reusableToken);
|
nextToken = createToken(stack.get(index++), current, reusableToken);
|
||||||
|
@ -47,7 +47,7 @@ public class RussianLuceneMorphTest {
|
|||||||
for (int i = 1; i < qa.length; i++) {
|
for (int i = 1; i < qa.length; i++) {
|
||||||
result.add(qa[i]);
|
result.add(qa[i]);
|
||||||
}
|
}
|
||||||
Set<String> stringList = new HashSet<String>(luceneMorph.getMorhInfo(qa[0]));
|
Set<String> stringList = new HashSet<String>(luceneMorph.getNormalForms(qa[0]));
|
||||||
assertThat(stringList, equalTo(result));
|
assertThat(stringList, equalTo(result));
|
||||||
s = bufferedReader.readLine();
|
s = bufferedReader.readLine();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user