LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-10-2016, 11:41 PM   #1
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 1,862

Rep: Reputation: 142Reputation: 142
Need help installing local LanguageTool server for Thunderbird grammar checker


I'm in the process of testing the Grammar Checker 0.6 add-on for Thunderbird 38.6.0 for Windows 7. The add-on's "more information" strongly recommends to "setup [a] local LT server" and references http://nuald.blogspot.com/2009/10/th...extension.html for how to do this. So, I'm game to try, but stuck right out of the gate.

The first suggestion in that link is to "download and start the GUI LanguageTool that works in the server mode via browser:" http://languagetool.org/webstart/web/LanguageTool.jnlp. Not sure what platform the author assumes (the page doesn't say), but when I go to that link from Firefox on Windows I get a dialog to either save the file or open with some program. Hmmm. I guess Windows/Firefox doesn't know what to do with a jnlp file. Neither do I.

The next suggested alternative is to "start the application from the command line:"

$ javaws http://www.languagetool.org/webstart...guageTool.jnlp

The '$' at the front implies Unix, which is OK because I'd like to install this LT server on the Samba file server anyway. But, when I run the command I get the error: "(javaws:25024): Gtk-WARNING **: cannot open display:". I'm guessing that is because the suggested "command line" is actually supposed to be an X-term, right? This server does not have GUI desktops installed as there are no actual users.

Can someone give me a nudge in the right direction to getting this installed on a non-X server, or is that not possible?
 
Old 03-11-2016, 03:04 AM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 16,936
Blog Entries: 10

Rep: Reputation: 5041Reputation: 5041Reputation: 5041Reputation: 5041Reputation: 5041Reputation: 5041Reputation: 5041Reputation: 5041Reputation: 5041Reputation: 5041Reputation: 5041
the addon page's comments suggest that the project is dead. has been for years.

by the way, that .jnlp file is just an xml file, you can look at it in a text editor (but it won't help).
 
Old 03-12-2016, 10:39 AM   #3
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 1,862

Original Poster
Rep: Reputation: 142Reputation: 142
Quote:
Originally Posted by ondoho View Post
the addon page's comments suggest that the project is dead. has been for years. ...
Really, do you think so? The version info page: https://addons.mozilla.org/en-US/thu...etail-relnotes, says, "Released May 17, 2013" which isn't that long ago, but yes, 3 years. The referenced howto: http://nuald.blogspot.com/2009/10/th...extension.html, had 2009 right in the URL, and the author's last blog archive is from 2014. Hmmm. The last comment poster (5/2011) mentioned "http://www.englishsoftware.org/ they offer a similar engine but with NLP (Natural Language Processing) technology built-in." Ever heard of that one?

The LanguageTool page itself says, "English has incomplete support in LanguageTool".

So, what do Thunderbird user do for grammar checking?
 
Old 03-13-2016, 11:36 AM   #4
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 1,862

Original Poster
Rep: Reputation: 142Reputation: 142
The actual LanguageTool project seems to be alive. I downloaded the standalone version from https://languagetool.org/ and it works just fine. I can use the command line and run a file through the checker as:

$ java -jar languagetool-commandline.jar -l en-US fileToCheck

One commentor on the add-on author's site http://nuald.blogspot.com/2009/10/th...extension.html had the same issue as me:

Quote:
ChristianMay 16, 2012 at 12:23 AM

I have personal server (Debian), without X11.
Is it possible to use it at LanguageTool server, and how to configure it with only command line ?

Christian
Reply
Replies

Alexander SlesarevMay 16, 2012 at 9:48 AM

JRE requires X-server, so probably you won't be able to install LT server. I can only recommend to use the external server archeus.ro, if local unavailable, like this: http://archeus.ro/languagetool/check...%20was%20there
As you noted, the jnlp file is xml and doesn't help. Not really sure of what it even does. It does list a lot of jarfiles. Too bad people like to play with all these esoteric ways of installing software

I've installed the add-on and the options show the local server as http://localhost:8081. I think my next step is to just set up a dummy local server page and see what gets passed to that. Maybe I can use the commandline jar with that input ... stay tooned!

Last edited by mfoley; 03-13-2016 at 11:39 AM.
 
Old 03-13-2016, 12:27 PM   #5
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 1,862

Original Poster
Rep: Reputation: 142Reputation: 142
Maybe I need a bit more knowledge about how these URLs are set up (maybe I need to make a new post). The grammar checker does work and maybe I should leave well enough along, but I'd really like to figure out how to set up a local server.

As shown, the local host is http://localhost:8081, which is not yet hooked up. The secondary host is https://languagetool.org:8081/, which works and is where the grammar checking obviously gets run.

For localhost I've created a jsp file and put http://www.myserver.com/lt.jsp as the URL. When I click on the grammar checker, it flashes the local URL then shows "Requesting [en]..." forever.

So, is there a way to trap what parameters are being sent, http://localhost:8081???????, and what is being returned? I'm using Windows, but I could also stage this on linux.
 
Old 03-13-2016, 11:05 PM   #6
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 1,862

Original Poster
Rep: Reputation: 142Reputation: 142
Some progress. I am able to run the LanguageTool at the command line as shown above:

$ java -jar languagetool-commandline.jar --api -l en-US fileToCheck

the --api parameter will output xml. So, I ran the html in my FireFox browser similar to the add-on author's example:

Code:
https://languagetool.org:8081/check?text=the%20rayn%20we%20done%20it&language=en-US
Which gave me:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<matches software="LanguageTool" version="3.3-SNAPSHOT" buildDate="2016-03-12 22:01">
<language shortname="en-US" name="English (US)"/>
<error fromy="0" fromx="0" toy="0" tox="3" ruleId="UPPERCASE_SENTENCE_START" msg="This sentence does not start with an uppercase letter" replacements="The" context="the rayn we done it" contextoffset="0" offset="0" errorlength="3" category="Capitalization" locqualityissuetype="typographical"/>
<error fromy="0" fromx="4" toy="0" tox="8" ruleId="MORFOLOGIK_RULE_EN_US" msg="Possible spelling mistake found" shortmsg="Spelling mistake" replacements="ran#reign#rain#ray#Ray#Ryan#rays#rayon#mayn#ray n" context="the rayn we done it" contextoffset="4" offset="4" errorlength="4" category="Possible Typo" locqualityissuetype="misspelling"/>
<error fromy="0" fromx="12" toy="0" tox="16" ruleId="PRP_PAST_PART" subId="1" msg="Possible grammatical error. You used a past participle without using any required verb ('be' or 'have'). Did you mean 'did'?" replacements="did" context="the rayn we done it" contextoffset="12" offset="12" errorlength="4" category="Grammar" locqualityissuetype="grammar"/>
</matches>
I then ran my JSP file as:

Code:
https://www.mydom.com/lt.jsp?text=the%20rayn%20we%20done%20it&language=en-US
I got:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<matches software="LanguageTool" version="3.2" buildDate="2015-12-29 10:24">
<language shortname="en-US" name="English (US)"/>
<error fromy="0" fromx="0" toy="0" tox="3" ruleId="UPPERCASE_SENTENCE_START" msg="This sentence does not start with an uppercase letter" replacements="The" context="the rayn we done it" contextoffset="0" offset="0" errorlength="3" category="Capitalization" locqualityissuetype="typographical"/>
<error fromy="0" fromx="4" toy="0" tox="8" ruleId="MORFOLOGIK_RULE_EN_US" msg="Possible spelling mistake found" replacements="ran#reign#rain#ray#Ray#Ryan#rays#rayon#mayn#ray n" context="the rayn we done it" contextoffset="4" offset="4" errorlength="4" category="Possible Typo" locqualityissuetype="misspelling"/>
<error fromy="0" fromx="12" toy="0" tox="16" ruleId="PRP_PAST_PART" subId="1"  msg="Possible grammatical error. You used a past participle without using any required verb (&apos;be&apos; or &apos;have&apos;). Did you mean &apos;did&apos;?" replacements="did" context="the rayn we done it" contextoffset="12" offset="12" errorlength="4" category="Grammar" locqualityissuetype="grammar"/>
</matches>
<!--
Time: 1132ms for 1 sentences (0.9 sentences/sec)
-->
This looks pretty darn close to what the official server generates, except my "server" is missing the "shortmsg" attribute and has that commented section at the end.

However, when I specify https://www.mydom.com/lt.jsp as the Thunderbird, Grammar 0.6 add-on server, I get nothing when I tell it do do a grammar check. Well, grammar panel briefly flashes the URL then sits with "Requesting [en] ...". That's it.

Does anyone have any idea of what could be amiss?

Last edited by mfoley; 03-13-2016 at 11:11 PM.
 
Old 03-14-2016, 11:01 AM   #7
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 1,862

Original Poster
Rep: Reputation: 142Reputation: 142
OK, figured out this last problem. In my .jsp program I needed:

Code:
<%@ page contentType="text/xml" %>
So, to summarize the complete solution ...

First, Download the "standalone version" from https://languagetool.org/. This is ready to go using the languagetool-commandline.jar jarfile and can be tested at the Linux command line as shown above. A list of option swicthes can be shown by using some invalid switch such as -h.

The non-commandline stand-alone version seems to be oriented toward workstations with X only. When I ran it, it failed because it couldn't connect to an X display. That's not going to work with Windows. And, I could not get the add-on author's .jnlp or javaws suggestions to work (if anybody ever does, please post howto), so I used the commandline version run from jsp. Here's the source, hope someone finds it useful:

Code:
<%@page trimDirectiveWhitespaces="true"%>
<%-- file: grammar.jsp
   date: 2016-03-13
    $Id: $

  Check grammar using LanguageTools jarfile

 $Log: $
--%>
<%@ include file="include/stdImports.inc" %>
<%@ page contentType="text/xml" %>
<%

// Get URL parameters. lanauage, and text are passed. So can be motherTongue, but we'll ignore that one

Enumeration parameterNames = request.getParameterNames();

String lang = null;
String text = null;
int i = 1;

while (parameterNames.hasMoreElements())
{
    String parameterName = (String) parameterNames.nextElement();
    String parameterValue = (String) request.getParameter(parameterName);

    if (parameterName.equalsIgnoreCase("language"))
        lang = parameterValue;

    else if (parameterName.equalsIgnoreCase("text"))
        text = parameterValue;
}

// Write text to a file

String textPath = getServletContext().getRealPath("") + "tmp/lt";
BufferedWriter textOut = new BufferedWriter(new FileWriter(textPath + ".txt"));

textOut.write(text);
textOut.close();

// Create shell script

textOut = new BufferedWriter(new FileWriter(textPath + ".sh"));

// -d "MORFOLOGIK_RULE_EN_US" - disables spelling mistake rule
// --api - creates the xml output

textOut.write("/usr/lib/java/bin/java -jar /user/util/src/LanguageTool-3.2/languagetool-commandline.jar " +
    "-d \"MORFOLOGIK_RULE_EN_US\" --api -l " + lang + " " + textPath + ".txt > " + textPath +  ".out 2>&1\n");

textOut.close();

runThis("chmod +rx " + textPath + ".sh");       // make executable
runThis(textPath + ".sh");                      // then run command

// Get results

BufferedReader results = new BufferedReader(new FileReader(textPath + ".out"));
String inLine = "";

while ((inLine = results.readLine()) != null)
{
        out.println(inLine.replace("#",", "));
}

results.close();
%>

<%!
static int runThis(String command)
{
    Process p = null;

    try {
        p = Runtime.getRuntime().exec(command);
        p.waitFor();
    } catch ( Exception e) { return p.exitValue(); }

    return 0;
}
%>
The Grammar 0.6 add-on for Thunderbird is not as well integrated as the spelling checker. There is no dialog for choosing replacements and putting them in your message body. You just get a panel with commentary. This is also true when using the default server at https://languagetool.org:8081/. Perhaps a 1.0 add-on could enhance this.

I've disabled the spelling checker rule in LanguageTool because Thunderbird's checker works just fine and, as just mentioned, the grammar add-on just list the words, no substitution dialog -- therefore, why clutter up the grammar comments.

Last edited by mfoley; 03-14-2016 at 11:08 AM.
 
  


Reply

Tags
thunderbird


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Spellchecker OK but no grammar checker working in OO 2 and 3 klarsin Linux - Software 3 05-22-2009 06:58 AM
LXer: Extending OpenOffice.org: Checking grammar with LanguageTool LXer Syndicated Linux News 0 05-10-2007 10:31 PM
Does XFCE 4.2 Mail Checker work w/ Thunderbird local folders? pnellesen Slackware 2 07-25-2005 08:56 AM
Search for grammar checker for linux valar Linux - Software 1 09-06-2003 12:53 PM
Developing a Spelling & Grammar Checker X11 Programming 4 05-26-2002 06:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:26 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration