use of peltomaa.sukija.attributes.BaseFormAttribute in project sukija by ahomansikka.
the class SuggestionTester method analyze.
public static void analyze(Reader reader, Writer writer, Voikko voikko, String suggestionFile, boolean stopOnSuccess, boolean useHyphenFilter, TokenStream t) throws IOException {
List<Analysis> analysis = null;
((Tokenizer) t).setReader(reader);
// t = new VoikkoFilter (t, voikko);
t = new SuggestionFilter(t, voikko, suggestionFile, false);
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.attributes.BaseFormAttribute 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);
String orig = "";
TreeSet<String> tset = new TreeSet<String>();
FlagsAttribute flagsA = new FlagsAttributeImpl();
try {
t.reset();
while (t.incrementToken()) {
if (!orig.equals("") && !orig.equals(originalWordAtt.getOriginalWord())) {
writer.write("Sana: " + orig);
if (Constants.hasFlag(flagsA, Constants.FOUND)) {
writer.write(" M " + toString(tset));
}
writer.write("\n");
writer.flush();
tset.clear();
}
orig = originalWordAtt.getOriginalWord();
tset.addAll(baseFormAtt.getBaseForms());
flagsA.setFlags(flagsAtt.getFlags());
}
writer.write("Sana: " + orig);
if (Constants.hasFlag(flagsA, Constants.FOUND)) {
writer.write(" M " + toString(tset));
}
writer.write("\n");
writer.flush();
t.end();
} finally {
t.close();
}
/*
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();
}
*/
}
use of peltomaa.sukija.attributes.BaseFormAttribute 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