]> Git — Sourcephile - gargantext.git/blob - src-test/Ngrams/Lang/Occurrences.hs
ref.
[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 NoImplicitPrelude #-}
15 {-# LANGUAGE OverloadedStrings #-}
16 {-# LANGUAGE ScopedTypeVariables #-}
17
18 module Ngrams.Lang.Occurrences where
19
20 import Test.Hspec
21
22 import Data.Either (Either(Right))
23
24 import Gargantext.Prelude
25 import Gargantext.Text.Metrics.Occurrences (parseOccurrences)
26
27 parsersTest :: IO ()
28 parsersTest = hspec $ do
29 describe "Parser for occurrences" $ do
30
31 let txt = "internet"
32
33 it "returns the result of one parsing" $ do
34 parseOccurrences "internet" "internet" `shouldBe` Right 1
35
36 -- | Context of Text should be toLower
37 it "returns the result of one parsing not case sensitive" $ do
38 let txtCase = "Internet"
39 parseOccurrences txtCase "internet" `shouldBe` Right 1
40
41 it "returns the result of one parsing after space" $ do
42 parseOccurrences txt " internet"
43 `shouldBe` Right 1
44
45 it "returns the result of one parsing after chars" $ do
46 parseOccurrences txt "l'internet"
47 `shouldBe` Right 1
48
49 it "returns the result of multiple parsing" $ do
50 parseOccurrences txt "internet internet of things"
51 `shouldBe` Right 2
52
53 it "returns the result of multiple parsing separated by text" $ do
54 parseOccurrences txt "internet in the internet of things"
55 `shouldBe` Right 2
56
57 it "returns the result of multiple parsing separated by punctuation" $ do
58 parseOccurrences txt "internet. In the internet of things, internet like; internet?"
59 `shouldBe` Right 4
60
61 -- describe "Parser for nodes" $ do
62 -- it "returns the result of one parsing after space" $ do
63 -- occOfCorpus 249509 "sciences" `shouldReturn` 7
64