import Data.Aeson
import Data.Aeson.Types (toJSONKeyText)
import Data.Map (Map, fromList, lookup)
-import Data.Text (Text, splitOn, pack)
+import Data.Text (Text, splitOn, pack, strip)
import Gargantext.Core.Types (TODO(..))
import Gargantext.Prelude
import Prelude (Functor)
------------------------------------------------------------------------
-- | TODO put it in Gargantext.Core.Text.Ngrams
-data Ngrams = Ngrams { _ngramsTerms :: Text
- , _ngramsSize :: Int
- } deriving (Generic, Show, Eq, Ord)
+data Ngrams = UnsafeNgrams { _ngramsTerms :: Text
+ , _ngramsSize :: Int
+ } deriving (Generic, Show, Eq, Ord)
makeLenses ''Ngrams
instance PGS.ToRow Ngrams where
- toRow (Ngrams t s) = [toField t, toField s]
+ toRow (UnsafeNgrams t s) = [toField t, toField s]
text2ngrams :: Text -> Ngrams
-text2ngrams txt = Ngrams txt $ length $ splitOn " " txt
+text2ngrams txt = UnsafeNgrams txt' $ length $ splitOn " " txt'
+ where
+ txt' = strip txt
-------------------------------------------------------------------------
-- | TODO put it in Gargantext.Core.Text.Ngrams