#https://github.com/seatgeek/fuzzywuzzy
#https://pypi.python.org/pypi/fuzzywuzzy/0.4.0

from fuzzywuzzy import fuzz
from fuzzywuzzy import process

choices = ["total users",
           "total repositories",
           "total new repositories",
           "total commits",
           "trending now",
           "user commit frequency",
           "top repositories sorted by contributors",
           "top repositories sorted by branches",
           "top repositories sorted by commits",
           "top new repositories sorted by contributors",
           "top new repositories sorted by branches",
           "top new repositories sorted by commits"
           ]

def compare(input):
    #print "comparing ....", input
    r = process.extract(input, choices,limit=5)
    suggestionList = ""
    #Pick top 3 if more than 75% exact
    if (r[0][1] >= 75):
        suggestionList += "<p class=\"text-info\">Did you mean:</p><ul>"
        cnt = 1
        for row in r:
            if (row[1] >= 75 and cnt <= 3):
                cnt = cnt + 1
                suggestionList += "<li><a href=\"/?q=" + str(row[0]) + "&amp;action=Search\">" + str(row[0]) + "</a></li>"
            else:
                break
        suggestionList += "</ul>"
    #Pick one if no exact       
    elif (r[0][1] >= 0):
        suggestionList += "<p class=\"text-info\">Suggestion:</p><a href=\"/?q=" + str(r[0][0]) + "&amp;action=Search\">" + str(r[0][0]) + "</a>"
    
    #print suggestionList
    return suggestionList

@@ -158,336 +158,53 @@
  %5B%22t
-otal users%22,%0A           %22total repositories%22,%0A           %22total new repositories%22,%0A           %22total commits%22,%0A           %22trending now%22,%0A           %22user commit frequency%22,%0A           %22top repositories sorted by contributors%22,%0A           %22top repositories sorted by branches%22,%0A           %22top repositories sorted by commit
+rending now%22,%0A          %22top organization
 s%22,%0A
- 
     
@@ -218,35 +218,8 @@
 top 
-new repositories sorted by 
 cont
@@ -235,34 +235,29 @@
 ,%0A          
- 
 %22top 
-new 
 repositories
@@ -260,31 +260,11 @@
 ries
- sorted by branches
 %22,%0A
- 
     
@@ -294,39 +294,9 @@
 ries
- sorted by commits%22%0A           
+%22
 %5D%0A%0Ad

Modify suggestions