2 Module : Gargantext.Ngrams.Letters
3 Description : Ngrams.Letters module
4 Copyright : (c) CNRS, 2017
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
10 Sugar to work on letters with Text.
14 {-# LANGUAGE OverloadedStrings #-}
16 module Gargantext.Ngrams.Letters where
18 import qualified Data.Text.Lazy as DTL
19 -- import qualified Data.Text.Lazy.IO as DTLIO
20 import Gargantext.Prelude
23 -- | /O(n)/ Breaks a 'Text' up into each Text list of chars.
24 -- from slower to faster:
25 letters :: DTL.Text -> [DTL.Text]
26 letters text = DTL.chunksOf 1 text
28 letters' :: DTL.Text -> [DTL.Text]
29 letters' text = DTL.splitOn "#" $ DTL.intersperse '#' text
31 letters'' :: DTL.Text -> [DTL.Text]
32 letters'' = DTL.foldr (\ch xs -> DTL.singleton ch : xs) []