def filterSimilarKeywords(keyword, kwdsIterator):
 seenDict = {}
 kwdSndx = soundex(keyword.encode('ascii', 'ignore'))
 matches = []
 matchesappend = matches.append
 checkContained = False
 if (len(keyword) > 4):
  checkContained = True
 for (movieID, key) in kwdsIterator:
  if (key in seenDict):
   continue
  seenDict[key] = None
  if (checkContained and (keyword in key)):
   matchesappend(key)
   continue
  if (kwdSndx == soundex(key.encode('ascii', 'ignore'))):
   matchesappend(key)
 return _sortKeywords(keyword, matches)

def filterSimilarKeywords ( keyword , kwdsIterator ) : seenDict = { } kwdSndx = soundex ( keyword . encode ( 'ascii' , 'ignore' ) ) matches = [ ] matchesappend = matches . append checkContained = False if ( len ( keyword ) > 4 ) : checkContained = True for ( movieID , key ) in kwdsIterator : if ( key in seenDict ) : continue seenDict [ key ] = None if ( checkContained and ( keyword in key ) ) : matchesappend ( key ) continue if ( kwdSndx == soundex ( key . encode ( 'ascii' , 'ignore' ) ) ) : matchesappend ( key ) return _sortKeywords ( keyword , matches )
return a sorted list of keywords similar to the one given .