Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8838777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:05:28+00:00 2026-06-14T10:05:28+00:00

I am trying to implement google’s did you mean feature in java. I found

  • 0

I am trying to implement google’s “did you mean” feature in java.
I found some code on internet saying it works properly, it gets me an error though when trying to run it. I think it has to do with the directory creation, which is the only part of the code I do not exactly understand.

Here is the code, could you give me some help on what’s wrong?
Thanks in advance!

             public static void main(String[] args) throws Exception {
             File dir = new File("C:/Users/Lala");
             Directory directory = FSDirectory.open(dir);

             SpellChecker spellChecker = new SpellChecker(directory);

             spellChecker.indexDictionary(
             new PlainTextDictionary(new File("fulldictionary00.txt")));
             String wordForSuggestions = "hwllo";
             int suggestionsNumber = 5;
             String[] suggestions = spellChecker.
                 suggestSimilar(wordForSuggestions, suggestionsNumber);
             if (suggestions!=null && suggestions.length>0) {
                 for (String word : suggestions) {
                     System.out.println("Did you mean:" + word);
                 }
             }
             else {
                 System.out.println("No suggestions found for word:"+wordForSuggestions);
             }

         }

The file fulldictionary00.txt is a plain text file in the right format.

The error I get though is at line 18:

SpellChecker spellChecker = new SpellChecker(directory);

so it has to do with the directory creation.. I am pasting the error I get just in case any idea accures when you see it.

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/lucene/document/Fieldable at did_you_mean.main(did_you_mean.java:18) Caused by:     
 java.lang.ClassNotFoundException: org.apache.lucene.document.Fieldable 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T10:05:29+00:00Added an answer on June 14, 2026 at 10:05 am

    Just in case that someone else has the same problem, I found a way to solve it!

    First of all, the problem seemed to be at version 4.0.0 of lucene, the one that I downloaded, because a class of a jar file was calling a class in another jar file that had been renamed in this version.

    To fix the problem I just downloaded an older version (3.6.1), which demanded some changes to the existing code. In this version, spellChecker.IndexDictionary() function needs 3 arguments:

    spellChecker.indexDictionary(new PlainTextDictionary(new File("fulldictionary00.txt")),config,false);

    config is an IndexWriterConfig object.

    I hope this’ll help someone with the same problem!
    @ppeterka thanks for the help anyway!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement the simple-linkedinphp library (it's found at http://code.google.com/p/simple-linkedinphp/ ) It runs
since Google translate api will stop working i'm trying to implement some jquery code
I am trying to implement Google Map but I am facing some problem with
I am trying to implement this package http://code.google.com/p/python-progressbar/ when downloading a file like below:
I'm trying to implement google analytics code into our system that is mainly ajax
I am trying to implement Google Cloud Messaging. My internet provider uses dynamic ip
I'm trying to implement the wmd-editor from the google code repository (like the one
I'm trying to implement the 1.6 Mobile Facebook API ( http://code.google.com/p/facebook-actionscript-api/downloads/detail?name=GraphAPI_Mobile_1_6.swc ) into an
I'm trying to implement some Google Maps stuff in .NET for a uni project.
I am trying to implement Rtpsockets like in sipdroid. http://code.google.com/p/sipdroid/source/browse/trunk/src/org/sipdroid/sipua/ui/VideoCamera.java sipdroid is a huge

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.