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
150
Issues
150
List
Board
Labels
Milestones
Merge Requests
5
Merge Requests
5
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
eb29fcd8
Commit
eb29fcd8
authored
May 29, 2020
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ngrams] add score recomputation endpoint
parent
cc6ed9f6
Pipeline
#863
canceled with stage
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
1 deletion
+32
-1
Ngrams.hs
src/Gargantext/API/Ngrams.hs
+32
-1
No files found.
src/Gargantext/API/Ngrams.hs
View file @
eb29fcd8
...
...
@@ -1141,6 +1141,30 @@ getTableNgrams _nType nId tabType listId limit_ offset
pure
tableMap3
scoresRecomputeTableNgrams
::
forall
env
err
m
.
(
RepoCmdM
env
err
m
,
HasNodeError
err
,
HasConnectionPool
env
)
=>
NodeId
->
TabType
->
ListId
->
m
Int
scoresRecomputeTableNgrams
nId
tabType
listId
=
do
tableMap
<-
getNgramsTableMap
listId
ngramsType
_
<-
tableMap
&
v_data
%%~
setScores
.
Map
.
mapWithKey
ngramsElementFromRepo
pure
$
1
where
ngramsType
=
ngramsTypeFromTabType
tabType
setScores
::
forall
t
.
Each
t
t
NgramsElement
NgramsElement
=>
t
->
m
t
setScores
table
=
do
let
ngrams_terms
=
(
table
^..
each
.
ne_ngrams
)
occurrences
<-
getOccByNgramsOnlyFast'
nId
listId
ngramsType
ngrams_terms
let
setOcc
ne
=
ne
&
ne_occurrences
.~
sumOf
(
at
(
ne
^.
ne_ngrams
)
.
_Just
)
occurrences
pure
$
table
&
each
%~
setOcc
-- APIs
-- TODO: find a better place for the code above, All APIs stay here
...
...
@@ -1196,9 +1220,15 @@ type TableNgramsApiPost = Summary " Table Ngrams API Adds new ngrams"
:>
ReqBody
'[
J
SON
]
[
NgramsTerm
]
:>
Post
'[
J
SON
]
()
type
RecomputeScoresNgramsApiGet
=
Summary
" Recompute scores for ngrams table"
:>
QueryParamR
"ngramsType"
TabType
:>
QueryParamR
"list"
ListId
:>
"recompute"
:>
Post
'[
J
SON
]
Int
type
TableNgramsApi
=
TableNgramsApiGet
:<|>
TableNgramsApiPut
:<|>
TableNgramsApiPost
:<|>
RecomputeScoresNgramsApiGet
getTableNgramsCorpus
::
(
RepoCmdM
env
err
m
,
HasNodeError
err
,
HasConnectionPool
env
)
=>
NodeId
->
TabType
...
...
@@ -1240,7 +1270,7 @@ apiNgramsTableCorpus :: ( RepoCmdM env err m
apiNgramsTableCorpus
cId
=
getTableNgramsCorpus
cId
:<|>
tableNgramsPut
:<|>
tableNgramsPost
:<|>
scoresRecomputeTableNgrams
cId
apiNgramsTableDoc
::
(
RepoCmdM
env
err
m
,
HasNodeError
err
...
...
@@ -1251,6 +1281,7 @@ apiNgramsTableDoc :: ( RepoCmdM env err m
apiNgramsTableDoc
dId
=
getTableNgramsDoc
dId
:<|>
tableNgramsPut
:<|>
tableNgramsPost
:<|>
scoresRecomputeTableNgrams
dId
-- > add new ngrams in database (TODO AD)
-- > index all the corpus accordingly (TODO AD)
...
...
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