Hi Olivier,<br><br>Great work! Now it's possible to write a full rule converter for the existing LanguageTool modules. I will add your library to the lightproof module with an example/test.<br><br>By the way, I have ported the lightproof modules to Python 3.3, but it seems, there is a registration issue with the bundled dictionary packages with Lightproof components (unfortunately, I couldn't test it yesterday, because the daily build had a missing library problem on Ubuntu), so I will write soon.<br>
<br>Best regards,<br>László<br><div class="gmail_extra"><br><br><div class="gmail_quote">2012/12/4 Olivier R. <span dir="ltr"><<a href="mailto:olivier.noreply@gmail.com" target="_blank">olivier.noreply@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
My connection ended while posting. Here is the full post:<br>
<br>
<br>
Hello everyone,<br>
<br>
## Build indexable binary grammatically tagged dictionaries for<br>
Lightproof/Grammalecte ##<br>
<div><br>
The most important limitation for building a grammar checker with Lightproof<br>
was the lack of grammatically tagged dictionaries. Most of Hunspell<br>
dictionaries, which Lightproof can handle via LibreOffice-UNO, are not<br>
grammatically tagged and cannot be of any help to retrieve morphological<br>
information about words.<br>
<br>
LanguageTool has not this problem since it’s using binary indexable<br>
</div>dictionaries built on huge grammatically tagged lexicons with a finite-state<br>
automaton (fsa) software<br>
(<a href="http://www.eti.pg.gda.pl/katedry/kiw/pracownicy/Jan.Daciuk/personal/fsa.html" target="_blank">http://www.eti.pg.gda.pl/katedry/kiw/pracownicy/Jan.Daciuk/personal/fsa.html</a>)<br>
written in C. Java has a dedicated library to read these binary files.<br>
<br>
But we had nothing such as this in Python.<br>
So I tried to understand how this FSA software in C works, but as I am not a<br>
C expert and as I was upset to depend again on another software, I finally<br>
decided to write my own FSA tool to build such indexable binary<br>
dictionaries.<br>
<br>
Why build such dictionaries? you may ask. Because lexicons which contain<br>
words, lemmas and morphological tags are HUGE, up to several megabytes, they<br>
are not indexable as is and it uses much more memory to make them such. So<br>
the goal is to make them small, compressed, quick to load and to parse, low<br>
memory consuming, indexable, readable without having to uncompress them.<br>
<br>
That’s what I did with Python 3.3.<br>
<br>
I took all lexicons from LanguageTool and I compressed them in binary<br>
indexable dictionaries readable with my own script.<br>
The built dictionaries are not as small as the ones made with the C FSA tool<br>
used by LT, but it’s close enough and there is still room for improvements.<br>
I’ll work on this later.<br>
<br>
Here are the results:<br>
<br>
<br>
These dictionaries are about 5-30 % bigger than the LT ones (and sometimes<br>
surprisingly twice smaller), but anyhow it’s perfectly usable as is.<br>
<br>
Consequences:<br>
— it will be possible to use all existing LT lexicons with Lightproof,<br>
— we will be able to make a stand-alone version of Lightproof/Grammalecte as<br>
it won’t be necessary to use Hunspell anymore,<br>
— we will be able to write automated tests and prevent regressions when<br>
writting/modifying rules.<br>
<br>
<br>
# Lexicons<br>
<br>
Lexicon are simple text document listing all flexions, their stem and their<br>
morphological tags:<br>
<br>
<br>
<br>
Each field is separated with a tabulation.<br>
<br>
With the new tool, lexicons MUST be UTF-8 encoded to be properly converted.<br>
<br>
<br>
# Want to test it?<br>
<br>
The code is written with Python 3.3. License: MPL 2.<br>
<br>
Two files:<br>
— fsa_builder.py      reads all files listed in "_lexicons.list.txt" and<br>
builds binary dictionaries with a specific stemming command.<br>
— fsa_reader.py       reads all files whose name is "[lang].bdic", and if it<br>
finds a test file named "[lang].test.txt" writes results found for each word<br>
in a new file.<br>
<br>
The builder with uncompressed LT lexicons encoded in UTF-8:<br>
<a href="http://dicollecte.free.fr/download/fsa1/pyFSA_builder.7z" target="_blank">http://dicollecte.free.fr/download/fsa1/pyFSA_builder.7z</a> [130 Mb]<br>
<br>
Type:<br>
<br>
<br>
<br>
And let it run. Warning: building dictionaries is slow, as lexicons are<br>
huge. For most langages it takes 1 or 2 minutes for each. But for german,<br>
polish, galician, russian, czech, it tooks 5 to 10 minutes for each, and it<br>
consumes a huge amount of memory. The czech uses up to 6 Gb! You have been<br>
warned. :)<br>
<br>
The dictionary reader with binary dictionaries and test files:<br>
<a href="http://dicollecte.free.fr/download/fsa1/pyFSA_reader.7z" target="_blank">http://dicollecte.free.fr/download/fsa1/pyFSA_reader.7z</a> [11 Mb]<br>
<br>
Type:<br>
<br>
<br>
<br>
Let it run. Count to 1 (or 2 if you have a slow computer). And it’s already<br>
finished. :)<br>
It has read all binary dictionaries, read the test files, and written the<br>
results in other files.<br>
<br>
I’ll try to write a more complete web page about this when I have the time.<br>
I still have to compress it better, for those who might think it’s not<br>
enough.<br>
<br>
<br>
Regards,<br>
Olivier R.<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://nabble.documentfoundation.org/Grammar-checking-Using-LanguageTool-lexicons-with-Lightproof-new-possible-tp4022489p4022495.html" target="_blank">http://nabble.documentfoundation.org/Grammar-checking-Using-LanguageTool-lexicons-with-Lightproof-new-possible-tp4022489p4022495.html</a><br>


<div><div>Sent from the Dev mailing list archive at Nabble.com.<br>
_______________________________________________<br>
LibreOffice mailing list<br>
<a href="mailto:LibreOffice@lists.freedesktop.org" target="_blank">LibreOffice@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/libreoffice" target="_blank">http://lists.freedesktop.org/mailman/listinfo/libreoffice</a><br>
</div></div></blockquote></div><br></div>