]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Core/Text/Terms/Multi/RAKE.hs
[FLOW] preparing Hyperdata ToNode instance
[gargantext.git] / src / Gargantext / Core / Text / Terms / Multi / RAKE.hs
1 {-|
2 Module : Gargantext.Core.Text.Terms.Multi.RAKE
3 Description : Rapid automatic keyword extraction (RAKE)
4 Copyright : (c) CNRS, 2017
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
8 Portability : POSIX
9
10 Personal notes for the integration of RAKE in Gargantext.
11
12 RAKE algorithm is a simple, rapid and effective algorithm to extract
13 keywords that is very sensitive to the quality of the stop word list.
14
15 Indeed, the very first step starts from the stop words list to cut the
16 text towards keywords extraction. The conTexT is the sentence level to
17 compute the coccurrences and occurrences which are divided to compute
18 the metric of one word. Multi-words metrics is equal to the sum of the
19 metrics of each word.
20
21 Finally The metrics highlight longer keywords which highly depends of
22 quality of the cut which depends on the quality of the stop word list.
23
24 As a consequence, to improve the effectiveness of RAKE algorithm, I am
25 wondering if some bayesian features could be added to increase stop word
26 list quality in time.
27
28 -}
29
30
31 module Gargantext.Core.Text.Terms.Multi.RAKE (multiterms_rake, select, hardStopList)
32 where
33
34 import GHC.Real (round)
35 import Data.Text (Text)
36 import NLP.RAKE.Text
37
38 import Gargantext.Core.Text.Samples.EN (stopList)
39 import Gargantext.Prelude
40
41 select :: Double -> [a] -> [a]
42 select part ns = take n ns
43 where
44 n = round $ part * (fromIntegral $ length ns)
45
46
47 multiterms_rake :: Text -> [WordScore]
48 multiterms_rake = candidates hardStopList
49 defaultNosplit
50 defaultNolist . pSplitter
51
52 -- | StopList
53 hardStopList :: StopwordsMap
54 hardStopList = mkStopwordsStr stopList