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