]> Git — Sourcephile - gargantext.git/blob - src-test/Ngrams/Lang/En.hs
[FIX] merge dev-phylo and dev
[gargantext.git] / src-test / Ngrams / Lang / En.hs
1 {-|
2 Module : Ngrams.Lang
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.En where
17
18 {-
19 import Data.List ((!!))
20 import Data.Text (Text)
21
22 import Test.Hspec
23
24 import Gargantext.Prelude
25 import Gargantext.Core (Lang(..))
26
27 -- TODO this import is not used anymore
28 import Gargantext.Text.Ngrams.PosTagging.Parser (extractNgrams, selectNgrams)
29 -- use instead
30 -- import Gargantext.Text.Terms (extractNgramsT)
31
32 ngramsExtractionTest :: IO ()
33 ngramsExtractionTest = hspec $ do
34 describe "Ngrams extraction in English Language" $ do
35 let textTest = [ "Alcoholic extract of Kaempferia galanga was tested for analgesic and antiinflammatory activities in animal models. ", "Three doses, 300 mg/kg, 600 mg/kg and 1200 mg/kg of the plant extract prepared as a suspension in 2 ml of 2% gum acacia were used. ", " Acute and sub acute inflammatory activities were studied in rats by carrageenan induced paw edema and cotton pellet induced granuloma models respectively. ", "In both models, the standard drug used was aspirin 100 mg/kg. ", "Two doses 600 mg/kg and 1200 mg/kg of plant extract exhibited significant (P<0.001) antiinflammatory activity in carrageenan model and cotton pellet granuloma model in comparison to control. ", "Analgesic activity was studied in rats using hot plate and tail-flick models. ", "Codeine 5 mg/kg and vehicle served as standard and control respectively. ", "The two doses of plant extract exhibited significant analgesic activity in tail flick model (P<0.001) and hot plate model (P<0.001) in comparison to control. ", "In conclusion K. galanga possesses antiinflammatory and analgesic activities. "] :: [Text]
36
37 it "\"Of\" seperates two ngrams" $ do
38 t1 <- map (selectNgrams EN) <$> extractNgrams EN (textTest !! 0)
39 t1 `shouldBe` [[("Alcoholic extract of Kaempferia galanga","NN","LOCATION"),("analgesic activities","NN+CC","O"),("antiinflammatory activities","NN+CC","O"),("animal models","NN","O")]]
40
41 it "Tests the conjunction of coordination in two ngrams with its adjectives" $ do
42 t2 <- map (selectNgrams EN) <$> extractNgrams EN (textTest !! 2)
43 t2 `shouldBe` [[("Acute activities","NN+CC","O"),("sub acute inflammatory activities","NN+CC","O"),("rats","NNS","O"),("carrageenan","NN","O"),("paw edema","NN","O"),("cotton pellet","NN","O"),("granuloma models","NN","O")]]
44
45 it "Tests nouns with preposition and determinants" $ do
46 let t = "Donald Trump is president of the United-States of America."
47 t2 <- map (selectNgrams EN) <$> extractNgrams EN t
48 t2 `shouldBe` [[("Donald Trump","NNP","PERSON"),("president of the United-States of America","NN","LOCATION")]]
49
50 -}