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
160
Issues
160
List
Board
Labels
Milestones
Merge Requests
8
Merge Requests
8
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
daba6a47
Unverified
Commit
daba6a47
authored
Mar 26, 2019
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
getOccByNgramsOnly: For now it calls the fast and the slow and compares
parent
1c37c774
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
9 deletions
+20
-9
Ngrams.hs
src/Gargantext/API/Ngrams.hs
+2
-2
NgramsByNode.hs
src/Gargantext/Database/Metrics/NgramsByNode.hs
+18
-7
No files found.
src/Gargantext/API/Ngrams.hs
View file @
daba6a47
...
...
@@ -72,7 +72,7 @@ import GHC.Generics (Generic)
import
Gargantext.Core.Utils.Prefix
(
unPrefix
)
-- import Gargantext.Database.Schema.Ngrams (NgramsTypeId, ngramsTypeId, NgramsTableData(..))
--import Gargantext.Database.Config (userMaster)
import
Gargantext.Database.Metrics.NgramsByNode
(
getOccByNgramsOnly
)
import
Gargantext.Database.Metrics.NgramsByNode
(
getOccByNgramsOnly
Safe
)
import
Gargantext.Database.Schema.Ngrams
(
NgramsType
)
import
Gargantext.Database.Utils
(
fromField'
,
HasConnection
)
--import Gargantext.Database.Lists (listsWith)
...
...
@@ -936,7 +936,7 @@ getTableNgrams cId tabType listId limit_ moffset
-- getNgramsTableMap ({-lists <>-} listIds) ngramsType
table
<-
getNgramsTableMap
listId
ngramsType
&
mapped
.
v_data
%~
finalize
occurrences
<-
getOccByNgramsOnly
cId
ngramsType
(
table
^..
v_data
.
_NgramsTable
.
each
.
ne_ngrams
)
occurrences
<-
getOccByNgramsOnly
Safe
cId
ngramsType
(
table
^..
v_data
.
_NgramsTable
.
each
.
ne_ngrams
)
let
setOcc
ne
=
ne
&
ne_occurrences
.~
sumOf
(
at
(
ne
^.
ne_ngrams
)
.
_Just
)
occurrences
...
...
src/Gargantext/Database/Metrics/NgramsByNode.hs
View file @
daba6a47
...
...
@@ -20,6 +20,7 @@ module Gargantext.Database.Metrics.NgramsByNode
where
import
Data.Map.Strict
(
Map
,
fromListWith
,
elems
,
toList
,
fromList
)
import
Data.Map.Strict.Patch
(
PatchMap
,
Replace
,
diff
)
import
Data.Set
(
Set
)
import
Data.Text
(
Text
)
import
Data.Tuple.Extra
(
second
,
swap
)
...
...
@@ -135,17 +136,27 @@ queryNgramsByNodeUser = [sql|
|]
------------------------------------------------------------------------
-- TODO add groups
getOccByNgramsOnly
::
CorpusId
->
NgramsType
->
[
Text
]
->
Cmd
err
(
Map
Text
Int
)
getOccByNgramsOnly
cId
nt
ngs
=
getOccByNgramsOnly
Fast
::
CorpusId
->
NgramsType
->
[
Text
]
->
Cmd
err
(
Map
Text
Int
)
getOccByNgramsOnly
Fast
cId
nt
ngs
=
fromListWith
(
+
)
<$>
selectNgramsOccurrencesOnlyByNodeUser
cId
nt
ngs
-- just slower than getOccByNgramsOnly
getOccByNgramsOnly
'
::
CorpusId
->
NgramsType
->
[
Text
]
->
Cmd
err
(
Map
Text
Int
)
getOccByNgramsOnly
'
cId
nt
ngs
=
-- just slower than getOccByNgramsOnly
Fast
getOccByNgramsOnly
Slow
::
CorpusId
->
NgramsType
->
[
Text
]
->
Cmd
err
(
Map
Text
Int
)
getOccByNgramsOnly
Slow
cId
nt
ngs
=
Map
.
map
Set
.
size
<$>
getNodesByNgramsOnlyUser
cId
nt
ngs
getOccByNgramsOnlySafe
::
CorpusId
->
NgramsType
->
[
Text
]
->
Cmd
err
(
Map
Text
Int
)
getOccByNgramsOnlySafe
cId
nt
ngs
=
do
printDebug
"getOccByNgramsOnlySafe"
(
cId
,
nt
,
length
ngs
)
fast
<-
getOccByNgramsOnlyFast
cId
nt
ngs
slow
<-
getOccByNgramsOnlySlow
cId
nt
ngs
when
(
fast
/=
slow
)
$
printDebug
"getOccByNgramsOnlySafe: difference"
(
diff
slow
fast
::
PatchMap
Text
(
Replace
(
Maybe
Int
)))
pure
slow
selectNgramsOccurrencesOnlyByNodeUser
::
CorpusId
->
NgramsType
->
[
Text
]
->
Cmd
err
[(
Text
,
Int
)]
selectNgramsOccurrencesOnlyByNodeUser
cId
nt
tms
=
...
...
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