use of peltomaa.sukija.finnish.HVTokenizer in project sukija by ahomansikka.
the class AppTest method test.
private boolean test(String input, String expectedOutput) throws IOException {
Reader r = new StringReader(input);
TokenStream t = new HVTokenizer();
((Tokenizer) t).setReader(r);
t = new VoikkoFilter(t, voikko);
t.reset();
VoikkoAttribute sukijaAtt = t.addAttribute(VoikkoAttribute.class);
CharTermAttribute termAtt = t.addAttribute(CharTermAttribute.class);
while (t.incrementToken()) {
System.out.println("AppTest " + termAtt.toString());
for (int i = 0; i < sukijaAtt.getAnalysis().size(); i++) {
System.out.println(sukijaAtt.getAnalysis(i).get("BASEFORM"));
// VoikkoUtils.printAnalysisResult (sukijaAtt.getAnalysis(i), System.out);
}
System.out.println("");
}
return true;
}
use of peltomaa.sukija.finnish.HVTokenizer in project sukija by ahomansikka.
the class SukijaTest method test.
private boolean test(String input, String expectedOutput) throws IOException {
Reader r = new StringReader(input);
TokenStream t = new HVTokenizer();
((Tokenizer) t).setReader(r);
t = new VoikkoFilter(t, voikko);
t.reset();
VoikkoAttribute sukijaAtt = t.addAttribute(VoikkoAttribute.class);
CharTermAttribute termAtt = t.addAttribute(CharTermAttribute.class);
while (t.incrementToken()) {
System.out.println("sukijaTest " + termAtt.toString());
for (int i = 0; i < sukijaAtt.getAnalysis().size(); i++) {
System.out.println(sukijaAtt.getAnalysis(i).get("BASEFORM"));
// VoikkoUtils.printAnalysisResult (sukijaAtt.getAnalysis(i), System.out);
}
System.out.println("");
}
return true;
}
use of peltomaa.sukija.finnish.HVTokenizer in project sukija by ahomansikka.
the class BaseFormTester method test.
public static void test(Reader reader, Writer writer, Voikko voikko, boolean successOnly) throws IOException {
TokenStream t = new HVTokenizer();
((Tokenizer) t).setReader(reader);
t = new BaseFormFilter(t, voikko, successOnly);
CharTermAttribute termAtt = t.addAttribute(CharTermAttribute.class);
BaseFormAttribute baseFormAtt = t.addAttribute(BaseFormAttribute.class);
FlagsAttribute flagsAtt = t.addAttribute(FlagsAttribute.class);
OriginalWordAttribute originalWordAtt = t.addAttribute(OriginalWordAttribute.class);
try {
t.reset();
while (t.incrementToken()) {
writer.write("Sana: " + originalWordAtt.getOriginalWord() + " | " + termAtt.toString() + " | ");
writer.write(Constants.toString(flagsAtt));
writer.write("\n");
writer.flush();
}
t.end();
} finally {
t.close();
}
}
use of peltomaa.sukija.finnish.HVTokenizer in project sukija by ahomansikka.
the class KeepFilterTester method test.
public static void test(Reader reader, Writer writer, Voikko voikko, CharArraySet wordSet, String from, String to, Suggestion[] suggestion, boolean stopOnSuccess) throws IOException {
Set<String> set = new TreeSet<String>();
TokenStream t = new HVTokenizer();
((Tokenizer) t).setReader(reader);
t = new KeepFilter(t, voikko, wordSet, from, to, suggestion);
CharTermAttribute termAtt = t.addAttribute(CharTermAttribute.class);
BaseFormAttribute baseFormAtt = t.addAttribute(BaseFormAttribute.class);
FlagsAttribute flagsAtt = t.addAttribute(FlagsAttribute.class);
OriginalWordAttribute originalWordAtt = t.addAttribute(OriginalWordAttribute.class);
try {
t.reset();
while (t.incrementToken()) {
writer.write("Sana: " + originalWordAtt.getOriginalWord() + " " + termAtt.toString() + " " + Constants.toString(flagsAtt) + " " + baseFormAtt.getBaseForms().toString() + "\n");
writer.flush();
}
t.end();
} finally {
t.close();
}
}
Aggregations