]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Ngrams/Lang/Fr.hs
[FEAT] serving static files for front-end.
[gargantext.git] / src / Gargantext / Ngrams / Lang / Fr.hs
1 {-# LANGUAGE OverloadedStrings #-}
2 {-# LANGUAGE NoImplicitPrelude #-}
3
4 module Gargantext.Ngrams.Lang.Fr (selectNgrams, groupNgrams, textTest)
5 where
6
7 import Gargantext.Prelude
8 import Data.Text (Text)
9 import Data.Monoid ((<>))
10
11 selectNgrams :: [(Text, Text, Text)] -> [(Text, Text, Text)]
12 selectNgrams xs = filter selectNgrams' xs
13 where
14 selectNgrams' (_,"N" ,_ ) = True
15 selectNgrams' (_,"NC" ,_ ) = True
16 selectNgrams' (_,"NN+CC",_ ) = True
17 selectNgrams' (_,_ ,"PERSON" ) = True
18 selectNgrams' (_,_ ,"ORGANIZATION") = True
19 selectNgrams' (_,_ ,"LOCATION" ) = True
20 selectNgrams' (_,_ ,_ ) = False
21
22
23 groupNgrams :: [(Text, Text, Text)] -> [(Text, Text, Text)]
24 groupNgrams [] = []
25
26 --groupNgrams ((_,"DET",_):xs) = groupNgrams xs
27
28 -- "Groupe : nom commun et adjectifs avec conjonction"
29 groupNgrams ((n,"NC",n'):(j1,"ADJ",_):(_,"CC",_):(j2,"ADJ",_):xs) = groupNgrams (n1:n2:xs)
30 where
31 n1 = (n <> " " <> j1, "NC", n')
32 n2 = (n <> " " <> j2, "NC", n')
33
34 -- /!\ sometimes N instead of NC (why?)
35 groupNgrams ((n,"N",n'):(j1,"ADJ",_):(_,"CC",_):(j2,"ADJ",_):xs) = groupNgrams (n1:n2:xs)
36 where
37 n1 = (n <> " " <> j1, "N", n')
38 n2 = (n <> " " <> j2, "N", n')
39
40 -- Groupe : Adjectif + Conjonction de coordination + Adjectif
41 -- groupNgrams ((j1,"ADJ",_):(_,"CC",_):(j2,"ADJ",j2'):xs) = groupNgrams ((j1 <> " " <> j2, "ADJ", j2'):xs)
42
43 -- Groupe : Nom commun + préposition + Nom commun
44 groupNgrams ((n1,"NC",_):(p,"P",_):(n2,"NC",n2'):xs) = groupNgrams ((n1 <> " " <> p <> " " <> n2, "NC", n2'):xs)
45 groupNgrams ((n1,"NC",_):(p,"P",_):(n2,"NPP",n2'):xs) = groupNgrams ((n1 <> " " <> p <> " " <> n2, "NC", n2'):xs)
46 groupNgrams ((n1,"NC",_):(prep,"P",_):(det,"DET",_):(n2,"NPP",n2'):xs) = groupNgrams ((n1 <> " " <> prep <> " " <> det <> " " <> n2, "NC", n2'):xs)
47
48 -- Groupe : Plusieurs adjectifs successifs
49 groupNgrams ((x,"ADJ",_):(y,"ADJ",yy):xs) = groupNgrams ((x <> " " <> y, "ADJ", yy):xs)
50
51 -- Groupe : nom commun et adjectif
52 groupNgrams ((x,"NC",_):(y,"ADJ",yy):xs) = groupNgrams ((x <> " " <> y, "NC", yy):xs)
53 -- /!\ sometimes N instead of NC (why?)
54 groupNgrams ((x,"N",_):(y,"ADJ",yy):xs) = groupNgrams ((x <> " " <> y, "NC", yy):xs)
55
56 -- Groupe : adjectif et nom commun
57 groupNgrams ((x,"ADJ",_):(y,"NC",yy):xs) = groupNgrams ((x <> " " <> y, "NC", yy):xs)
58 -- /!\ sometimes N instead of NC (why?)
59 groupNgrams ((x,"ADJ",_):(y,"N",yy):xs) = groupNgrams ((x <> " " <> y, "NC", yy):xs)
60
61
62 groupNgrams ((x,_,"PERSON"):(y,yy,"PERSON"):xs) = groupNgrams ((x <> " " <> y,yy,"PERSON"):xs)
63 groupNgrams ((x,_,"ORGANIZATION"):(y,yy,"ORGANIZATION"):xs) = groupNgrams ((x <> " " <> y,yy,"ORGANIZATION"):xs)
64
65
66 -- Si aucune des règles précédentes n'est remplie
67 groupNgrams (x:xs) = (x:(groupNgrams xs))
68
69
70 textTest :: [Text]
71 textTest = [ "L'heure d'arrivée des coureurs dépend de la météo du jour."]
72