Back to LanguageTool Homepage - Privacy - Imprint

Quality of spelling check in Java differs from web interface


(Julian) #1

Hello,

I have written a small sample code to auto-correct a string:

import java.util.List;

import org.languagetool.tools.Tools;
import org.languagetool.JLanguageTool;
import org.languagetool.language.GermanyGerman;
import org.languagetool.language.BritishEnglish;
import org.languagetool.rules.*;

public class Rechtschreibung {

public static void main(String[] args){

	String text = "Fußball";
	try {
	JLanguageTool lt = new JLanguageTool(new GermanyGerman());
            System.out.println(Tools.correctText(text, lt));
	} catch (Exception e) {
		e.printStackTrace();
	}
}	

}

I’m using Gradle in combination with the maven repository 'org.languagetool:language-de:2.9' and 'org.languagetool:language-en:2.9'.

When running the code, languagetool changes "Fußball" to "Funkball", while https://languagetool.org/de/ correctly finds no mistake. When using "Fertigstelln" the first suggestion of the web interface is "Fertigstellen" while my code simply returns "Fertigstelln". It is my understanding that Tools.correctText() should apply the first match.

i checked getDisabledRules() and received an empty set, so all standard rules are being applied. Is the web interface using custom rules/dictionaries? How should I change the code to improve results?

Thanks in advance,
Julian


(Daniel Naber) #2

That's strange, I cannot reproduce that with LT 2.9. What do you get when you add this code?

      System.out.println(lt.check("Fertigstelln"));

      System.out.println(lt.check("Fertigstellen"));
      System.out.println(lt.check("Fußball"));
      System.out.println(lt.check("Handball"));
      System.out.println(lt.check("Handballtest"));

(Julian) #3

Ok, thank you for your answere. Since there was obviously a problem beside the code, i was able to solve the problems:

  1. I had old dependencies in my gradle directory, deleting and redownloading everthing helped.
  2. The encoding of my .java file messed with the "ß", but that was not visible in eclipse. Changing it solved the "Funkball" problem.

Now everthing works fine.

Thank you very much for your help!