]> Git — Sourcephile - gargantext.git/blob - src-test/Ngrams/Lang/Fr.hs
Merge branch 'master' into fromRFC3339
[gargantext.git] / src-test / Ngrams / Lang / Fr.hs
1 {-# LANGUAGE OverloadedStrings #-}
2 {-# LANGUAGE ScopedTypeVariables #-}
3 {-# LANGUAGE NoImplicitPrelude #-}
4
5 module Ngrams.Lang.Fr where
6
7 import Test.Hspec
8
9 import Gargantext.Prelude
10 import Gargantext.Types.Main (Language(..))
11 import Gargantext.Ngrams.Parser (extractNgrams, selectNgrams)
12
13 ngramsExtractionTest :: IO ()
14 ngramsExtractionTest = hspec $ do
15 describe "Behavioral tests: ngrams extraction in French Language" $ do
16 it "Groupe : adjectif et nom commun" $ do
17 let textFr = "Le beau texte fut écrit."
18 testFr <- map (selectNgrams FR) <$> (extractNgrams FR) textFr
19 testFr `shouldBe` [[("beau texte","NC","O")]]
20
21 it "Groupe : adjectifs et nom commun" $ do
22 let textFr = "Le beau petit texte fut écrit."
23 testFr <- map (selectNgrams FR) <$> (extractNgrams FR) textFr
24 testFr `shouldBe` [[("beau petit texte","NC","O")]]
25 -- `shouldBe` [[("beau texte","NC","O"),("petit texte","NC","O")]] ?
26
27 it "Groupe : nom commun et adjectif" $ do
28 let textFr = "Le livre blanc fut écrit."
29 testFr <- map (selectNgrams FR) <$> (extractNgrams FR) textFr
30 testFr `shouldBe` [[("livre blanc","NC","O")]]
31
32 it "Groupe : nom commun et adjectifs avec conjonction" $ do
33 let textFr = "Le livre blanc et rouge."
34 testFr <- map (selectNgrams FR) <$> (extractNgrams FR) textFr
35 testFr `shouldBe` [[("livre blanc","N","O"),("livre rouge","N","O")]]
36 -- `shouldBe` [[("livre blanc et rouge","N","O")]] ?
37
38 it "Groupe: Nom commun + préposition + Nom commun" $ do
39 let textFr0 = "Le problème du jour est résolu."
40 testFr0 <- map (selectNgrams FR) <$> (extractNgrams FR) textFr0
41 testFr0 `shouldBe` [[("problème du jour","NC","O")]]
42
43 it "Groupe: Nom commun + préposition + déterminant + Nom commun" $ do
44 let textFr0 = "Emmanuel Macron est le président de la France."
45 testFr0 <- map (selectNgrams FR) <$> (extractNgrams FR) textFr0
46 testFr0 `shouldBe` [[("Emmanuel Macron","NPP","PERSON"),("président de la France","NC","LOCATION")]]
47
48
49 it "Groupe: Nom commun + préposition + Nom commun + prép + Nom commun" $ do
50 let textFr1 = "L'heure d'arrivée des coureurs dépend de la météo du jour."
51 testFr1 <- map (selectNgrams FR) <$> (extractNgrams FR) textFr1
52 testFr1 `shouldBe` [[("heure d' arrivée des coureurs","NC","O"),("météo du jour","NC","O")]]
53