]> Git — Sourcephile - gargantext.git/blob - src-test/Ngrams/Lang/Occurrences.hs
[REFACT] preparing metrics update
[gargantext.git] / src-test / Ngrams / Lang / Occurrences.hs
1 {-|
2 Module : Ngrams.Lang.Occurrences
3 Description :
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
8 Portability : POSIX
9
10 Here is a longer description of this module, containing some
11 commentary with @some markup@.
12 -}
13
14 {-# LANGUAGE ScopedTypeVariables #-}
15
16 module Ngrams.Lang.Occurrences where
17
18 import Test.Hspec
19
20 import Data.Either (Either(Right))
21
22 import Gargantext.Prelude
23 import Gargantext.Text.Metrics.Occurrences (parseOccurrences)
24
25 parsersTest :: IO ()
26 parsersTest = hspec $ do
27 describe "Parser for occurrences" $ do
28
29 let txt = "internet"
30
31 it "returns the result of one parsing" $ do
32 parseOccurrences "internet" "internet" `shouldBe` Right 1
33
34 -- | Context of Text should be toLower
35 it "returns the result of one parsing not case sensitive" $ do
36 let txtCase = "Internet"
37 parseOccurrences txtCase "internet" `shouldBe` Right 1
38
39 it "returns the result of one parsing after space" $ do
40 parseOccurrences txt " internet"
41 `shouldBe` Right 1
42
43 it "returns the result of one parsing after chars" $ do
44 parseOccurrences txt "l'internet"
45 `shouldBe` Right 1
46
47 it "returns the result of multiple parsing" $ do
48 parseOccurrences txt "internet internet of things"
49 `shouldBe` Right 2
50
51 it "returns the result of multiple parsing separated by text" $ do
52 parseOccurrences txt "internet in the internet of things"
53 `shouldBe` Right 2
54
55 it "returns the result of multiple parsing separated by punctuation" $ do
56 parseOccurrences txt "internet. In the internet of things, internet like; internet?"
57 `shouldBe` Right 4
58
59 -- describe "Parser for nodes" $ do
60 -- it "returns the result of one parsing after space" $ do
61 -- occOfCorpus 249509 "sciences" `shouldReturn` 7
62