Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-4487

SpellChecker : SpellChecker.indexDictionary : Javadoc incorrect

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.6.1
    • Fix Version/s: None
    • Component/s: modules/spellchecker
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      example code in javadoc seems to be incorrect

      code changes from LUCENE-3557

      means the javadoc

        SpellChecker spellchecker = new SpellChecker(spellIndexDirectory);
        // To index a field of a user index:
        spellchecker.indexDictionary(new LuceneDictionary(my_lucene_reader, a_field));
        // To index a file containing words:
        spellchecker.indexDictionary(new PlainTextDictionary(new File("myfile.txt")));
        String[] suggestions = spellchecker.suggestSimilar("misspelt", 5);
      

      is incorrect i think something like this is better maybe

        SpellChecker spellchecker = new SpellChecker(spellIndexDirectory);
        // To index a field of a user index:
        spellchecker.indexDictionary(new LuceneDictionary(my_lucene_reader, a_field), new IndexWriterConfig(Version.LUCENE_CURRENT, null), false);
        // To index a file containing words:
        spellchecker.indexDictionary(new PlainTextDictionary(new File("myfile.txt")), new IndexWriterConfig(Version.LUCENE_CURRENT, null), false);
        String[] suggestions = spellchecker.suggestSimilar("misspelt", 5);
      

      I'd possibly add something about creating a spellIndexDirectory too, not clear

        Directory spellIndexDirectory = FSDirectory.open("/dev/tmp/SOME_WORKING_DIR");
        SpellChecker spellchecker = new SpellChecker(spellIndexDirectory);
        // To index a field of a user index:
        spellchecker.indexDictionary(new LuceneDictionary(my_lucene_reader, a_field), new IndexWriterConfig(Version.LUCENE_CURRENT, null), false);
        // To index a file containing words:
        spellchecker.indexDictionary(new PlainTextDictionary(new File("myfile.txt")), new IndexWriterConfig(Version.LUCENE_CURRENT, null), false);
        String[] suggestions = spellchecker.suggestSimilar("misspelt", 5);
      

      would of sent a patch but not familiar with how to get access to the apache git repo todo a pull/push

      cheers

      Ant

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                zapper Anthony Mckale
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: