]> Git — Sourcephile - gargantext.git/blob - src-test/Ngrams/Lang/Fr.hs
[refactoring] add some default extensions to package.yaml
[gargantext.git] / src-test / Ngrams / Lang / Fr.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.Fr where
17
18 import Test.Hspec
19
20 import Gargantext.Prelude
21 import Gargantext.Core (Lang(..))
22 import Gargantext.Text.Ngrams.PosTagging.Parser (extractNgrams, selectNgrams)
23
24 ngramsExtractionTest :: IO ()
25 ngramsExtractionTest = hspec $ do
26 describe "Behavioral tests: ngrams extraction in French Language" $ do
27 it "Groupe : adjectif et nom commun" $ do
28 let textFr = "Le beau texte fut écrit."
29 testFr <- map (selectNgrams FR) <$> (extractNgrams FR) textFr
30 testFr `shouldBe` [[("beau texte","NC","O")]]
31
32 it "Groupe : adjectifs et nom commun" $ do
33 let textFr = "Le beau petit texte fut écrit."
34 testFr <- map (selectNgrams FR) <$> (extractNgrams FR) textFr
35 testFr `shouldBe` [[("beau petit texte","NC","O")]]
36 -- `shouldBe` [[("beau texte","NC","O"),("petit texte","NC","O")]] ?
37
38 it "Groupe : nom commun et adjectif" $ do
39 let textFr = "Le livre blanc fut écrit."
40 testFr <- map (selectNgrams FR) <$> (extractNgrams FR) textFr
41 testFr `shouldBe` [[("livre blanc","NC","O")]]
42
43 it "Groupe : nom commun et adjectifs avec conjonction" $ do
44 let textFr = "Le livre blanc et rouge."
45 testFr <- map (selectNgrams FR) <$> (extractNgrams FR) textFr
46 testFr `shouldBe` [[("livre blanc","NC","O"),("livre rouge","NC","O")]]
47 -- `shouldBe` [[("livre blanc et rouge","N","O")]] ?
48
49 it "Groupe: Nom commun + préposition + Nom commun" $ do
50 let textFr0 = "Le problème du jour est résolu."
51 testFr0 <- map (selectNgrams FR) <$> (extractNgrams FR) textFr0
52 testFr0 `shouldBe` [[("problème du jour","NC","O")]]
53
54 it "Groupe: Nom commun + préposition + déterminant + Nom commun" $ do
55 let textFr0 = "Emmanuel Macron est le président de la France."
56 testFr0 <- map (selectNgrams FR) <$> (extractNgrams FR) textFr0
57 testFr0 `shouldBe` [[("Emmanuel Macron","NPP","PERSON"),("président de la France","NC","LOCATION")]]
58
59
60 it "Groupe: Nom commun + préposition + Nom commun + prép + Nom commun" $ do
61 let textFr1 = "L'heure d'arrivée des coureurs dépend de la météo du jour."
62 testFr1 <- map (selectNgrams FR) <$> (extractNgrams FR) textFr1
63 testFr1 `shouldBe` [[("heure d' arrivée des coureurs","NC","O"),("météo du jour","NC","O")]]
64