+from lucene import StringReader
+
+import enchant
+
+dictionary = enchant.Dict('pl_PL')
+
+
+def did_you_mean(query, tokens):
+    change = {}
+    
+    for t in tokens:
+        print("%s ok? %s, sug: %s" %(t, dictionary.check(t), dictionary.suggest(t)))
+        if not dictionary.check(t):
+            try:
+                change[t] = dictionary.suggest(t)[0]
+            except IndexError:
+                pass
+
+    if change == {}:
+        return None
+
+    for frm, to in change.items():
+        query = query.replace(frm, to)
+        
+    return query