Revision: 9423
http://languagetool.svn.sourceforge.net/languagetool/?rev=9423&view=rev
Author: dnaber
Date: 2013-02-18 23:08:35 +0000 (Mon, 18 Feb 2013)
Log Message:
-----------
re-add more tests from pre-Maven days
Added Paths:
-----------
trunk/languagetool/languagetool-standalone/src/test/java/org/languagetool/rules/bitext/FalseFriendsAsBitextLoaderTest.java
trunk/languagetool/languagetool-standalone/src/test/java/org/languagetool/tagging/ManualTaggerTest.java
trunk/languagetool/languagetool-standalone/src/test/java/org/languagetool/tagging/disambiguation/MultiWordChunkerTest.java
trunk/languagetool/languagetool-standalone/src/test/java/org/languagetool/tools/LanguageIdentifierToolsTest.java
Copied:
trunk/languagetool/languagetool-standalone/src/test/java/org/languagetool/rules/bitext/FalseFriendsAsBitextLoaderTest.java
(from rev 9047,
trunk/JLanguageTool/src/test/java/org/languagetool/rules/bitext/FalseFriendsAsBitextLoaderTest.java)
===================================================================
---
trunk/languagetool/languagetool-standalone/src/test/java/org/languagetool/rules/bitext/FalseFriendsAsBitextLoaderTest.java
(rev 0)
+++
trunk/languagetool/languagetool-standalone/src/test/java/org/languagetool/rules/bitext/FalseFriendsAsBitextLoaderTest.java
2013-02-18 23:08:35 UTC (rev 9423)
@@ -0,0 +1,83 @@
+/* LanguageTool, a natural language style checker
+ * Copyright (C) 2006 Daniel Naber (http://www.danielnaber.de)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+package org.languagetool.rules.bitext;
+
+import junit.framework.TestCase;
+import org.languagetool.AnalyzedSentence;
+import org.languagetool.JLanguageTool;
+import org.languagetool.language.English;
+import org.languagetool.language.Polish;
+import org.languagetool.rules.RuleMatch;
+import org.languagetool.rules.patterns.bitext.BitextPatternRule;
+import org.languagetool.rules.patterns.bitext.FalseFriendsAsBitextLoader;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public class FalseFriendsAsBitextLoaderTest extends TestCase {
+
+ public void testHintsForPolishTranslators() throws IOException,
ParserConfigurationException, SAXException {
+ final Polish polish = new Polish();
+ final English english = new English();
+ final JLanguageTool langTool = new JLanguageTool(english, polish);
+ final JLanguageTool trgTool = new JLanguageTool(polish);
+
+ final FalseFriendsAsBitextLoader ruleLoader = new
FalseFriendsAsBitextLoader();
+ final String name = "/false-friends.xml";
+ final List<BitextPatternRule> rules = ruleLoader.
+ getFalseFriendsAsBitext(name, english, polish);
+
+ assertErrors(1, rules, "This is an absurd.", "To absurd.", langTool,
trgTool);
+ assertErrors(1, rules, "I have to speak to my advocate.", "Muszę
porozmawiać z adwokatem.", langTool, trgTool);
+ assertErrors(1, rules, "This is not actual.", "To nie jest aktualne.",
langTool, trgTool);
+ assertErrors(0, rules, "This is not actual.", "To nie jest rzeczywiste.",
langTool, trgTool);
+ }
+
+ private List<RuleMatch> check(final List<BitextPatternRule> bRules,
+ final String src, final String trg,
+ final JLanguageTool srcTool, final JLanguageTool trgTool) throws
IOException {
+ final List<RuleMatch> allMatches = new ArrayList<RuleMatch>();
+ for (BitextPatternRule bRule : bRules) {
+ final RuleMatch[] matches = match(bRule, src, trg, srcTool, trgTool);
+ if (matches != null) {
+ Collections.addAll(allMatches, matches);
+ }
+ }
+ return allMatches;
+ }
+
+ private RuleMatch[] match(final BitextPatternRule rule, final String src,
final String trg,
+ final JLanguageTool srcLanguageTool,
+ final JLanguageTool trgLanguageTool) throws IOException {
+ final AnalyzedSentence srcText = srcLanguageTool.getAnalyzedSentence(src);
+ final AnalyzedSentence trgText = trgLanguageTool.getAnalyzedSentence(trg);
+ return rule.match(srcText, trgText);
+ }
+
+ private void assertErrors(int errorCount,
+ final List<BitextPatternRule> rules,
+ final String src, final String trg, JLanguageTool srcTool, JLanguageTool
trgTool) throws IOException {
+ final List<RuleMatch> matches = check(rules, src, trg, srcTool, trgTool);
+ assertEquals(errorCount, matches.size());
+ }
+}
Copied:
trunk/languagetool/languagetool-standalone/src/test/java/org/languagetool/tagging/ManualTaggerTest.java
(from rev 9047,
trunk/JLanguageTool/src/test/java/org/languagetool/tagging/ManualTaggerTest.java)
===================================================================
---
trunk/languagetool/languagetool-standalone/src/test/java/org/languagetool/tagging/ManualTaggerTest.java
(rev 0)
+++
trunk/languagetool/languagetool-standalone/src/test/java/org/languagetool/tagging/ManualTaggerTest.java
2013-02-18 23:08:35 UTC (rev 9423)
@@ -0,0 +1,42 @@
+/* LanguageTool, a natural language style checker
+ * Copyright (C) 2007 Daniel Naber (http://www.danielnaber.de)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+package org.languagetool.tagging;
+
+import junit.framework.TestCase;
+import org.languagetool.JLanguageTool;
+
+import java.io.IOException;
+import java.util.Arrays;
+
+public class ManualTaggerTest extends TestCase {
+
+ private static final String MANUAL_DICT_FILENAME = "/de/added.txt";
+
+ public void testManualTagger() throws IOException {
+ final ManualTagger tagger = new
ManualTagger(JLanguageTool.getDataBroker().getFromResourceDirAsStream(MANUAL_DICT_FILENAME));
+ assertNull(tagger.lookup(""));
+ assertNull(tagger.lookup("gibtsnicht"));
+
+ assertEquals("[Ableitung, SUB:NOM:PLU:FEM, Ableitung, SUB:GEN:PLU:FEM,
Ableitung, SUB:DAT:PLU:FEM, Ableitung, SUB:AKK:PLU:FEM]",
+ Arrays.toString(tagger.lookup("Ableitungen")));
+ // lookup is case sensitive:
+ assertNull(tagger.lookup("ableitungen"));
+ }
+
+}
Copied:
trunk/languagetool/languagetool-standalone/src/test/java/org/languagetool/tagging/disambiguation/MultiWordChunkerTest.java
(from rev 9047,
trunk/JLanguageTool/src/test/java/org/languagetool/tagging/disambiguation/MultiWordChunkerTest.java)
===================================================================
---
trunk/languagetool/languagetool-standalone/src/test/java/org/languagetool/tagging/disambiguation/MultiWordChunkerTest.java
(rev 0)
+++
trunk/languagetool/languagetool-standalone/src/test/java/org/languagetool/tagging/disambiguation/MultiWordChunkerTest.java
2013-02-18 23:08:35 UTC (rev 9423)
@@ -0,0 +1,38 @@
+/* LanguageTool, a natural language style checker
+ * Copyright (C) 2011 Daniel Naber (http://www.danielnaber.de)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+package org.languagetool.tagging.disambiguation;
+
+import junit.framework.TestCase;
+import org.languagetool.AnalyzedSentence;
+import org.languagetool.AnalyzedTokenReadings;
+import org.languagetool.JLanguageTool;
+import org.languagetool.language.English;
+
+public class MultiWordChunkerTest extends TestCase {
+
+ public void testDisambiguate() throws Exception {
+ final Disambiguator chunker = new MultiWordChunker("/pl/multiwords.txt");
+ final JLanguageTool lt = new JLanguageTool(new English());
+ final AnalyzedSentence analyzedSentence = lt.getAnalyzedSentence("A
test... More.");
+ final AnalyzedSentence disambiguated =
chunker.disambiguate(analyzedSentence);
+ final AnalyzedTokenReadings[] tokens = disambiguated.getTokens();
+ assertTrue(tokens[4].getReadings().toString().contains("<ELLIPSIS>"));
+ assertTrue(tokens[6].getReadings().toString().contains("</ELLIPSIS>"));
+ }
+}
Copied:
trunk/languagetool/languagetool-standalone/src/test/java/org/languagetool/tools/LanguageIdentifierToolsTest.java
(from rev 9047,
trunk/JLanguageTool/src/test/java/org/languagetool/tools/LanguageIdentifierToolsTest.java)
===================================================================
---
trunk/languagetool/languagetool-standalone/src/test/java/org/languagetool/tools/LanguageIdentifierToolsTest.java
(rev 0)
+++
trunk/languagetool/languagetool-standalone/src/test/java/org/languagetool/tools/LanguageIdentifierToolsTest.java
2013-02-18 23:08:35 UTC (rev 9423)
@@ -0,0 +1,36 @@
+/* LanguageTool, a natural language style checker
+ * Copyright (C) 2011 Michael Bryant
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+package org.languagetool.tools;
+
+import junit.framework.TestCase;
+
+import org.apache.tika.language.LanguageIdentifier;
+
+public class LanguageIdentifierToolsTest extends TestCase {
+
+ public void testAddProfile() throws Exception {
+ LanguageIdentifier.initProfiles();
+ final int numLanguagesBefore =
LanguageIdentifier.getSupportedLanguages().size();
+ assertEquals(18, numLanguagesBefore);
+ LanguageIdentifierTools.addLtProfiles();
+ final int numLanguagesAfter =
LanguageIdentifier.getSupportedLanguages().size();
+ assertNotSame(numLanguagesAfter, numLanguagesBefore);
+ }
+
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
The Go Parallel Website, sponsored by Intel - in partnership with Geeknet,
is your hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials, tech docs,
whitepapers, evaluation guides, and opinion stories. Check out the most
recent posts - join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Languagetool-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/languagetool-commits