]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Ngrams/Letters.hs
[FEAT/STEM] implementing Porter lib into Gargantext for English language.
[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 NoImplicitPrelude #-}
15 {-# LANGUAGE OverloadedStrings #-}
16
17 module Gargantext.Ngrams.Letters where
18
19 import qualified Data.Text.Lazy as DTL
20 -- import qualified Data.Text.Lazy.IO as DTLIO
21 import Gargantext.Prelude
22
23
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
28
29 letters' :: DTL.Text -> [DTL.Text]
30 letters' text = DTL.splitOn "#" $ DTL.intersperse '#' text
31
32 letters'' :: DTL.Text -> [DTL.Text]
33 letters'' = DTL.foldr (\ch xs -> DTL.singleton ch : xs) []
34
35