]> Git — Sourcephile - gargantext.git/blob - src-test/Ngrams/Lang/Occurrences.hs
[CLEAN] Facet.hs
[gargantext.git] / src-test / Ngrams / Lang / Occurrences.hs
1 {-# LANGUAGE OverloadedStrings #-}
2 {-# LANGUAGE ScopedTypeVariables #-}
3
4 module Ngrams.Lang.Occurrences where
5
6 import Test.Hspec
7 import Control.Exception (evaluate)
8
9
10 import Data.Text (Text)
11
12 import Gargantext.Prelude
13 import Gargantext.Types.Main (Language(..))
14 import Gargantext.Ngrams
15 import Gargantext.Ngrams.Occurrences (parseOccurrences)
16 import Gargantext.Ngrams.Parser (extractNgrams, selectNgrams)
17
18
19 parsersTest = hspec $ do
20 describe "Parser for occurrences" $ do
21
22 let txt = "internet"
23
24 it "returns the result of one parsing" $ do
25 parseOccurrences "internet" "internet" `shouldBe` Right 1
26
27 -- | Context of Text should be toLower
28 it "returns the result of one parsing not case sensitive" $ do
29 let txtCase = "Internet"
30 parseOccurrences txtCase "internet" `shouldBe` Right 1
31
32 it "returns the result of one parsing after space" $ do
33 parseOccurrences txt " internet"
34 `shouldBe` Right 1
35
36 it "returns the result of one parsing after chars" $ do
37 parseOccurrences txt "l'internet"
38 `shouldBe` Right 1
39
40 it "returns the result of multiple parsing" $ do
41 parseOccurrences txt "internet internet of things"
42 `shouldBe` Right 2
43
44 it "returns the result of multiple parsing separated by text" $ do
45 parseOccurrences txt "internet in the internet of things"
46 `shouldBe` Right 2
47
48 it "returns the result of multiple parsing separated by punctuation" $ do
49 parseOccurrences txt "internet. In the internet of things, internet like; internet?"
50 `shouldBe` Right 4
51
52 -- describe "Parser for nodes" $ do
53 -- it "returns the result of one parsing after space" $ do
54 -- occOfCorpus 249509 "sciences" `shouldReturn` 7
55