Group.hs 1.03 KB
Newer Older
1
{-|
2
Module      : Gargantext.Core.Text.Terms.Multi.Group
3 4 5 6 7 8 9 10 11 12 13 14 15
Description : English Grammar rules to group postag tokens.
Copyright   : (c) CNRS, 2017-Present
License     : AGPL + CECILL v3
Maintainer  : team@gargantext.org
Stability   : experimental
Portability : POSIX

Rule-based grammars are computed in this english module in order to
group the tokens into extracted terms.

-}


16
module Gargantext.Core.Text.Terms.Multi.Group (group2)
17 18 19 20 21 22 23 24 25
  where

import Gargantext.Core.Types
import Gargantext.Prelude

-- | FIXME p1 and p2 not really taken into account
group2 :: POS -> POS -> [TokenTag] -> [TokenTag]
group2 p1 p2 (x@(TokenTag _ _ (Just p1') _):y@(TokenTag _ _ (Just p2') _):z) =
  if (p1 == p1') && (p2 == p2')
26 27
     then group2 p1 p2 (x<>y : z)
     -- then (x : y : group2 p1 p2 (x<>y : z))
28 29 30 31 32
     else (x : group2 p1 p2 (y:z))
group2 p1 p2 (x@(TokenTag _ _ Nothing _):y) = (x: group2 p1 p2 y)
group2 _ _ [x@(TokenTag _ _ (Just _) _)] = [x]
group2 p1 p2 (x@(TokenTag _ _ (Just _) _):y@(TokenTag _ _ Nothing _):z) = (x:y: group2 p1 p2 (y:z))
group2 _ _ [] = []