Linux.com

Feature

Extending OpenOffice.org: Checking grammar with LanguageTool

By Dmitri Popov on May 10, 2007 (8:00:00 AM)

Share    Print    Comments   

One of the features that many users dearly miss in OpenOffice.org is a grammar checker. Fortunately, LanguageTool fills the void, adding grammar-checking capabilities to OpenOffice.org.

Although LanguageTool is probably not on par with the grammar checker offered by Microsoft Office or other commercial closed source office suites, it does have one important advantage: you can easily define new grammar rules. The current version of LanguageTools supports several languages besides English, including German, Polish, French, and Dutch. The degree of support varies from language to language; right now the most supported language is Polish (it includes 579 grammar rules), followed by English (221 rules) and Dutch (198 rules). You can see a full list of the supported languages at LanguageTool's Web site.

You can install LanguageTool like any other OpenOffice.org extension. In OpenOffice.org, choose Tools -> Extension Manager, select the My Extensions section, press the Add button, and select the LanguageTool.zip file. Restart OpenOffice.org, and you should see the LanguageTool menu in the Main toolbar.

To check grammar in the currently opened document, choose LanguageTool -> Check Text. The Configuration command allows you to set your native language as well as enable and disable specific grammar rules.

You can use LanguageTool not only as an OpenOffice.org extension, but also as a standalone GUI tool, a command-line tool, and even a service. To launch LanguageTool as a standalone GUI tool, unpack the LanguageTool-x.x.x.zip package and the standalone-libs.zip archive inside of it. Start LanguageTool using by launching the LanguageToolGUI.jar file:

java -jar LanguageToolGUI.jar

LanguageTool's real forte, though, lies in its extensibility. It stores all grammar rules in the rules/xx/grammar.xml file (where xx refers to the actual language code, e.g. en, de, fr), and you can define and add new rules to it. For example, let's say you are having problems with the word "monkey jacket": for some inexplicable reason, you tend to write "wonky jacket" instead. Though the spell checker can't identify these kinds of mistakes (there is nothing wrong with the words "wonky" and "jacket"), it's a job for LanguageTool. To make LanguageTool catch this mistake, you can create a simple grammar rule:

  <rule id="WONKY_JACKET" name="Possible typo 'wonky jacket' (monkey jacket)">
       <pattern>
         <token>wonky</token>
         <token>jacket</token>
       </pattern>
       <message>Did you mean <suggestion>monkey jacket</suggestion>?</message>
       <example type="correct">All the officer were wearing monkey jackets.</example>
       <example type="incorrect">All the officers were wearing<marker>wonky</marker> jackets.</example>
  </rule>

The <pattern> specifies the sequence of words marked with the <token> tag. In this case, the pattern is defined as the word "wonky" followed by the word "jacket." The <message> tag marks the error message, while the <example> tag marks the correct and incorrect examples.

You can find more information on defining grammar rules on LanguageTool's Web site, and you can learn a few tricks by taking a closer look at the predefined rules in the grammar.xml file.

Dmitri Popov is a freelance writer whose articles have appeared in Russian, British, US, German, and Danish computer magazines.

Dmitri Popov is a freelance writer whose articles have appeared in Russian, British, US, German, and Danish computer magazines.

Share    Print    Comments   

Comments

on Extending OpenOffice.org: Checking grammar with LanguageTool

Note: Comments are owned by the poster. We are not responsible for their content.

Grammar checkers cannot really help you

Posted by: Anonymous Coward on May 11, 2007 12:20 AM

The only grammar checker worth anything is your brain. Grammar checkers cannot deliver on their promises, because they can't understand what you're trying to express.

#

Re: Grammar checkers cannot really help you

Posted by: Anonymous [ip: 24.37.240.62] on August 12, 2007 03:32 AM
I guess you never tried to conjugate French. if the noun is masculine or femanine, the adjective has to agree. If it plural or singular, the adjective has to agree.

Then there are verbs and adverbs. And relative pronouns. Microsoft's french grammar and spell checker is just fantastic. I do not require it for my mother tongue.

In fact must individuals use the grammar checker for their second or third language

#

Re(1): Grammar checkers cannot really help you

Posted by: Anonymous [ip: 83.204.140.81] on October 22, 2007 07:10 PM
I've been browsing around this subject. May I re-open it?

My native language is English, but I write a lot in French. With French, the grammar checker in Word picks up numerous simple grammatical blunders though, of course, it doesn't help much with style. French-speaking colleagues also use the grammar checker - errors occur more easily than with English, and readers get upset more easily (it's a religion for some people).

However, the MS checker has 2 big faults: it picks up numerous typographical non-errors, and if you miss out an accent or use an accent wrongly it says the word doesn't exist, and you have to go back to your dictionary.

Conclusion: some languages need grammar checking more than others, and this is indispensable for some users.

Regards

#

Unnecessary

Posted by: Anonymous Coward on May 11, 2007 12:20 AM
Grammar checkers are nothing but a marketing ploy for commercial word processers.

Half the time, they just annoy you with false criticism.

If you are concerned about your grammar, get a copy of <a href="http://www.amazon.com/Elements-Style-Fourth-William-Strunk/dp/020530902X/ref=pd_bbs_2/104-5675579-2131134?ie=UTF8&s=books&qid=1178813707&sr=8-2" title="amazon.com">The Elements of Style by Strunk and White</a amazon.com>. It's a quick read, but it's all you need to write good grammar.

#

Re:Unnecessary

Posted by: Anonymous Coward on May 11, 2007 01:24 PM
Grammar checkers, spelling checkers, autocomplete tools etc. etc. might be completely useless... unless you are pro, who has to produce 10+ pages of text every day, whether its translation, secretarial job, technical writing, or proofread/edit someone elses text.
For pros effective tools are an absolute need. So, please, I do not come telling you whether vi or notepad is better coding tool<nobr> <wbr></nobr>;) and I suggest you keep to stuff you know.

#

Re:Unnecessary

Posted by: Anonymous Coward on May 11, 2007 01:58 PM
If you had any inkling of what you were talking about, you would not group grammar checking with spell check and autocomplete.

The latter two are useful tools. Grammar check is not. At least, not until HAL 9000 comes along.

Finish doing your homework kid.

#

Grammar checkers don't always suck

Posted by: Anonymous Coward on May 11, 2007 01:26 AM
While I hate dealing with grammar checkers, they can (in theory) be useful to non-native speakers. They obviously don't replace simply having advanced knowledge of a language, but they can guide non-native speakers to using good style.

#

My Two cents

Posted by: Anonymous Coward on May 11, 2007 10:41 AM
Just two comments:

- some of the comments above mistake style and grammar. You may write gramatically correct sentences and yet your style may still suck badly.

- you can't judge completeness of language support by directly comparing number of rules. Polish has insanely more complicated grammar than English (I say it as native speaker of Polish) so most likely the most supported language in Language Tool is still English

#

Best-laid Plans

Posted by: Administrator on May 12, 2007 11:24 PM
A rule like this:
"All the officer were wearing monkey jackets."
(in which the subject and verb do not agree in number) points out the need for rule-writers to know what they are doing---and to check for typos without trusting a spell-checker.

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya