Commits

Robert Smith committed b09fcb7

word normalization for portuguese

Comments (0)

Files changed (1)

2d-palindrome.lisp

 
 (defvar *word-table* (make-hash-table))
 
+(defun normalize-word (word)
+  (flet ((strip-accent (char)
+           (case char
+             ((#\Á #\À #\Â #\Ã) #\A)
+             ((#\É #\Ê) #\E)
+             ((#\Í #\Î) #\I)
+             ((#\Ó #\Ô #\Õ) #\O)
+             ((#\Ú #\Û #\Ü) #\U)
+             ((#\Ç) #\C)
+             (otherwise char))))
+    (map 'string #'strip-accent (string-upcase word))))
+
 (defun load-words ()
   (with-open-file (s *words-file* :direction :input)
     (loop :for word := (read-line s nil nil nil) :then (read-line s nil nil nil)
           :for total :from 0
           :for tree := (cl-string-complete:make-completion-tree)
           :while word
-          :do (let ((normalized (string-upcase word)))
+          :do (let ((normalized (normalize-word word)))
                 (unless (cl-string-complete:completion-tree-contains-p tree
                                                                        normalized)
                   (cl-string-complete:completion-tree-add tree normalized)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.