text-compression 0.1.0.17 → 0.1.0.18
raw patch · 3 files changed
+74/−6 lines, 3 filesPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
API changes (from Hackage documentation)
+ Data.FMIndex: bytestringPCFMIndexLocate :: ByteString -> ByteString -> FMIndexB -> LIntB
+ Data.FMIndex: textPCFMIndexLocate :: Text -> Text -> FMIndexT -> LIntT
Files
- CHANGELOG.md +4/−0
- src/Data/FMIndex.hs +69/−5
- text-compression.cabal +1/−1
CHANGELOG.md view
@@ -72,3 +72,7 @@ ## 0.1.0.17 -- 2022-12-02 * Added FM-index locate operation.++## 0.1.0.18 -- 2022-12-02++* Added additional FM-index functionality for the locate operation.
src/Data/FMIndex.hs view
@@ -77,7 +77,9 @@ textFMIndexCount, -- * Locate operations bytestringFMIndexLocate,- textFMIndexLocate+ bytestringPCFMIndexLocate,+ textFMIndexLocate,+ textPCFMIndexLocate ) where import Data.BWT@@ -560,12 +562,12 @@ fmap (BS.singleton) $ DS.fromList $ BS.unpack input- let bytestringfmindex = bytestringToBWTToFMIndexB input+ let bfmindex = bytestringToBWTToFMIndexB input let patternf = fmap (BSC8.singleton) $ DS.fromList $ BSC8.unpack pat let indices = runST $ locateFMIndexB patternf- bytestringfmindex+ bfmindex fmap (\x -> if | isNothing x -> Nothing | otherwise@@ -574,6 +576,37 @@ DS.index bytestringsa ((fromJust x) - 1) ) indices +-- | Takes a pattern ('ByteString'),+-- an input ('ByteString')+-- and a pre-computed 'FMIndexB' of the input 'ByteString'+-- and returns the indexe(s) of occurences of the pattern+-- using the pre-computed 'FMIndexB'+-- in the input 'ByteString'.+-- The output is not sorted.+bytestringPCFMIndexLocate :: ByteString+ -> ByteString+ -> FMIndexB+ -> LIntB+bytestringPCFMIndexLocate (BSC8.uncons -> Nothing) _ _ = DS.Empty+bytestringPCFMIndexLocate _ (BSC8.uncons -> Nothing) _ = DS.Empty+bytestringPCFMIndexLocate pat input bfmindex = do+ let bytestringsa = createSuffixArray $+ fmap (BS.singleton) $+ DS.fromList $+ BS.unpack input+ let patternf = fmap (BSC8.singleton) $+ DS.fromList $+ BSC8.unpack pat+ let indices = runST $ locateFMIndexB patternf+ bfmindex+ fmap (\x -> if | isNothing x+ -> Nothing+ | otherwise+ -> Just $+ suffixstartpos $+ DS.index bytestringsa ((fromJust x) - 1)+ ) indices+ -- | Takes a pattern ('Text') -- and an input 'Text' -- and returns the indexe(s) of occurences of the pattern@@ -589,12 +622,43 @@ fmap (DText.singleton) $ DS.fromList $ DText.unpack input- let textfmindex = textToBWTToFMIndexT input+ let tfmindex = textToBWTToFMIndexT input let patternf = fmap (DText.singleton) $ DS.fromList $ DText.unpack pat let indices = runST $ locateFMIndexT patternf- textfmindex+ tfmindex+ fmap (\x -> if | isNothing x+ -> Nothing+ | otherwise+ -> Just $+ suffixstartpos $+ DS.index textsa ((fromJust x) - 1)+ ) indices++-- | Takes a pattern ('Text'),+-- an input ('Text')+-- and a pre-computed 'FMIndexT' of the input 'Text+-- and returns the indexe(s) of occurences of the pattern+-- using the pre-computed 'FMIndexT'+-- in the input 'Text'.+-- The output is not sorted.+textPCFMIndexLocate :: Text+ -> Text+ -> FMIndexT+ -> LIntT+textPCFMIndexLocate "" _ _ = DS.Empty+textPCFMIndexLocate _ "" _ = DS.Empty+textPCFMIndexLocate pat input tfmindex = do+ let textsa = createSuffixArray $+ fmap (DText.singleton) $+ DS.fromList $+ DText.unpack input+ let patternf = fmap (DText.singleton) $+ DS.fromList $+ DText.unpack pat+ let indices = runST $ locateFMIndexT patternf+ tfmindex fmap (\x -> if | isNothing x -> Nothing | otherwise
text-compression.cabal view
@@ -20,7 +20,7 @@ -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change-version: 0.1.0.17+version: 0.1.0.18 -- A short (one-line) description of the package. synopsis: A text compression library.