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
19a73c11
Verified
Commit
19a73c11
authored
Feb 17, 2023
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ngrams] some attempts at making aggregation work
However, this still returns 0s for some reason.
parent
9dd4e321
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
23 deletions
+29
-23
Facet.hs
src/Gargantext/Database/Query/Facet.hs
+29
-23
No files found.
src/Gargantext/Database/Query/Facet.hs
View file @
19a73c11
...
...
@@ -19,7 +19,7 @@ module Gargantext.Database.Query.Facet
(
runViewAuthorsDoc
,
runViewDocuments
,
viewDocuments
,
viewDocuments'
--
, viewDocuments'
,
runCountDocuments
,
filterWith
,
runTestAgg
...
...
@@ -182,15 +182,22 @@ viewDocuments' :: CorpusId
->
Maybe
Text
->
Maybe
Text
->
Select
FacetDocAgg
viewDocuments'
cId
t
ntId
mQuery
mYear
=
aggregate
(
pFacetDoc
FacetDoc
{
facetDoc_id
=
OAgg
.
groupBy
,
facetDoc_created
=
OAgg
.
groupBy
,
facetDoc_title
=
OAgg
.
groupBy
,
facetDoc_hyperdata
=
OAgg
.
groupBy
,
facetDoc_category
=
OAgg
.
groupBy
,
facetDoc_ngramCount
=
OAgg
.
sumInt4
,
facetDoc_score
=
OAgg
.
sum
})
(
viewDocumentsAgg
cId
t
ntId
mQuery
mYear
)
viewDocuments'
cId
t
ntId
mQuery
mYear
=
proc
()
->
do
fd
<-
viewDocumentsAgg
cId
t
ntId
mQuery
mYear
-<
()
agg
<-
(
laterally
.
OAgg
.
aggregate
)
sumInt4
(
proc
fd'
->
do
returnA
-<
facetDoc_ngramCount
fd'
)
-<
fd
returnA
-<
fd
{
facetDoc_ngramCount
=
agg
}
-- aggregate (pFacetDoc FacetDoc { facetDoc_id = OAgg.groupBy
-- , facetDoc_created = OAgg.groupBy
-- , facetDoc_title = OAgg.groupBy
-- , facetDoc_hyperdata = OAgg.groupBy
-- , facetDoc_category = OAgg.groupBy
-- , facetDoc_ngramCount = OAgg.sumInt4
-- , facetDoc_score = OAgg.sum })
-- (viewDocumentsAgg cId t ntId mQuery mYear)
viewDocumentsAgg
::
CorpusId
->
IsTrash
...
...
@@ -200,33 +207,32 @@ viewDocumentsAgg :: CorpusId
->
Select
FacetDocAggPart
viewDocumentsAgg
cId
t
ntId
mQuery
mYear
=
proc
()
->
do
(
c
,
nc
)
<-
viewDocumentsQuery
cId
t
ntId
mQuery
mYear
-<
()
agg
<-
OAgg
.
aggregate
sumInt4
(
aggQ
(
nc
^.
nc_node_id
)
(
c
^.
cs_id
))
-<
()
-- agg <-
OAgg.aggregate
sumInt4
--
agg <- OAgg.aggregate sumInt4 (aggQ (nc ^. nc_node_id) (c ^. cs_id)) -< ()
-- agg <-
(laterally . OAgg.aggregate)
sumInt4
-- (proc (c', nc') -> do
-- cnng <- queryContextNodeNgramsTable -< ()
-- restrict -< (cnng ^. cnng_node_id) .== (nc' ^. nc_node_id)
-- restrict -< (cnng ^. cnng_context_id) .== (c' ^. cs_id)
-- returnA -< (cnng ^. cnng_doc_count)) -< (c, nc)
--
cnng <- optionalRestrict queryContextNodeNgramsTable -<
--
\cnng' -> (cnng' ^. cnng_node_id) .== (nc ^. nc_node_id) .&&
--
(cnng' ^. cnng_context_id) .== (c ^. cs_id)
cnng
<-
optionalRestrict
queryContextNodeNgramsTable
-<
\
cnng'
->
(
cnng'
^.
cnng_node_id
)
.==
(
nc
^.
nc_node_id
)
.&&
(
cnng'
^.
cnng_context_id
)
.==
(
c
^.
cs_id
)
returnA
-<
FacetDoc
{
facetDoc_id
=
_cs_id
c
,
facetDoc_created
=
_cs_date
c
,
facetDoc_title
=
_cs_name
c
,
facetDoc_hyperdata
=
_cs_hyperdata
c
,
facetDoc_category
=
nc
^.
nc_category
,
facetDoc_ngramCount
=
fromIntegral
agg
-- , facetDoc_ngramCount = fromMaybeFields 0 $ _cnng_doc_count <$> cnng -- toNullable $ nc^.
nc_score
-- , facetDoc_ngramCount = agg
,
facetDoc_ngramCount
=
fromMaybeFields
0
$
_cnng_doc_count
<$>
cnng
-- toNullable $ nc^. nc_score
-- , facetDoc_ngramCount = toNullable $ toFields cnt
,
facetDoc_score
=
nc
^.
nc_score
}
aggQ
ncId
cId
=
proc
()
->
do
cnng
<-
queryContextNodeNgramsTable
-<
()
restrict
-<
(
cnng
^.
cnng_node_id
)
.==
ncId
restrict
-<
(
cnng
^.
cnng_context_id
)
.==
cId
returnA
-<
(
cnng
^.
cnng_doc_count
)
--
aggQ ncId cId = proc () -> do
--
cnng <- queryContextNodeNgramsTable -< ()
--
restrict -< (cnng ^. cnng_node_id) .== ncId
--
restrict -< (cnng ^. cnng_context_id) .== cId
--
returnA -< (cnng ^. cnng_doc_count)
-- TODO Join with context_node_ngrams at context_id/node_id and sum by
-- doc_count.
...
...
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