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