module Holumbus.Data.PrefixTree.FuzzySearch
where
import Data.Char
import Holumbus.Data.PrefixTree.Core
import Holumbus.Data.PrefixTree.PrefixSet
import Holumbus.Data.PrefixTree.Types
prefixFindCaseWithKey :: Key -> PrefixTree a -> [(Key, a)]
prefixFindCaseWithKey k = toList . cutPx' (singlePS k)
prefixFindNoCaseWithKey :: Key -> PrefixTree a -> [(Key, a)]
prefixFindNoCaseWithKey k = toList . cutPx' (noCaseKeys k)
prefixFindNoCase :: Key -> PrefixTree a -> [a]
prefixFindNoCase k = elems . cutPx' (noCaseKeys k)
lookupNoCase :: Key -> PrefixTree a -> [(Key, a)]
lookupNoCase k = toList . cutAllPx' (noCaseKeys k)
prefixFindCaseWithKeyBF :: Key -> PrefixTree a -> [(Key, a)]
prefixFindCaseWithKeyBF k = toListBF . cutPx' (singlePS k)
prefixFindNoCaseWithKeyBF :: Key -> PrefixTree a -> [(Key, a)]
prefixFindNoCaseWithKeyBF k = toListBF . cutPx' (noCaseKeys k)
lookupNoCaseBF :: Key -> PrefixTree a -> [(Key, a)]
lookupNoCaseBF k = toListBF . cutAllPx' (noCaseKeys k)
noCaseKeys :: Key -> PrefixSet
noCaseKeys = noCasePS . singlePS
noLowerCaseKeys :: Key -> PrefixSet
noLowerCaseKeys = noLowerCasePS . singlePS
noCasePS :: PrefixSet -> PrefixSet
noCasePS = fuzzyCharPS (\ x -> [toUpper x, toLower x])
noLowerCasePS :: PrefixSet -> PrefixSet
noLowerCasePS = fuzzyCharPS (\ x -> [toUpper x, x])
noUmlautPS :: PrefixSet -> PrefixSet
noUmlautPS = fuzzyCharsPS noUmlaut
where
noUmlaut '\196' = ["Ae"]
noUmlaut '\214' = ["Oe"]
noUmlaut '\220' = ["Ue"]
noUmlaut '\228' = ["ae"]
noUmlaut '\246' = ["oe"]
noUmlaut '\252' = ["ue"]
noUmlaut '\223' = ["ss"]
noUmlaut c = [[c]]