Name-QuickSearch-0.2.0.0
Safe HaskellNone
LanguageHaskell2010

QuickSearch.Internal.Filter

Synopsis

Documentation

buildTokenPartitions Source #

Arguments

:: (Hashable uid, Eq uid) 
=> [Entry Text uid]

List of entries

-> HashMap Token (HashSet uid)

A map of Token -> [uids]

Given the list of entries to be held by QuickSearch, return a HashMap keyed on tokens from the strings in the entries, where the associated HashMap value is the list of uids of entries containing the token.

getSearchPartition Source #

Arguments

:: (Hashable uid, Eq uid) 
=> Text

Target string

-> HashMap Token (HashSet uid)

HashMap associating tokens with sets of uids

-> HashSet uid

The union of sets of associated uids.

Given a target string and a Token HashMap, return the union of sets of uids associated with the tokens in the target string

wordTokenize Source #

Arguments

:: Text

The target string

-> [Token]

A list of tokens from the target string, casefolded

Turn a Data.Text.Text string into a list of casefolded tokens. Turns most non-Alphanum into spaces and deletes all periods and apostrophes.

>>> wordTokenize ("Jane Smith-Walker, M.D."::T.Text)
["jane", "smith", "walker", "md"]

toTokenizedTuple :: (Hashable uid, Eq uid) => Entry Text uid -> ([Token], uid) Source #

Convert an Entry T.Text uid to a tuple of ([wordTokenize name], uid)

>>> toTokenizedTuple ("Jane Smith-Walker, M.D.", 1)::Entry
(["jane", "smith", "walker", "md"], 1)

newtype Entry name uid Source #

Structure associating a name with its unique identifier

Constructors

Entry (name, uid) 

Instances

Instances details
Bifunctor Entry Source # 
Instance details

Defined in QuickSearch.Internal.Filter

Methods

bimap :: (a -> b) -> (c -> d) -> Entry a c -> Entry b d #

first :: (a -> b) -> Entry a c -> Entry b c #

second :: (b -> c) -> Entry a b -> Entry a c #

(Eq name, Eq uid) => Eq (Entry name uid) Source # 
Instance details

Defined in QuickSearch.Internal.Filter

Methods

(==) :: Entry name uid -> Entry name uid -> Bool #

(/=) :: Entry name uid -> Entry name uid -> Bool #

(Show name, Show uid) => Show (Entry name uid) Source # 
Instance details

Defined in QuickSearch.Internal.Filter

Methods

showsPrec :: Int -> Entry name uid -> ShowS #

show :: Entry name uid -> String #

showList :: [Entry name uid] -> ShowS #

entryName :: Entry name uid -> name Source #

Name accessor for an Entry

entryUID :: Entry name uid -> uid Source #

UID accessor for an Entry

first :: Bifunctor p => (a -> b) -> p a c -> p b c #

Map covariantly over the first argument.

first f ≡ bimap f id

Examples

Expand
>>> first toUpper ('j', 3)
('J',3)
>>> first toUpper (Left 'j')
Left 'J'