Revision: 10045
http://sourceforge.net/p/languagetool/code/10045
Author: dnaber
Date: 2013-05-05 15:20:58 +0000 (Sun, 05 May 2013)
Log Message:
-----------
web page about using LT as a spell checker
Modified Paths:
--------------
trunk/languagetool/languagetool-language-modules/en/src/test/java/org/languagetool/JLanguageToolTest.java
trunk/website/include/header.php
Added Paths:
-----------
trunk/website/www/java-spell-checker/
trunk/website/www/java-spell-checker/index.php
Modified:
trunk/languagetool/languagetool-language-modules/en/src/test/java/org/languagetool/JLanguageToolTest.java
===================================================================
---
trunk/languagetool/languagetool-language-modules/en/src/test/java/org/languagetool/JLanguageToolTest.java
2013-05-05 14:55:31 UTC (rev 10044)
+++
trunk/languagetool/languagetool-language-modules/en/src/test/java/org/languagetool/JLanguageToolTest.java
2013-05-05 15:20:58 UTC (rev 10045)
@@ -51,6 +51,24 @@
}
}
+ // used on http://languagetool.org/java-spell-checker/
+ public void spellCheckerDemoCodeForHomepage() throws IOException {
+ JLanguageTool langTool = new JLanguageTool(new BritishEnglish());
+ for (Rule rule : langTool.getAllRules()) {
+ if (!rule.isSpellingRule()) {
+ langTool.disableRule(rule.getId());
+ }
+ }
+ List<RuleMatch> matches = langTool.check("A speling error");
+ for (RuleMatch match : matches) {
+ System.out.println("Potential typo at line " +
+ match.getLine() + ", column " +
+ match.getColumn() + ": " + match.getMessage());
+ System.out.println("Suggested correction(s): " +
+ match.getSuggestedReplacements());
+ }
+ }
+
public void testEnglish() throws IOException {
final JLanguageTool tool = new JLanguageTool(new English());
assertEquals(0, tool.check("A test that should not give errors.").size());
Modified: trunk/website/include/header.php
===================================================================
--- trunk/website/include/header.php 2013-05-05 14:55:31 UTC (rev 10044)
+++ trunk/website/include/header.php 2013-05-05 15:20:58 UTC (rev 10045)
@@ -248,7 +248,9 @@
<?php
}
?>
+
<div class="submenuitem"><a
href="http://sourceforge.net/p/languagetool/bugs/">Bug Reports</a></div>
+
<?php
if ($sub_page == "java-api") {
?>
@@ -260,7 +262,21 @@
<?php
}
?>
+
+ <?php
+ if ($sub_page == "java-spell-checker") {
+ ?>
+ <div class="submenuitem activeMenuitem">Java Spell Checker</div>
+ <?php
+ } else {
+ ?>
+ <div class="submenuitem"><a href="<?php print $rootUrl
?>/java-spell-checker/">Java Spell Checker</a></div>
+ <?php
+ }
+ ?>
+
<div class="submenuitem"><a href="<?php print $rootUrl
?>/development/api/">Javadoc</a></div>
+
<?php
if ($sub_page == "http-api") {
?>
@@ -272,6 +288,7 @@
<?php
}
?>
+
<?php
if ($sub_page == "http-server") {
?>
@@ -283,6 +300,7 @@
<?php
}
?>
+
<?php
if ($page == "developer-links") {
?>
Added: trunk/website/www/java-spell-checker/index.php
===================================================================
--- trunk/website/www/java-spell-checker/index.php
(rev 0)
+++ trunk/website/www/java-spell-checker/index.php 2013-05-05 15:20:58 UTC
(rev 10045)
@@ -0,0 +1,65 @@
+<?php
+$page = "development";
+$sub_page = "java-spell-checker";
+$title = "LanguageTool";
+$title2 = "Java-based spell checker";
+$lastmod = "2013-05-05 18:20:00 CET";
+include("../../include/header.php");
+include('../../include/geshi/geshi.php');
+?>
+
+<h2 class="firstpara">Why?</h2>
+
+<p>It's easy to use LanguageTool as a spell checker in your Java projects.
While you can also
+use existing projects like <a
href="https://github.com/dren-dk/HunspellJNA">HunspellJNA</a> or
+<a href="https://github.com/thomas-joiner/HunspellBridJ">HunspellBridJ</a>
+(<a href="http://search.maven.org/#search|ga|1|a%3A%22hunspell-bridj%22">at
Maven Central</a>),
+LanguageTool has some advantages:
+</p>
+
+<ol>
+ <li>It provides spell checking, but adding more powerful checks, including
several grammar checks, is very easy.</li>
+ <li>Our goal is to provide 100% pure Java code, whereas the <a
href="http://hunspell.sourceforge.net/">Hunspell</a>-based
+ alternatives linked above require native code.
+ We're not there yet for all languages - if in doubt, run <tt>mvn
dependency:tree</tt> on your
+ LanguageTool-based Maven project. If the dependencies contain
<tt>hunspell-native-libs</tt>, LanguageTool also
+ uses Hunspell internally for your language(s) and thus also requires
native libraries.</li>
+ <li>Hunspell can be slow when it comes to generating suggestions for
misspelled words. For languages
+ where LanguageTool does not internally use Hunspell (see item 2), it's
faster in generating
+ suggestions.</li>
+ <li>LanguageTool is available at Maven Central and comes with dictionaries
included. Those dictionaries
+ are the Hunspell dictionaries also used for
LibreOffice/OpenOffice.</li>
+</ol>
+
+<h2>How?</h2>
+
+<p>See <a href="../java-api">our Java API page</a> for the Maven
+dependency you need to specify. Then, use code like this to find
+spelling errors in a string:</p>
+
+<div class="xmlrule" style="margin-top:5px">
+ <?php hljava('JLanguageTool langTool = new JLanguageTool(new
BritishEnglish());
+for (Rule rule : langTool.getAllRules()) {
+ if (!rule.isSpellingRule()) {
+ langTool.disableRule(rule.getId());
+ }
+}
+List<RuleMatch> matches = langTool.check("A speling error");
+for (RuleMatch match : matches) {
+ System.out.println("Potential typo at line " +
+ match.getLine() + ", column " +
+ match.getColumn() + ": " + match.getMessage());
+ System.out.println("Suggested correction(s): " +
+ match.getSuggestedReplacements());
+}'); ?>
+</div>
+
+<p>If you want more than just spell checking, just remove the first
<tt>for</tt> loop and
+add a call <tt>langTool.activateDefaultPatternRules()</tt> to activate all
rules.
+See <a href="../development/">our development documentation</a> for how those
rules work.
+Need help? Just ask in <a href="../forum">our forum</a> or <a
href="../developer-links/">on
+the mailing list</a>.</p>
+
+<?php
+include("../../include/footer.php");
+?>
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite
It's a free troubleshooting tool designed for production
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap2
_______________________________________________
Languagetool-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/languagetool-commits