• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

SpellChecker Again... What am I doing wrong?

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello again. Im workin on a spellchecker and I can't seem to understand why (in my main method) it is not printing out anything. Any reasons or suggestions to what I can do? [I realize it won't be working completely... so far I would think it should show at least the incorrect words... btw thirdgrade.txt is full of spelling errors]
Here is the code...
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Java, arrays start with element 0, and in

public static void main( String[] args )

arg[0] is the first command line argument (not the name of the file as in C/C++).

I think you may have a problem with this line in main():

for (int i = 1; i < args.length ; ++i )

if you are only providing one file name on the command line.
 
Garion Winters
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm... Ill give it a shot. I had been using the run application params or whatever and setting the file names there to test (1st is dictionary, 2nd and any other are files to check)
Worth a look though. Thanks!
 
Garion Winters
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm... still not getting it. Seems I am doing something really wrong. Anyway, any ideas would help, otherwise I will see what I can do.
 
Ranch Hand
Posts: 1067
2
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't see anything jumping out at me here. So I would suggest that you start testing out code to see what is actually not working.
For starters try printing out "dicWords" after you make the call to "spelling.GetWords()", to verify that the tree actually has something in it.
 
Just let me do the talking. Ahem ... so ... you see ... we have this tiny ad...
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic