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 NoImplicitPrelude #-}
15 {-# LANGUAGE OverloadedStrings #-}
17 module Gargantext.Ngrams.Letters where
19 import qualified Data.Text.Lazy as DTL
20 -- import qualified Data.Text.Lazy.IO as DTLIO
21 import Gargantext.Prelude
24 -- | /O(n)/ Breaks a 'Text' up into each Text list of chars.
25 -- from slower to faster:
26 letters :: DTL.Text -> [DTL.Text]
27 letters text = DTL.chunksOf 1 text
29 letters' :: DTL.Text -> [DTL.Text]
30 letters' text = DTL.splitOn "#" $ DTL.intersperse '#' text
32 letters'' :: DTL.Text -> [DTL.Text]
33 letters'' = DTL.foldr (\ch xs -> DTL.singleton ch : xs) []