New Topic
Results 1 to 3 of 3

Thread: [Python] Simple Spellcheck Program

  1. Whoo's Avatar
    Whoo is offline The Wise One
    • My Website(s)
      twilight.ws ddlrank.com
    • My Statistics
    #1
    8th Jan 2010, 11:46 AM
    This is a simple application that I had to make during the exam today. Basically what it does is do a spell check for 2 or more words. This is done by using Google (the more results your word has, the correcter it is)

    Before you can work with the app below you have to download the xgoogle module, which can be found here.

    Simply extract it, and put your python file (that we are going to make in a bit), in the same place as the location of your xgoogle folder. So do not place it inside the xgoogle folder.

    Here is the code of the spellchecker.py file:
    Code:
    #!/usr/bin/python
    from xgoogle.search import GoogleSearch, SearchError
    import sys
    highest = -1
    winner = ""
    filename = sys.argv[0]
    if sys.argv != "" and len(sys.argv) > 1:
        for word in sys.argv:
            if word != filename:
                try:
                    gs = GoogleSearch(word)
                    gs.results_per_page = 50
                    results = gs.get_results()
                    amount = gs.num_results
                    print "Results for " + word + ": " + str(amount)
                    if(highest <= amount):
                        highest = amount
                        winner = word
                except SearchError, e:
                    print "Search failed: %s" % e
    else:
        input = raw_input('Enter your spellcheck words seperated by a comma:\n')
        words = input.split(",")
        for word in words:
            try:
                gs = GoogleSearch(word)
                gs.results_per_page = 50
                results = gs.get_results()
                amount = gs.num_results
                print "Results for " + word + ": " + str(amount)
                if(highest <= amount):
                    highest = amount
                    winner = word
            except SearchError, e:
                print "Search failed: %s" % e        
    print "And the most likely correct word is: " + winner
    You have 2 options of running this.
    1) run ./spellchecker.py word1 word2
    2)run ./spellchecker.py

    1st option will check word1 and word2 and the 2nd option will ask you to enter a lis tof words, comma seperated

    Hope this could come in use

    EDIT: have a look at this too if you would like to use xgoogle for more features like search engine ranking or w/e
    I can always be contacted by sending a tweet @twilightws

  2. pi0tr3k's Avatar
    • My Website(s)
      eih.bz
    • My Statistics
    #2
    8th Jan 2010, 11:47 AM
    So you have to make a notepda file with .py extension and upload on your server?
    Nice, will try this out Thanks

    S.O.T.W #2 Winner

  3. desiboy's Avatar
    • My Statistics
    #3
    8th Jan 2010, 11:51 AM
    Nice ..
    Good Job !
    Coding Horror Fan
    I don't read PM's frequently .

Similar Threads

  1. NEED HELP ON PYTHON
    By gogg302 in forum Webmaster Discussion - Archive
    Replies: 0
    Last Post: 24th Jun 2011, 10:26 AM
  2. Not Selected for The Program (MEPI- Student Leaders Program)!!
    By DoctorX in forum General Discussion - Archive
    Replies: 0
    Last Post: 9th Feb 2011, 03:29 PM
  3. python (willing to pay $)
    By G_Homie_G in forum Development Area - Archive
    Replies: 0
    Last Post: 22nd Nov 2010, 06:01 PM
  4. Php or Python
    By Mouch in forum Hosting Discussion & Reviews - Archive
    Replies: 5
    Last Post: 15th Feb 2010, 12:46 PM
  5. Need some invoice program source code/or program only
    By Nikolasr in forum Webmaster Discussion - Archive
    Replies: 2
    Last Post: 1st Feb 2010, 09:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •