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
d2ea221d
Commit
d2ea221d
authored
Aug 23, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FACTO] moving data2graph from textflow to Viz.Graph.
parent
16a85fb4
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
37 deletions
+50
-37
Main.hs
src-doctest/Main.hs
+1
-1
API.hs
src/Gargantext/API.hs
+16
-5
Text.hs
src/Gargantext/Text.hs
+1
-1
TextFlow.hs
src/Gargantext/TextFlow.hs
+2
-28
Graph.hs
src/Gargantext/Viz/Graph.hs
+30
-2
No files found.
src-doctest/Main.hs
View file @
d2ea221d
...
...
@@ -2,5 +2,5 @@ import System.FilePath.Glob
import
Test.DocTest
main
::
IO
()
main
=
glob
"src/Gargantext/
Text/
"
>>=
doctest
main
=
glob
"src/Gargantext/"
>>=
doctest
src/Gargantext/API.hs
View file @
d2ea221d
{-|
Module : Gargantext.API
Description :
Server API
Description :
REST API declaration
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
...
...
@@ -10,6 +10,7 @@ Portability : POSIX
Main REST API of Gargantext (both Server and Client sides)
TODO App type, the main monad in which the bot code is written with.
Provide config, state, logs and IO
type App m a = ( MonadState AppState m
, MonadReader Conf m
...
...
@@ -186,22 +187,32 @@ makeDevApp env = do
type
SwaggerAPI
=
SwaggerSchemaUI
"swagger-ui"
"swagger.json"
-- | API for serving main operational routes of @gargantext.org@
type
GargAPI
=
"user"
:>
Summary
"First user endpoint"
type
GargAPI
=
-- Roots endpoint
"user"
:>
Summary
"First user endpoint"
:>
Roots
-- Node endpoint
:<|>
"node"
:>
Summary
"Node endpoint"
:>
Capture
"id"
Int
:>
NodeAPI
-- Corpus endpoint
:<|>
"corpus"
:>
Summary
"Corpus endpoint"
:>
Capture
"id"
Int
:>
NodeAPI
-- Corpus endpoint
:<|>
"nodes"
:>
Summary
"Nodes endpoint"
:>
ReqBody
'[
J
SON
]
[
Int
]
:>
NodesAPI
-- :<|> "counts" :> Stream GET NewLineFraming '[JSON] Count :> CountAPI
-- :<|> "counts" :> Stream GET NewLineFraming '[JSON] Count :> CountAPI
-- Corpus endpoint
:<|>
"count"
:>
Summary
"Count endpoint"
:>
ReqBody
'[
J
SON
]
Query
:>
CountAPI
-- Corpus endpoint
:<|>
"search"
:>
Summary
"Search endpoint"
:>
ReqBody
'[
J
SON
]
SearchQuery
:>
SearchAPI
...
...
src/Gargantext/Text.hs
View file @
d2ea221d
...
...
@@ -63,7 +63,7 @@ termTests = "It is hard to detect important articles in a specific context. Info
-- | Ngrams Test
-- >>
>
ngramsTest testText
-- >> ngramsTest testText
-- 248
--ngramsTest :: Text -> Int
--ngramsTest x = length ws
...
...
src/Gargantext/TextFlow.hs
View file @
d2ea221d
...
...
@@ -22,17 +22,15 @@ import qualified Data.Text as T
import
Data.Text.IO
(
readFile
)
import
Data.Map.Strict
(
Map
)
import
qualified
Data.Array.Accelerate
as
A
import
qualified
Data.Map.Strict
as
M
----------------------------------------------
import
Gargantext.Core
(
Lang
)
import
Gargantext.Core.Types
(
Label
)
import
Gargantext.Prelude
import
Gargantext.Viz.Graph.Index
(
createIndices
,
toIndex
,
map2mat
,
mat2map
)
import
Gargantext.Viz.Graph.Distances.Matrice
(
conditional
)
import
Gargantext.Viz.Graph
(
Graph
(
..
),
Node
(
..
),
Edge
(
..
),
Attributes
(
..
),
TypeNode
(
..
)
)
import
Gargantext.Viz.Graph
(
Graph
(
..
),
data2graph
)
import
Gargantext.Text.Metrics.Count
(
cooc
)
import
Gargantext.Text.Metrics
import
Gargantext.Text.Terms
(
TermType
,
extractTerms
)
...
...
@@ -40,7 +38,7 @@ import Gargantext.Text.Context (splitBy, SplitContext(Sentences))
import
Gargantext.Text.Parsers.CSV
import
Data.Graph.Clustering.Louvain.CplusPlus
(
cLouvain
,
LouvainNode
(
..
)
)
import
Data.Graph.Clustering.Louvain.CplusPlus
(
cLouvain
)
{-
...
...
@@ -130,28 +128,4 @@ textFlow' termType contexts = do
--printDebug "partitions" partitions
pure
$
data2graph
(
M
.
toList
ti
)
myCooc4
distanceMap
partitions
-----------------------------------------------------------
-- | From data to Graph
-- FIXME: distance should not be a map since we just "toList" it (same as cLouvain)
data2graph
::
[(
Label
,
Int
)]
->
Map
(
Int
,
Int
)
Int
->
Map
(
Int
,
Int
)
Double
->
[
LouvainNode
]
->
Graph
data2graph
labels
coocs
distance
partitions
=
Graph
nodes
edges
where
community_id_by_node_id
=
M
.
fromList
[
(
n
,
c
)
|
LouvainNode
n
c
<-
partitions
]
nodes
=
[
Node
{
node_size
=
maybe
0
identity
(
M
.
lookup
(
n
,
n
)
coocs
)
,
node_type
=
Terms
-- or Unknown
,
node_id
=
cs
(
show
n
)
,
node_label
=
T
.
unwords
l
,
node_attributes
=
Attributes
{
clust_default
=
maybe
0
identity
(
M
.
lookup
n
community_id_by_node_id
)
}
}
|
(
l
,
n
)
<-
labels
]
edges
=
[
Edge
{
edge_source
=
cs
(
show
s
)
,
edge_target
=
cs
(
show
t
)
,
edge_weight
=
w
,
edge_id
=
cs
(
show
i
)
}
|
(
i
,
((
s
,
t
),
w
))
<-
zip
([
0
..
]
::
[
Integer
])
(
M
.
toList
distance
)
]
-----------------------------------------------------------
src/Gargantext/Viz/Graph.hs
View file @
d2ea221d
{-|
Module : Gargantext.Viz.Graph
Description :
Description :
Graph utils
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
...
...
@@ -27,9 +27,14 @@ import Data.Text (Text)
import
qualified
Text.Read
as
T
import
qualified
Data.Text
as
T
import
Data.Map.Strict
(
Map
)
import
qualified
Data.Map.Strict
as
M
import
Gargantext.Prelude
import
Gargantext.Core.Types
(
Label
)
import
Gargantext.Core.Utils.Prefix
(
unPrefix
)
import
Data.Graph.Clustering.Louvain.CplusPlus
(
LouvainNode
(
..
))
data
TypeNode
=
Terms
|
Unknown
deriving
(
Show
,
Generic
)
...
...
@@ -92,7 +97,30 @@ data GraphOld = GraphOld {
$
(
deriveJSON
(
unPrefix
"go_"
)
''
G
raphOld
)
----------------------------------------------------------
-- | From data to Graph
-- FIXME: distance should not be a map since we just "toList" it (same as cLouvain)
data2graph
::
[(
Label
,
Int
)]
->
Map
(
Int
,
Int
)
Int
->
Map
(
Int
,
Int
)
Double
->
[
LouvainNode
]
->
Graph
data2graph
labels
coocs
distance
partitions
=
Graph
nodes
edges
where
community_id_by_node_id
=
M
.
fromList
[
(
n
,
c
)
|
LouvainNode
n
c
<-
partitions
]
nodes
=
[
Node
{
node_size
=
maybe
0
identity
(
M
.
lookup
(
n
,
n
)
coocs
)
,
node_type
=
Terms
-- or Unknown
,
node_id
=
cs
(
show
n
)
,
node_label
=
T
.
unwords
l
,
node_attributes
=
Attributes
{
clust_default
=
maybe
0
identity
(
M
.
lookup
n
community_id_by_node_id
)
}
}
|
(
l
,
n
)
<-
labels
]
edges
=
[
Edge
{
edge_source
=
cs
(
show
s
)
,
edge_target
=
cs
(
show
t
)
,
edge_weight
=
w
,
edge_id
=
cs
(
show
i
)
}
|
(
i
,
((
s
,
t
),
w
))
<-
zip
([
0
..
]
::
[
Integer
])
(
M
.
toList
distance
)
]
-----------------------------------------------------------
-----------------------------------------------------------
graphOld2graph
::
GraphOld
->
Graph
graphOld2graph
(
GraphOld
links
nodes
)
=
Graph
(
map
nodeOld2node
nodes
)
(
zipWith
linkOld2edge
[
1
..
]
links
)
...
...
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