Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

How to read dictionaries.

Forum
2009-12-18
2013-05-08
  • Just down loaded jortho  and created a project using eclipse and the sample application to verify operation.  I have the code compiled and the application running.  However, no misspellings are shown.  Strongly suspicious that it's because I don't have a dictionary loaded.

    // Load the configuration from the file dictionaries.cnf and

    // use the current locale or the first language as default

    SpellChecker.registerDictionaries( null, null );

        ??'s:
        Am assuming that (null,null) need a path name and dictionary type.  Looking for an example.
        Where should the dictionary be placed?  If there is a preferred location.
        Need clarification on the statement regarding the dictionaries.cnf file.
        dictionary_en.ortho seems to be the correct dictionary.
       

     
  • fl_jelelena
    fl_jelelena
    2009-12-23

    Hi,

    I have the same problem. I figured that only the path to the dictionary file serves as the BaseURL and the actual dictionary filename gets build inside the SpellChecker.registerDictionaries() method. what I don't get is how this BaseURL has to look like if I for example have the dictionaries in a folder "resource/dict" within my project.

    I'd be grateful for any suggestions or examples.

    Cheers,
    Lena

     

  • Anonymous
    2010-07-19

    You are both correct.

    What I observed is that SpellChecker will throw one to three exceptions if it can't find one or more of the three files it needs to setup properly.

    Here is the code I used to test it (on a Mac - your path type may vary):

            try
            {
            File configFile = new File("//Volumes/SomeVolume/Path1/Path2/config/dictionaries.cnf");
           
            boolean exists = configFile.exists();
           
            configFile = new File("config/dictionaries.cnf");
           
            exists = configFile.exists();
           
            URL url = new URL("file",null, "/config");
            url = configFile.toURL();
            SpellChecker.registerDictionaries( url, null );
            }
            catch(MalformedURLException ex)
            {
            ex.printStackTrace(System.out);
            }

    Where you put the config file may vary, but the other files like the dictionary need to be relative to that. I haven't worked out all the details yet, but I will as I need to do this for my app to work correctly.

    The docs are poor in this respect (and some others) - they need to spell this out and give examples.

     
  • i-net software
    i-net software
    2010-07-19

    We have add some samples the API documentation. Here is a copy of it. I hope this make it clearer.

    Samples:
    // Load the configuration and dictionaries from the current working directory and use the current locale or the first language as default
    SpellChecker.registerDictionaries( null, null );

    // Load the configuration and dictionaries from the sub directory "dict"
    SpellChecker.registerDictionaries( new URL( "file", null, "dict" ), null );

    // Load the configuration and dictionaries from a web server and activate English as language
    SpellChecker.registerDictionaries( new URL( "http://MyWebServer/dictionries/" ), "en" );

    // Load the configuration and dictionaries from the same web location like the applet and use the German dictionary as default
    SpellChecker.registerDictionaries( myApplet.getCodeBase(), "de" );

    // Sample content from a file dictionaries.cnf
    extension=.ortho
    languages=de,en,it,fr,es,ru