Back to LanguageTool Homepage - Privacy - Imprint

Adding new functionality to get all words contained in a dictionary


(antonioalonzi85) #1

Hi guys,

I was wondering if it is possible to create a new function that returns all words contained in a dictionary.

It would be a great functionality to use in word games.

Any suggestion how can I achieve that?

I'm having problem to edit the source code.
Do you know where can I find the repository? (I've seen the github repository but it looks to have only 2.4-SNAPSHOT version).
I'm mainly interested to the repository for 2.2 version.

Kind regards
Antonio


(Daniel Naber) #2

You can export a dictionary as described at http://wiki.languagetool.org/developing-a-tagger-dictionary

The LT 2.2 source is not at git because we couldn't move the complete history, but you can find it in SVN at http://svn.code.sf.net/p/languagetool/code/tags/languagetool-2.2/


(antonioalonzi85) #3

Actually I wasn't looking for an export of a dictionary but for a method that I could call to return a list of all words contained into it.

I started looking into the code and I think I arrived into the correct place:
- Speller.isInDictionary();
-- FSATrasversalSearch.match();

The main problem is that I haven't really understood how to look into the FSA.

Any documentation regarding that?


(Daniel Naber) #4

There's code for that in TestTools.testDictionary():

    final Dictionary dictionary = Dictionary.read(JLanguageTool.getDataBroker().getFromResourceDirAsUrl(tagger.getFileName()));

    final DictionaryLookup lookup = new DictionaryLookup(dictionary);
    for (WordData wordData : lookup) { .... }