use of org.languagetool.language.AmericanEnglish in project languagetool by languagetool-org.
the class SpellingCheckRuleTest method testIgnorePhrases.
@Test
public void testIgnorePhrases() throws IOException {
JLanguageTool langTool = new JLanguageTool(new AmericanEnglish());
assertThat(langTool.check("A test with myfoo mybar").size(), is(2));
for (Rule rule : langTool.getAllActiveRules()) {
if (rule instanceof SpellingCheckRule) {
((SpellingCheckRule) rule).acceptPhrases(Arrays.asList("myfoo mybar", "Myy othertest"));
} else {
langTool.disableRule(rule.getId());
}
}
assertThat(langTool.check("A test with myfoo mybar").size(), is(0));
// the words on their own are not ignored
assertThat(langTool.check("A test with myfoo and mybar").size(), is(2));
assertThat(langTool.check("myfoo mybar here").size(), is(0));
assertThat(langTool.check("Myfoo mybar here").size(), is(0));
assertThat(langTool.check("MYfoo mybar here").size(), is(2));
assertThat(langTool.check("Myy othertest is okay").size(), is(0));
assertThat(langTool.check("And Myy othertest is okay").size(), is(0));
assertThat(langTool.check("But Myy Othertest is not okay").size(), is(2));
assertThat(langTool.check("But myy othertest is not okay").size(), is(2));
}
use of org.languagetool.language.AmericanEnglish in project languagetool by languagetool-org.
the class MorfologikAmericanSpellerRuleTest method testSuggestions.
@Test
public void testSuggestions() throws IOException {
Language language = new AmericanEnglish();
Rule rule = new MorfologikAmericanSpellerRule(TestTools.getMessages("en"), language);
super.testNonVariantSpecificSuggestions(rule, language);
}
use of org.languagetool.language.AmericanEnglish in project languagetool by languagetool-org.
the class JLanguageToolTest method testPositionsWithEnglishTwoLineBreaks.
@Test
public void testPositionsWithEnglishTwoLineBreaks() throws IOException {
JLanguageTool tool = new JLanguageTool(new AmericanEnglish());
List<RuleMatch> matches = tool.check("This sentence.\n\n" + "A sentence. A typoh.");
assertEquals(1, matches.size());
RuleMatch match = matches.get(0);
assertEquals(2, match.getLine());
// TODO: should actually be 15, as in testPositionsWithEnglish()
assertEquals(14, match.getColumn());
}
use of org.languagetool.language.AmericanEnglish in project languagetool by languagetool-org.
the class JLanguageToolTest method testPositionsWithEnglish.
@Test
public void testPositionsWithEnglish() throws IOException {
JLanguageTool tool = new JLanguageTool(new AmericanEnglish());
List<RuleMatch> matches = tool.check("A sentence with no period\n" + "A sentence. A typoh.");
assertEquals(1, matches.size());
RuleMatch match = matches.get(0);
assertEquals(1, match.getLine());
assertEquals(15, match.getColumn());
}
use of org.languagetool.language.AmericanEnglish in project languagetool by languagetool-org.
the class ConfigurationTest method testSaveAndLoadConfigurationForManyLanguages.
@Test
public void testSaveAndLoadConfigurationForManyLanguages() throws Exception {
File tempFile = File.createTempFile(ConfigurationTest.class.getSimpleName(), ".cfg");
createConfiguration(tempFile, new AmericanEnglish());
try {
Configuration conf = new Configuration(tempFile.getParentFile(), tempFile.getName(), new AmericanEnglish());
Set<String> disabledRuleIds = conf.getDisabledRuleIds();
assertTrue(disabledRuleIds.contains("FOO1"));
assertTrue(disabledRuleIds.contains("Foo2"));
assertEquals(2, disabledRuleIds.size());
Set<String> enabledRuleIds = conf.getEnabledRuleIds();
assertTrue(enabledRuleIds.contains("enabledRule"));
assertEquals(1, enabledRuleIds.size());
//now change language
conf = new Configuration(tempFile.getParentFile(), tempFile.getName(), new Belarusian());
disabledRuleIds = conf.getDisabledRuleIds();
assertTrue(disabledRuleIds.isEmpty());
enabledRuleIds = conf.getEnabledRuleIds();
assertTrue(enabledRuleIds.isEmpty());
conf.setEnabledRuleIds(new HashSet<>(Arrays.asList("enabledBYRule")));
conf.saveConfiguration(new Belarusian());
//and back...
conf = new Configuration(tempFile.getParentFile(), tempFile.getName(), new AmericanEnglish());
disabledRuleIds = conf.getDisabledRuleIds();
assertTrue(disabledRuleIds.contains("FOO1"));
assertTrue(disabledRuleIds.contains("Foo2"));
assertEquals(2, disabledRuleIds.size());
enabledRuleIds = conf.getEnabledRuleIds();
assertTrue(enabledRuleIds.contains("enabledRule"));
assertEquals(1, enabledRuleIds.size());
} finally {
tempFile.delete();
}
}
Aggregations