module Data.StringMap.FuzzySearch
( prefixFindCaseWithKey
, prefixFindNoCaseWithKey
, prefixFindNoCase
, lookupNoCase
, lookupNoCaseBF --redundant
, prefixFindCaseWithKeyBF
, prefixFindNoCaseWithKeyBF
, noCaseKeys
, noLowerCaseKeys
, noCasePS
, noLowerCasePS
, noUmlautPS
)
where
import Data.Char
import Data.StringMap.Base
import Data.StringMap.StringSet
prefixFindCaseWithKey :: Key -> StringMap a -> [(Key, a)]
prefixFindCaseWithKey k = toList . cutPx' (singlePS k)
prefixFindNoCaseWithKey :: Key -> StringMap a -> [(Key, a)]
prefixFindNoCaseWithKey k = toList . cutPx' (noCaseKeys k)
prefixFindNoCase :: Key -> StringMap a -> [a]
prefixFindNoCase k = elems . cutPx' (noCaseKeys k)
lookupNoCase :: Key -> StringMap a -> [(Key, a)]
lookupNoCase k = toList . cutAllPx' (noCaseKeys k)
prefixFindCaseWithKeyBF :: Key -> StringMap a -> [(Key, a)]
prefixFindCaseWithKeyBF k = toListBF . cutPx' (singlePS k)
prefixFindNoCaseWithKeyBF :: Key -> StringMap a -> [(Key, a)]
prefixFindNoCaseWithKeyBF k = toListBF . cutPx' (noCaseKeys k)
lookupNoCaseBF :: Key -> StringMap a -> [(Key, a)]
lookupNoCaseBF k = toListBF . cutAllPx' (noCaseKeys k)
noCaseKeys :: Key -> StringSet
noCaseKeys = noCasePS . singlePS
noLowerCaseKeys :: Key -> StringSet
noLowerCaseKeys = noLowerCasePS . singlePS
noCasePS :: StringSet -> StringSet
noCasePS = fuzzyCharPS (\ x -> [toUpper x, toLower x])
noLowerCasePS :: StringSet -> StringSet
noLowerCasePS = fuzzyCharPS (\ x -> [toUpper x, x])
noUmlautPS :: StringSet -> StringSet
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]]