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
158
Issues
158
List
Board
Labels
Milestones
Merge Requests
11
Merge Requests
11
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
a5bcf8db
Commit
a5bcf8db
authored
May 31, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[RENAME] name and newtypes for createIndices.
parent
47ed713f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
11 deletions
+22
-11
Pipeline.hs
src/Gargantext/Pipeline.hs
+2
-2
Index.hs
src/Gargantext/Viz/Graph/Index.hs
+20
-9
No files found.
src/Gargantext/Pipeline.hs
View file @
a5bcf8db
...
@@ -21,7 +21,7 @@ import qualified Data.Map.Strict as M
...
@@ -21,7 +21,7 @@ import qualified Data.Map.Strict as M
import
Gargantext.Core
(
Lang
(
FR
))
import
Gargantext.Core
(
Lang
(
FR
))
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Gargantext.Viz.Graph.Index
(
score
,
createInd
ex
es
,
toIndex
)
import
Gargantext.Viz.Graph.Index
(
score
,
createInd
ic
es
,
toIndex
)
import
Gargantext.Viz.Graph.Distances.Matrice
(
distributional
)
import
Gargantext.Viz.Graph.Distances.Matrice
(
distributional
)
import
Gargantext.Text.Metrics.Occurrences
(
cooc
,
removeApax
)
import
Gargantext.Text.Metrics.Occurrences
(
cooc
,
removeApax
)
import
Gargantext.Text.Terms
(
TermType
(
Multi
,
Mono
),
extractTerms
)
import
Gargantext.Text.Terms
(
TermType
(
Multi
,
Mono
),
extractTerms
)
...
@@ -43,7 +43,7 @@ pipeline path = do
...
@@ -43,7 +43,7 @@ pipeline path = do
-- Cooc -> Matrix
-- Cooc -> Matrix
let
theScores
=
M
.
filter
(
/=
0
)
$
score
distributional
myCooc
let
theScores
=
M
.
filter
(
/=
0
)
$
score
distributional
myCooc
let
(
ti
,
_
)
=
createInd
ex
es
theScores
let
(
ti
,
_
)
=
createInd
ic
es
theScores
-- Matrix -> Clustering -> Graph -> JSON
-- Matrix -> Clustering -> Graph -> JSON
pure
$
bestpartition
False
$
map2graph
$
toIndex
ti
theScores
pure
$
bestpartition
False
$
map2graph
$
toIndex
ti
theScores
...
...
src/Gargantext/Viz/Graph/Index.hs
View file @
a5bcf8db
...
@@ -39,6 +39,8 @@ import qualified Data.Set as S
...
@@ -39,6 +39,8 @@ import qualified Data.Set as S
import
Data.Map
(
Map
)
import
Data.Map
(
Map
)
import
qualified
Data.Map.Strict
as
M
import
qualified
Data.Map.Strict
as
M
import
Data.Vector
(
Vector
)
import
Gargantext.Prelude
import
Gargantext.Prelude
type
Index
=
Int
type
Index
=
Int
...
@@ -50,7 +52,7 @@ score :: (Ord t) => (A.Matrix Int -> A.Matrix Double)
...
@@ -50,7 +52,7 @@ score :: (Ord t) => (A.Matrix Int -> A.Matrix Double)
->
Map
(
t
,
t
)
Double
->
Map
(
t
,
t
)
Double
score
f
m
=
fromIndex
fromI
.
mat2map
.
f
$
cooc2mat
toI
m
score
f
m
=
fromIndex
fromI
.
mat2map
.
f
$
cooc2mat
toI
m
where
where
(
toI
,
fromI
)
=
createInd
ex
es
m
(
toI
,
fromI
)
=
createInd
ic
es
m
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
...
@@ -79,21 +81,30 @@ toIndex ni ns = indexConversion ni ns
...
@@ -79,21 +81,30 @@ toIndex ni ns = indexConversion ni ns
fromIndex
::
Ord
t
=>
Map
Index
t
->
Map
(
Index
,
Index
)
a
->
Map
(
t
,
t
)
a
fromIndex
::
Ord
t
=>
Map
Index
t
->
Map
(
Index
,
Index
)
a
->
Map
(
t
,
t
)
a
fromIndex
ni
ns
=
indexConversion
ni
ns
fromIndex
ni
ns
=
indexConversion
ni
ns
---------------------------------------------------------------------------------
indexConversion
::
(
Ord
b
,
Ord
k
)
=>
Map
k
b
->
Map
(
k
,
k
)
a
->
Map
(
b
,
b
)
a
indexConversion
::
(
Ord
b
,
Ord
k
)
=>
Map
k
b
->
Map
(
k
,
k
)
a
->
Map
(
b
,
b
)
a
indexConversion
index
ms
=
M
.
fromList
$
map
(
\
((
k1
,
k2
),
c
)
->
(
((
M
.!
)
index
k1
,
(
M
.!
)
index
k2
),
c
))
(
M
.
toList
ms
)
indexConversion
index
ms
=
M
.
fromList
$
map
(
\
((
k1
,
k2
),
c
)
->
(
((
M
.!
)
index
k1
,
(
M
.!
)
index
k2
),
c
))
(
M
.
toList
ms
)
---------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- TODO
createIndexes
::
Ord
t
=>
Map
(
t
,
t
)
b
->
(
Map
t
Index
,
Map
Index
t
)
fromIndex'
::
Ord
t
=>
Vector
t
->
Map
(
Index
,
Index
)
a
->
Map
(
t
,
t
)
a
createIndexes
=
set2indexes
.
cooc2set
fromIndex'
vi
ns
=
undefined
-- TODO
createIndices'
::
Ord
t
=>
Map
(
t
,
t
)
b
->
(
Map
t
Index
,
Vector
t
)
createIndices'
=
undefined
createIndices
::
Ord
t
=>
Map
(
t
,
t
)
b
->
(
Map
t
Index
,
Map
Index
t
)
createIndices
=
set2indices
.
map2set
where
where
cooc
2set
::
Ord
t
=>
Map
(
t
,
t
)
a
->
Set
t
map
2set
::
Ord
t
=>
Map
(
t
,
t
)
a
->
Set
t
cooc
2set
cs'
=
foldl'
(
\
s
((
t1
,
t2
),
_
)
->
insert
[
t1
,
t2
]
s
)
S
.
empty
(
M
.
toList
cs'
)
map
2set
cs'
=
foldl'
(
\
s
((
t1
,
t2
),
_
)
->
insert
[
t1
,
t2
]
s
)
S
.
empty
(
M
.
toList
cs'
)
where
where
insert
as
s
=
foldl'
(
\
s'
t
->
S
.
insert
t
s'
)
s
as
insert
as
s
=
foldl'
(
\
s'
t
->
S
.
insert
t
s'
)
s
as
set2ind
ex
es
::
Ord
t
=>
Set
t
->
(
Map
t
Index
,
Map
Index
t
)
set2ind
ic
es
::
Ord
t
=>
Set
t
->
(
Map
t
Index
,
Map
Index
t
)
set2ind
ex
es
s
=
(
M
.
fromList
toIndex'
,
M
.
fromList
fromIndex'
)
set2ind
ic
es
s
=
(
M
.
fromList
toIndex'
,
M
.
fromList
fromIndex'
)
where
where
fromIndex'
=
zip
[
0
..
]
xs
fromIndex'
=
zip
[
0
..
]
xs
toIndex'
=
zip
xs
[
0
..
]
toIndex'
=
zip
xs
[
0
..
]
...
...
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