Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
147
Issues
147
List
Board
Labels
Milestones
Merge Requests
6
Merge Requests
6
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
gargantext
haskell-gargantext
Commits
09cf2917
Commit
09cf2917
authored
May 31, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Pipeline] clustering with C++ Louvain bindings, ok.
parent
00344aaf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
21 deletions
+25
-21
Pipeline.hs
src/Gargantext/Pipeline.hs
+9
-9
Graph.hs
src/Gargantext/Viz/Graph.hs
+0
-5
Matrice.hs
src/Gargantext/Viz/Graph/Distances/Matrice.hs
+16
-7
No files found.
src/Gargantext/Pipeline.hs
View file @
09cf2917
...
...
@@ -22,17 +22,16 @@ import Gargantext.Core (Lang(FR))
import
Gargantext.Prelude
import
Gargantext.Viz.Graph.Index
(
score
,
createIndices
,
toIndex
)
import
Gargantext.Viz.Graph.Distances.Matrice
(
distribu
tional
)
import
Gargantext.Viz.Graph.Distances.Matrice
(
condi
tional
)
import
Gargantext.Text.Metrics.Occurrences
(
cooc
,
removeApax
)
import
Gargantext.Text.Terms
(
TermType
(
Multi
,
Mono
),
extractTerms
)
import
Gargantext.Text.Context
(
splitBy
,
SplitContext
(
Sentences
))
import
Data.Graph.Clustering.Louvain
(
bestpartition
)
import
Data.Graph.Clustering.Louvain.Utils
(
map2graph
)
import
Data.Graph.Clustering.Louvain.CplusPlus
(
cLouvain
)
pipeline
path
=
do
-- Text <- IO Text <- FilePath
text
<-
readFile
path
text
<-
readFile
path
let
contexts
=
splitBy
(
Sentences
3
)
text
myterms
<-
extractTerms
Multi
FR
contexts
...
...
@@ -40,11 +39,12 @@ pipeline path = do
-- TODO groupBy (Stem | GroupList)
let
myCooc
=
removeApax
$
cooc
myterms
-- Cooc -> Matrix
let
theScores
=
M
.
filter
(
/=
0
)
$
score
distribu
tional
myCooc
let
theScores
=
M
.
take
350
$
M
.
filter
(
>
0
)
$
score
condi
tional
myCooc
let
(
ti
,
_
)
=
createIndices
theScores
-- Matrix -> Clustering -> Graph -> JSON
pure
$
bestpartition
False
$
map2graph
$
toIndex
ti
theScores
--
---- -- Matrix -> Clustering -> Graph -> JSON
---- pure $ bestpartition False $ map2graph $ toIndex ti theScores
partitions
<-
cLouvain
$
toIndex
ti
theScores
pure
partitions
src/Gargantext/Viz/Graph.hs
View file @
09cf2917
...
...
@@ -60,8 +60,3 @@ $(deriveJSON (unPrefix "g_") ''Graph)
src/Gargantext/Viz/Graph/Distances/Matrice.hs
View file @
09cf2917
...
...
@@ -89,8 +89,21 @@ type Matrix' a = Acc (Matrix a)
type
InclusionExclusion
=
Double
type
SpecificityGenericity
=
Double
conditional
::
Matrix
Double
->
(
Matrix
InclusionExclusion
,
Matrix
SpecificityGenericity
)
conditional
m
=
(
run
$
ie
(
use
m
),
run
$
sg
(
use
m
))
miniMax
::
Matrix'
Double
->
Matrix'
Double
miniMax
m
=
map
(
\
x
->
ifThenElse
(
x
>
miniMax'
)
x
0
)
m
where
miniMax'
=
(
the
$
minimum
$
maximum
m
)
conditional
::
Matrix
Int
->
Matrix
Double
conditional
m
=
run
(
miniMax
$
proba
r
$
map
fromIntegral
$
use
m
)
where
r
::
Rank
r
=
rank'
m
conditional'
::
Matrix
Double
->
(
Matrix
InclusionExclusion
,
Matrix
SpecificityGenericity
)
conditional'
m
=
(
run
$
ie
(
use
m
),
run
$
sg
(
use
m
))
where
ie
::
Matrix'
Double
->
Matrix'
Double
...
...
@@ -115,14 +128,10 @@ conditional m = (run $ ie (use m), run $ sg (use m))
-- | Distributional Distance
distributional
::
Matrix
Int
->
Matrix
Double
distributional
m
=
run
$
filter
$
ri
(
map
fromIntegral
$
use
m
)
distributional
m
=
run
$
miniMax
$
ri
(
map
fromIntegral
$
use
m
)
where
n
=
rank'
m
miniMax
m
=
map
(
\
x
->
ifThenElse
(
x
>
miniMax'
)
x
0
)
m
where
miniMax'
=
(
the
$
minimum
$
maximum
m
)
filter
m
=
zipWith
(
\
a
b
->
max
a
b
)
m
(
transpose
m
)
ri
mat
=
zipWith
(
/
)
mat1
mat2
...
...
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