]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Core/Text/Terms/Multi/RAKE.hs
Merge branch 'dev' into 141-dev-node-stories-db-optimization
[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 Data.Text (Text)
35 import NLP.RAKE.Text
36
37 import Gargantext.Core.Text.Samples.EN (stopList)
38 import Gargantext.Prelude
39
40 select :: Double -> [a] -> [a]
41 select part ns = take n ns
42 where
43 n = round $ part * (fromIntegral $ length ns)
44
45
46 multiterms_rake :: Text -> [WordScore]
47 multiterms_rake = candidates hardStopList
48 defaultNosplit
49 defaultNolist . pSplitter
50
51 -- | StopList
52 hardStopList :: StopwordsMap
53 hardStopList = mkStopwordsStr stopList