apache / lucene

Apache Lucene open-source search software
https://lucene.apache.org/
Apache License 2.0
2.58k stars 1.01k forks source link

Invalid example in SpellChecker javadoc [LUCENE-7971] #9020

Open asfimport opened 6 years ago

asfimport commented 6 years ago

Hello, in Lucene javadoc for SpellChecker class there is an example of how to use it, however it's incorrect (wrong method signature).

File: lucene/suggest/src/java/org/apache/lucene/search/spell/SpellChecker.java

It should be:

SpellChecker spellchecker = new SpellChecker(spellIndexDirectory);
IndexWriterConfig config = new IndexWriterConfig();
spellchecker.indexDictionary(new LuceneDictionary(my_lucene_reader, a_field), config, true);
spellchecker.indexDictionary(new PlainTextDictionary(new File("myfile.txt")), config, true);
String[] suggestions = spellchecker.suggestSimilar("misspelt", 5);

Instead of:

SpellChecker spellchecker = new SpellChecker(spellIndexDirectory);
spellchecker.indexDictionary(new LuceneDictionary(my_lucene_reader, a_field));
spellchecker.indexDictionary(new PlainTextDictionary(new File("myfile.txt")));
String[] suggestions = spellchecker.suggestSimilar("misspelt", 5);

I'm in the middle of sending pull request on Github. Just wanted to create JIRA ticket so I can reference it in my pull request.


Migrated from LUCENE-7971 by Bartosz Firyn (@sarxos)

asfimport commented 6 years ago

ASF GitHub Bot (migrated from JIRA)

GitHub user sarxos opened a pull request:

https://github.com/apache/lucene-solr/pull/248

Fix invalid javadoc example in SpellChecker

Hello Lucene team.

This pull request is to address [LUCENE-7971](https://issues.apache.org/jira/browse/LUCENE-7971) bug from JIRA.

It is a fix for invalid example in ```SpellChecker``` javadoc. Index dictionary can be done by invoking ```checker.indexDictionary(dictionary, config, true)``` but in javadoc example the ```checker.indexDictionary(dictionary)``` method is used instead, which is wrong, because such method does not exist.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/sarxos/lucene-solr patch-1

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/lucene-solr/pull/248.patch

To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message:

This closes `#248`

commit 5d132c5cdd57f5ade3c7f09b92eb653667775413 Author: Bartosz Firyn <bartoszfiryn@gmail.com> Date: 2017-09-16T11:52:55Z

Fix invalid javadoc example in SpellChecker

This is fix for invalid example in SpellChecker javadoc. Index dictionary can be done by invoking SpellChecker::indexDictionary(Dictionary, IndexWriterConfig, boolean), but in javadoc example the SpellChecker::indexDictionary(Dictionary) method is used instead, which is wrong because such method does not exist.

asfimport commented 6 years ago

Bartosz Firyn (@sarxos) (migrated from JIRA)

Pull request fixing this issue is available: https://github.com/apache/lucene-solr/pull/248