2 Module : Gargantext.Database.Action.Index
3 Description : Indexation tools
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
10 Main Database functions for Gargantext.API.Node.Update
12 UpdateNodeParamsTexts { methodTexts :: Granularity }
13 data Granularity = NewNgrams | NewTexts | Both
14 deriving (Generic, Eq, Ord, Enum, Bounded)
16 -- TODO add option for type of ngrams
20 module Gargantext.Database.Action.Index
24 import Data.List (nub)
25 import Gargantext.Core.Text.Terms.WithList (buildPatterns, filterTerms, termsInText)
28 index :: CorpusId -> Granularity -> Cmd err [Int]
29 index cId NewNgrams = do
30 ngrams <- get ngrams with zero count
31 texts <- get all text to index
32 indexSave text (buildPatterns ngrams)
34 index cId NewTexts = do
35 ngrams <- get all ngrams
36 texts <- get text with zero count
37 indexSave text (buildPatterns ngrams)
40 r1 <- index cId NewNgrams
41 r2 <- index cId NewTexts
44 indexSave :: [Document] -> Pattern -> Cmd err [Int]
45 indexSave corpus p = do
46 indexedDoc <- map (filterTerms patterns) corpus
47 saveIndexDoc ngramsTextId