Verified Commit af0a0bea authored by Camil Staps's avatar Camil Staps 🙂

Include syntax and ABC instructions in exactName queries

parent ae864aa8
......@@ -397,8 +397,9 @@ filterName :: !String !*CloogleDB -> *CloogleDB
filterName query wrap=:{db,name_ngrams,syntax,abc_instrs}
# (indices,db) = mapSt (uncurry getIndexWithDistance) ('Data.NGramIndex'.search query name_ngrams) db
# db = 'Database.Native'.searchIndices Intersect (catMaybes indices) db
# db = 'Database.Native'.searchWithIndices` syntaxSearch syntax db
# db = 'Database.Native'.searchWithIndices` abcSearch abc_instrs db
#! querycs = [c \\ c <-: query]
# db = 'Database.Native'.searchWithIndices` (syntaxSearch querycs) syntax db
# db = 'Database.Native'.searchWithIndices` (abcSearch query) abc_instrs db
= {wrap & db=db}
where
getIndexWithDistance :: !Index !Int !*(NativeDB CloogleEntry Annotation)
......@@ -418,23 +419,26 @@ where
!]
= (Just (idx, annots), db)
cs = [c \\ c <-: query]
qsize = toReal $ max 1 $ length $ 'Data.NGramIndex'.ngrams NGRAMS_CI NGRAMS_N query
syntaxSearch :: !CloogleEntry -> (!Bool, ![!a!])
syntaxSearch (SyntaxEntry se) = (any (not o isEmpty o flip 'Regex'.match cs) se.syntax_patterns, [!!])
syntaxSearch _ = (False, [!!])
abcSearch :: !CloogleEntry -> (!Bool, ![!a!])
abcSearch (ABCInstructionEntry ie) = (ie.aie_instruction == query, [!!])
abcSearch _ = (False, [!!])
filterExactName :: !String !*CloogleDB -> *CloogleDB
filterExactName n wrap=:{db,name_map}
filterExactName name wrap=:{db,name_map,syntax,abc_instrs}
# db = 'Database.Native'.searchIndices Intersect [(i,[!ExactResult!]) \\ i <- idxs] db
#! namecs = [c \\ c <-: name]
# db = 'Database.Native'.searchWithIndices` (syntaxSearch namecs) syntax db
# db = 'Database.Native'.searchWithIndices` (abcSearch name) abc_instrs db
= {wrap & db=db}
where
idxs = fromMaybe [] $ fmap (\xs->[x\\x<-:xs]) $ get n name_map
idxs = fromMaybe [] $ fmap (\xs->[x\\x<-:xs]) $ get name name_map
syntaxSearch :: ![Char] !CloogleEntry -> (!Bool, ![!Annotation!])
syntaxSearch query (SyntaxEntry se)
= (any (not o isEmpty o flip 'Regex'.match query) se.syntax_patterns, [!!])
syntaxSearch _ _ = (False, [!!])
abcSearch :: !String !CloogleEntry -> (!Bool, ![!Annotation!])
abcSearch query (ABCInstructionEntry ie) = (ie.aie_instruction == query, [!!])
abcSearch _ _ = (False, [!!])
filterUnifying :: !Type !*CloogleDB -> *CloogleDB
filterUnifying t wrap=:{db,types}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment