use of org.languagetool.language.English in project languagetool by languagetool-org.
the class AtomFeedCheckerTest method testCheckManually.
@Ignore("Interactive use only - for testing the 'recent changes' XML we get from the API")
@Test
public void testCheckManually() throws IOException {
AtomFeedChecker atomFeedChecker = new AtomFeedChecker(new English());
CheckResult checkResult = atomFeedChecker.checkChanges(new FileInputStream("/home/dnaber/wiki.xml"));
List<ChangeAnalysis> changeAnalysisList = checkResult.getCheckResults();
for (ChangeAnalysis changeAnalysis : changeAnalysisList) {
System.out.println(changeAnalysis.getTitle());
for (WikipediaRuleMatch match : changeAnalysis.getRemovedMatches()) {
System.out.println(" [-] " + match);
}
for (WikipediaRuleMatch match : changeAnalysis.getAddedMatches()) {
System.out.println(" [+] " + match);
}
System.out.println("----------------------");
}
}
use of org.languagetool.language.English in project languagetool by languagetool-org.
the class JLanguageToolTest method testEnglish.
@Test
public void testEnglish() throws IOException {
//more error-free sentences to deal with possible regressions
if (System.getProperty("disableHardcodedTests") == null) {
JLanguageTool lt = new JLanguageTool(new English());
assertNoError("A test that should not give errors.", lt);
assertNoError("As long as you have hope, a chance remains.", lt);
assertNoError("A rolling stone gathers no moss.", lt);
assertNoError("Hard work causes fitness.", lt);
assertNoError("Gershwin overlays the slow blues theme from section B in the final “Grandioso.”", lt);
assertNoError("Making ingroup membership more noticeable increases cooperativeness.", lt);
assertNoError("Dog mushing is more of a sport than a true means of transportation.", lt);
assertNoError("No one trusts him any more.", lt);
assertNoError("A member of the United Nations since 1992, Azerbaijan was elected to membership in the newly established Human Rights Council by the United Nations General Assembly on May 9, 2006 (the term of office began on June 19, 2006).", lt);
assertNoError("Anatomy and geometry are fused in one, and each does something to the other.", lt);
assertNoError("Certain frogs that lay eggs underground have unpigmented eggs.", lt);
assertNoError("It's a kind of agreement in which each party gives something to the other, Jack said.", lt);
assertNoError("Later, you shall know it better.", lt);
assertNoError("And the few must win what the many lose, for the opposite arrangement would not support markets as we know them at all, and is, in fact, unimaginable.", lt);
assertNoError("He explained his errand, but without bothering much to make it plausible, for he felt something well up in him which was the reason why he had fled the army.", lt);
assertNoError("I think it's better, and it's not a big deal.", lt);
assertOneError("A test test that should give errors.", lt);
assertOneError("I can give you more a detailed description.", lt);
assertTrue(lt.getAllRules().size() > 1000);
assertNoError("The sea ice is highly variable - frozen solid during cold, calm weather and broke...", lt);
assertTrue(lt.getAllRules().size() > 3);
assertOneError("I can give you more a detailed description.", lt);
lt.disableRule("MORE_A_JJ");
assertNoError("I can give you more a detailed description.", lt);
assertOneError("I've go to go.", lt);
lt.disableCategory(Categories.TYPOS.getId());
assertNoError("I've go to go.", lt);
}
}
use of org.languagetool.language.English in project languagetool by languagetool-org.
the class JLanguageToolTest method testWhitespace.
@Test
public void testWhitespace() throws IOException {
JLanguageTool tool = new JLanguageTool(new English());
AnalyzedSentence raw = tool.getRawAnalyzedSentence("Let's do a \"test\", do you understand?");
AnalyzedSentence cooked = tool.getAnalyzedSentence("Let's do a \"test\", do you understand?");
//test if there was a change
assertFalse(raw.equals(cooked));
//see if nothing has been deleted
assertEquals(raw.getTokens().length, cooked.getTokens().length);
int i = 0;
for (AnalyzedTokenReadings atr : raw.getTokens()) {
assertEquals(atr.isWhitespaceBefore(), cooked.getTokens()[i].isWhitespaceBefore());
i++;
}
}
use of org.languagetool.language.English in project languagetool by languagetool-org.
the class JLanguageToolTest method testAnalyzedSentence.
@Test
public void testAnalyzedSentence() throws IOException {
JLanguageTool tool = new JLanguageTool(new English());
//test soft-hyphen ignoring:
assertEquals("<S> This[this/DT,B-NP-singular|E-NP-singular] " + "is[be/VBZ,B-VP] a[a/DT,B-NP-singular] " + "tested[tested/JJ,test/VBD,test/VBN,tested/null,I-NP-singular] " + "sentence[sentence/NN,E-NP-singular].[./.,</S>,O]", tool.getAnalyzedSentence("This is a tested sentence.").toString());
//test paragraph ends adding
assertEquals("<S> </S><P/> ", tool.getAnalyzedSentence("\n").toString());
}
use of org.languagetool.language.English in project languagetool by languagetool-org.
the class JLanguageToolTest method testParagraphRules.
@Test
public void testParagraphRules() throws IOException {
JLanguageTool tool = new JLanguageTool(new English());
//run normally
List<RuleMatch> matches1 = tool.check("(This is an quote.\n It ends in the second sentence.");
assertEquals(2, matches1.size());
//run in a sentence-only mode
List<RuleMatch> matches2 = tool.check("(This is an quote.\n It ends in the second sentence.", false, ParagraphHandling.ONLYNONPARA);
assertEquals(1, matches2.size());
assertEquals("EN_A_VS_AN", matches2.get(0).getRule().getId());
//run in a paragraph mode - single sentence
List<RuleMatch> matches3 = tool.check("(This is an quote.\n It ends in the second sentence.", false, ParagraphHandling.ONLYPARA);
assertEquals(1, matches3.size());
assertEquals("EN_UNPAIRED_BRACKETS", matches3.get(0).getRule().getId());
//run in a paragraph mode - many sentences
List<RuleMatch> matches4 = tool.check("(This is an quote.\n It ends in the second sentence.", true, ParagraphHandling.ONLYPARA);
assertEquals(1, matches4.size());
assertEquals("EN_UNPAIRED_BRACKETS", matches4.get(0).getRule().getId());
}
Aggregations