]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Ngrams/Letters.hs
[FIS][FIX] Frequent Item Set and fix ngrams extraction test.
[gargantext.git] / src / Gargantext / Ngrams / Letters.hs
1 {-|
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
8 Portability : POSIX
9
10 Sugar to work on letters with Text.
11
12 -}
13
14 {-# LANGUAGE OverloadedStrings #-}
15
16 module Gargantext.Ngrams.Letters where
17
18 import qualified Data.Text.Lazy as DTL
19 -- import qualified Data.Text.Lazy.IO as DTLIO
20 import Gargantext.Prelude
21
22
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
27
28 letters' :: DTL.Text -> [DTL.Text]
29 letters' text = DTL.splitOn "#" $ DTL.intersperse '#' text
30
31 letters'' :: DTL.Text -> [DTL.Text]
32 letters'' = DTL.foldr (\ch xs -> DTL.singleton ch : xs) []
33
34