use of org.languagetool.rules.patterns.MatchState in project languagetool by languagetool-org.
the class MatchTest method testSpeller.
@Test
public void testSpeller() throws Exception {
//tests with synthesizer
Match match = getMatch("POS1", "POS2", true);
final Polish polish = new Polish();
MatchState matchState = new MatchState(match, polish.getSynthesizer());
matchState.setToken(getAnalyzedTokenReadings("inflectedform11", "POS1", "Lemma1"));
//getting empty strings, which is what we want
assertEquals("[]", Arrays.toString(matchState.toFinalString(polish)));
// contrast with a speller = false!
match = getMatch("POS1", "POS2", false);
matchState = new MatchState(match, polish.getSynthesizer());
matchState.setToken(getAnalyzedTokenReadings("inflectedform11", "POS1", "Lemma1"));
assertEquals("[(inflectedform11)]", Arrays.toString(matchState.toFinalString(polish)));
//and now a real word - we should get something
match = getMatch("subst:sg:acc.nom:m3", "subst:sg:gen:m3", true);
matchState = new MatchState(match, polish.getSynthesizer());
matchState.setToken(getAnalyzedTokenReadings("AON", "subst:sg:acc.nom:m3", "AON"));
assertEquals("[AON-u]", Arrays.toString(matchState.toFinalString(polish)));
//and now pure text changes
match = getTextMatch("^(.*)$", "$0-u", true);
match.setLemmaString("AON");
matchState = new MatchState(match, polish.getSynthesizer());
assertEquals("[AON-u]", Arrays.toString(matchState.toFinalString(polish)));
match.setLemmaString("batalion");
//should be empty
matchState = new MatchState(match, polish.getSynthesizer());
assertEquals("[]", Arrays.toString(matchState.toFinalString(polish)));
match.setLemmaString("ASEAN");
//and this one not
matchState = new MatchState(match, polish.getSynthesizer());
assertEquals("[ASEAN-u]", Arrays.toString(matchState.toFinalString(polish)));
}
Aggregations