]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Core/Text/Terms/Multi/Group.hs
Merge branch 'dev-doc-annotation-issue' of ssh://gitlab.iscpif.fr:20022/gargantext...
[gargantext.git] / src / Gargantext / Core / Text / Terms / Multi / Group.hs
1 {-|
2 Module : Gargantext.Core.Text.Terms.Multi.Group
3 Description : English Grammar rules to group postag tokens.
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
8 Portability : POSIX
9
10 Rule-based grammars are computed in this english module in order to
11 group the tokens into extracted terms.
12
13 -}
14
15
16 module Gargantext.Core.Text.Terms.Multi.Group (group2)
17 where
18
19 import Data.Maybe (Maybe(Just))
20
21 import Gargantext.Core.Types
22 import Gargantext.Prelude
23
24 -- | FIXME p1 and p2 not really taken into account
25 group2 :: POS -> POS -> [TokenTag] -> [TokenTag]
26 group2 p1 p2 (x@(TokenTag _ _ (Just p1') _):y@(TokenTag _ _ (Just p2') _):z) =
27 if (p1 == p1') && (p2 == p2')
28 then group2 p1 p2 (x<>y : z)
29 else (x : group2 p1 p2 (y:z))
30 group2 p1 p2 (x@(TokenTag _ _ Nothing _):y) = (x: group2 p1 p2 y)
31 group2 _ _ [x@(TokenTag _ _ (Just _) _)] = [x]
32 group2 p1 p2 (x@(TokenTag _ _ (Just _) _):y@(TokenTag _ _ Nothing _):z) = (x:y: group2 p1 p2 (y:z))
33 group2 _ _ [] = []
34
35
36