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
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
Christian Merten
haskell-gargantext
Commits
14a93ae8
Unverified
Commit
14a93ae8
authored
Mar 12, 2019
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NGRAMS,METRICS] JSON instances and ngramsType
parent
c2d21d28
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
11 deletions
+13
-11
Metrics.hs
src/Gargantext/API/Metrics.hs
+4
-4
Node.hs
src/Gargantext/API/Node.hs
+9
-7
No files found.
src/Gargantext/API/Metrics.hs
View file @
14a93ae8
...
...
@@ -28,9 +28,10 @@ module Gargantext.API.Metrics
import
Data.Text
(
Text
)
import
GHC.Generics
(
Generic
)
import
Gargantext.Prelude
import
Data.Aeson
(
To
JSON
)
import
Data.Aeson
.TH
(
derive
JSON
)
import
Test.QuickCheck.Arbitrary
(
Arbitrary
,
arbitrary
)
import
Gargantext.Core.Types
(
ListType
(
..
))
import
Gargantext.Core.Utils.Prefix
(
unPrefix
)
import
Data.Swagger
...
...
@@ -38,7 +39,6 @@ data Metrics = Metrics
{
metrics_data
::
[
Metric
]}
deriving
(
Generic
)
instance
ToJSON
Metrics
instance
ToSchema
Metrics
instance
Arbitrary
Metrics
where
...
...
@@ -51,7 +51,6 @@ data Metric = Metric
,
m_cat
::
!
ListType
}
deriving
(
Generic
)
instance
ToJSON
Metric
instance
ToSchema
Metric
instance
Arbitrary
Metric
where
...
...
@@ -60,4 +59,5 @@ instance Arbitrary Metric
<*>
arbitrary
<*>
arbitrary
deriveJSON
(
unPrefix
"metrics_"
)
''
M
etrics
deriveJSON
(
unPrefix
"m_"
)
''
M
etric
src/Gargantext/API/Node.hs
View file @
14a93ae8
...
...
@@ -41,7 +41,7 @@ import Data.Text (Text())
import
Data.Time
(
UTCTime
)
import
Debug.Trace
(
trace
)
import
GHC.Generics
(
Generic
)
import
Gargantext.API.Ngrams
(
TabType
(
..
),
TableNgramsApi
,
TableNgramsApiGet
,
tableNgramsPatch
,
getTableNgrams
,
HasRepo
)
import
Gargantext.API.Ngrams
(
TabType
(
..
),
TableNgramsApi
,
TableNgramsApiGet
,
tableNgramsPatch
,
getTableNgrams
,
HasRepo
,
ngramsTypeFromTabType
)
import
Gargantext.API.Ngrams.Tools
import
Gargantext.API.Search
(
SearchAPI
,
searchIn
,
SearchInQuery
)
import
Gargantext.API.Metrics
...
...
@@ -389,24 +389,26 @@ query s = pure s
-------------------------------------------------------------------------------
type
MetricsAPI
=
Summary
"SepGen IncExc metrics"
:>
QueryParam
"list"
ListId
:>
QueryParam
"limit"
Int
:>
QueryParam
"list"
ListId
:>
QueryParam
"ngramsType"
TabType
:>
QueryParam
"limit"
Int
:>
Get
'[
J
SON
]
Metrics
getMetrics
::
NodeId
->
GargServer
MetricsAPI
getMetrics
cId
maybeListId
maybeLimit
=
do
getMetrics
cId
maybeListId
maybe
TabType
maybe
Limit
=
do
lId
<-
case
maybeListId
of
Nothing
->
defaultList
cId
Just
lId'
->
pure
lId'
let
ngramsType
=
ngramsTypeFromTabType
maybeTabType
-- TODO all terms
ngs'
<-
mapTermListRoot
[
lId
]
NgramsTerms
ngs'
<-
mapTermListRoot
[
lId
]
ngramsType
let
ngs
=
Map
.
unions
$
map
(
\
t
->
filterListWithRoot
t
ngs'
)
[
GraphTerm
,
StopTerm
,
CandidateTerm
]
myCooc
<-
Map
.
filter
(
>
1
)
<$>
getCoocByNgrams
<$>
groupNodesByNgrams
ngs
<$>
getNodesByNgramsOnlyUser
cId
NgramsTerms
(
Map
.
keys
ngs
)
<$>
getNodesByNgramsOnlyUser
cId
ngramsType
(
Map
.
keys
ngs
)
let
metrics
=
map
(
\
(
Scored
t
s1
s2
)
->
Metric
t
s1
s2
(
listType
t
ngs'
))
$
scored
myCooc
...
...
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