Back to LanguageTool Homepage - Privacy - Imprint

Different time taken to run the same sentence


(Nishith) #1

Hi,

We are using language tool as dedicated server which runs on our server. We are calling your service from java. It takes almost 3 to 4 sec to find errors in paragraph of 3 sentence. Every time it takes different time to run the same paragraph. Give me some detail about this.

(Daniel Naber) #2

By dedicated server, do you mean you start "java -jar languagetool-server.jar"? What language are you using? Can you post the example paragraphs you're using?


(Nishith) #3

Hi,

We start language tool by writing "java -cp <path>/languagetool-server.jar org.languagetool.server.HTTPServer --port 8081" in terminal. The paragraph i am testing is as follows :

Jobberspark is a plateform driven approach which is used to build resumes. It is being used as mosr recommended software.

We are using "en-US" language. I don't know there is a facility to add screen shot here but i am just pasting the logs generated on the server after executing above paragraph:

2013-12-17 11:09:58 Check done: 119 chars, en-US, null, 895ms
2013-12-17 11:36:50 Check done: 119 chars, en-US, null, 1515ms
2013-12-17 11:37:07 Check done: 119 chars, en-US, null, 537ms
2013-12-17 11:44:07 Check done: 119 chars, en-US, null, 12048ms
2013-12-17 12:08:36 Check done: 119 chars, en-US, null, 1916ms
2013-12-17 12:09:26 Check done: 119 chars, en-US, null, 532ms
2013-12-17 14:09:48 Check done: 119 chars, en-US, null, 26587ms

Waiting for your response.

This is being tested in localhost and we are afraid that if localhost with only one request at a time taking this much time to respond then what will the case when we use this on live system..

Waiting for your reply.


(Daniel Naber) #4

What client are you using to access the server, a common web browser? Using curl, I cannot reproduce the problem. The log look like this:

2013-12-17 13:58:29 Check done: 121 chars, en-US, null, 180ms
2013-12-17 13:59:02 Check done: 121 chars, en-US, null, 199ms
2013-12-17 13:59:04 Check done: 121 chars, en-US, null, 205ms
2013-12-17 14:00:31 Check done: 121 chars, en-US, null, 214ms

Are you sure it's not a problem with machine load, i.e. the server becoming slow because it has so much other stuff to do? Does it help if you give the process more memory by starting it with "java -Xmx500m -cp ..." (or other numbers instead of 500)?


(Nishith) #5

Hi,

Our backend is written in java using springs-hibernate framework. Java code calls language tool server. We are using jetty server which is running on port 8080 and language tool is running on 8081. I am pasting here java code which calls language tool.

urlToCall = "http://localhost:8081/?language=en-US&text="
+ URLEncoder.encode(decodedString, "UTF-8");

DocumentBuilderFactory factory = DocumentBuilderFactory
.newInstance();
DocumentBuilder builder;
Document document = null;
try {
builder = factory.newDocumentBuilder();
document = builder.parse(urlToCall); // parse XML returned from
// language tool
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


(Daniel Naber) #6

Your call would not work once the texts become longer, as the length of GET requests is limited. Anyway, I'm not sure what the problem is but I suggest you either debug this yourself by adding time statements to see where the time is actually spend (the code is in LanguageToolHttpHandler.java). You could also use a profiler like VisualVm.

The other solution is to just call LT directly - as you're in Java code this seems easier than parsing the XML. It's documented at http://wiki.languagetool.org/java-api.


(Nishith) #7

We have tried to use LT directly as you replied at last. We have imported languagetool-2.0.1.jar file and try to run the example given at http://wiki.languagetool.org/java-api. But i am getting exception like this:

Exception in thread "main" java.lang.NoClassDefFoundError: morfologik/stemming/IStemmer
at org.languagetool.language.English.getTagger(English.java:91)
at org.languagetool.JLanguageTool.(JLanguageTool.java:197)
at org.languagetool.JLanguageTool.(JLanguageTool.java:167)
at AbC.main(AbC.java:9)
Caused by: java.lang.ClassNotFoundException: morfologik.stemming.IStemmer
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
... 4 more

What could be the issue. I have downloaded jar file from http://search.maven.org/#search|ga|1|languagetool - first one.


(Daniel Naber) #8

You need more than just one JAR file, quoting the page: "If you don't use Maven, download the stand-alone ZIP instead. You will need the JAR files and everything in the org directory in your classpath". Also, please use latest version (2.3, or 2.3.1 in Maven) instead of 2.0.1.


(Nishith) #9

Hi,

I using language tool as JAVA API. I have copied the example you have provided on http://wiki.languagetool.org/java-api. Now I want context, errorlength which i was getting using XML earlier when used as HTTP SERVER. I want only four parameters from language tool : ,,,. Message i am getting using match.getMessage() but other three parameters is not accessible when used as JAVA API but are accessible by parsing XML.

What to do to access above parameters?


(Daniel Naber) #10

Each RuleMatch has a getFromPos() and getToPos() method. You can use these as parameters for ContextTools.getContext() (http://languagetool.org/development/api/org/languagetool/tools/ContextTools.html) to get the context.