Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Przemyslaw Kaminski
haskell-gargantext
Commits
97d5140c
Commit
97d5140c
authored
Oct 25, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FLOW][DB][NGRAMS][Lists] Done, need to be tested with real data.
parent
a4fb6705
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
26 deletions
+40
-26
Main.hs
src/Gargantext/Core/Types/Main.hs
+6
-1
Flow.hs
src/Gargantext/Database/Flow.hs
+26
-18
NodeNgram.hs
src/Gargantext/Database/NodeNgram.hs
+7
-3
NodeNodeNgram.hs
src/Gargantext/Database/NodeNodeNgram.hs
+1
-4
No files found.
src/Gargantext/Core/Types/Main.hs
View file @
97d5140c
...
...
@@ -78,7 +78,12 @@ corpusTree nId t = TreeN (NodeTree ("Corpus " <> t) NodeCorpus nId) ( [ leafT
--data Classification = Favorites | MyClassifcation
data
Lists
=
StopList
|
MainList
|
MapList
|
GroupList
data
ListType
=
Stop
|
Candidate
|
Map
listId
::
ListType
->
Int
listId
Stop
=
0
listId
Candidate
=
1
listId
Map
=
2
-- data Metrics = Occurrences | Cooccurrences | Specclusion | Genclusion | Cvalue
-- | TfidfCorpus | TfidfGlobal | TirankLocal | TirankGlobal
...
...
src/Gargantext/Database/Flow.hs
View file @
97d5140c
...
...
@@ -28,10 +28,10 @@ import System.FilePath (FilePath)
import
Data.Maybe
(
Maybe
(
..
))
import
Data.Text
(
Text
)
import
Data.Map
(
Map
)
import
Data.Tuple.Extra
(
both
)
import
Data.Tuple.Extra
(
both
,
second
)
import
qualified
Data.Map
as
DM
import
Gargantext.Core.Types
(
NodePoly
(
..
))
import
Gargantext.Core.Types
(
NodePoly
(
..
)
,
ListType
(
..
),
listId
)
import
Gargantext.Prelude
import
Gargantext.Database.Bashql
(
runCmd'
,
del
)
import
Gargantext.Database.Types.Node
(
HyperdataDocument
(
..
))
...
...
@@ -147,40 +147,48 @@ indexNgrams ng2nId = do
insertToNodeNgrams
::
Map
(
NgramsT
NgramsIndexed
)
(
Map
NodeId
Int
)
->
Cmd
Int
insertToNodeNgrams
m
=
insertNodeNgrams
$
[
NodeNgram
Nothing
nId
((
_ngramsId
.
_ngramsT
)
ng
)
insertToNodeNgrams
m
=
insertNodeNgrams
[
NodeNgram
Nothing
nId
((
_ngramsId
.
_ngramsT
)
ng
)
(
fromIntegral
n
)
((
ngramsTypeId
.
_ngramsType
)
ng
)
|
(
ng
,
nId2int
)
<-
DM
.
toList
m
,
(
nId
,
n
)
<-
DM
.
toList
nId2int
]
|
(
ng
,
nId2int
)
<-
DM
.
toList
m
,
(
nId
,
n
)
<-
DM
.
toList
nId2int
]
------------------------------------------------------------------------
groupNgramsBy
::
(
Ngrams
->
Ngrams
->
Bool
)
->
Map
(
NgramsT
NgramsIndexed
)
(
Map
NodeId
Int
)
->
Map
NgramsIndexed
NgramsIndexed
groupNgramsBy
::
(
Ngrams
->
Ngrams
->
Bool
)
->
Map
(
NgramsT
NgramsIndexed
)
(
Map
NodeId
Int
)
->
Map
NgramsIndexed
NgramsIndexed
groupNgramsBy
=
undefined
insertGroups
::
ListId
->
Map
NgramsIndexed
NgramsIndexed
->
Cmd
Int
insertGroups
lId
ngrs
=
insertNodeNgramNgram
$
[
NodeNgramNgram
lId
ng1
ng2
(
Just
1
)
|
(
ng1
,
ng2
)
<-
map
(
both
_ngramsId
)
$
DM
.
toList
ngrs
]
|
(
ng1
,
ng2
)
<-
map
(
both
_ngramsId
)
$
DM
.
toList
ngrs
]
------------------------------------------------------------------------
ngrams2list
::
Map
(
NgramsT
NgramsIndexed
)
(
Map
NodeId
Int
)
->
Map
ListType
NgramsIndexed
ngrams2list
=
undefined
-- | TODO: weight of the list could be a probability
insertLists
::
ListId
->
Map
ListType
NgramsIndexed
->
Cmd
Int
insertLists
lId
list2ngrams
=
insertNodeNgrams
[
NodeNgram
Nothing
lId
ngr
(
fromIntegral
$
listId
l
)
(
listId
l
)
|
(
l
,
ngr
)
<-
map
(
second
_ngramsId
)
$
DM
.
toList
list2ngrams
]
listFlow
::
UserId
->
CorpusId
->
Map
(
NgramsT
NgramsIndexed
)
(
Map
NodeId
Int
)
->
Cmd
ListId
listFlow
uId
cId
ng
=
do
lId
<-
maybe
(
panic
"mkList error"
)
identity
<$>
head
<$>
mkList
cId
uId
-- TODO add stemming equivalence of 2 ngrams
let
groupEd
=
groupNgramsBy
(
==
)
ng
_
<-
insertGroups
lId
groupEd
-- compute Candidate / Map
-- ALTER TABLE nodes_nodes_ngrams ADD COLUMN typelist int;
-- insertLists = NodeNodeNgram
let
lists
=
ngrams2list
ng
_
<-
insertLists
lId
lists
pure
lId
-- | TODO ask on meeting
-- get data of NgramsTable
-- post :: update NodeNodeNgrams
-- group ngrams
------------------------------------------------------------------------
src/Gargantext/Database/NodeNgram.hs
View file @
97d5140c
{-|
Module : Gargantext.Database.NodeNgram
Description :
Description :
NodeNgram for Ngram indexation or Lists
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
Here is a longer description of this module, containing some
commentary with @some markup@.
NodeNgram: relation between a Node and a Ngrams
if Node is a Document then it is indexing
if Node is a List then it is listing (either Stop, Candidate or Map)
-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
...
...
@@ -29,6 +32,7 @@ import Control.Lens.TH (makeLensesWith, abbreviatedFields)
import
Gargantext.Database.Node
(
mkCmd
,
Cmd
(
..
))
import
Opaleye
-- | TODO : remove id
data
NodeNgramPoly
id
node_id
ngram_id
weight
ngrams_type
=
NodeNgram
{
nodeNgram_NodeNgramId
::
id
,
nodeNgram_NodeNgramNodeId
::
node_id
...
...
src/Gargantext/Database/NodeNodeNgram.hs
View file @
97d5140c
{-|
Module : Gargantext.Database.NodeNodeNgram
Description :
Description :
TODO: remove this module and table in database
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
Here is a longer description of this module, containing some
commentary with @some markup@.
-}
{-# LANGUAGE NoImplicitPrelude #-}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment