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
9dd4e321
Verified
Commit
9dd4e321
authored
Feb 16, 2023
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ngrams] some query to fix
parent
b8d826ac
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
5 deletions
+43
-5
Facet.hs
src/Gargantext/Database/Query/Facet.hs
+21
-4
ContextNodeNgrams.hs
src/Gargantext/Database/Schema/ContextNodeNgrams.hs
+22
-1
No files found.
src/Gargantext/Database/Query/Facet.hs
View file @
9dd4e321
...
@@ -22,6 +22,7 @@ module Gargantext.Database.Query.Facet
...
@@ -22,6 +22,7 @@ module Gargantext.Database.Query.Facet
,
viewDocuments'
,
viewDocuments'
,
runCountDocuments
,
runCountDocuments
,
filterWith
,
filterWith
,
runTestAgg
,
Category
,
Category
,
Score
,
Score
...
@@ -59,6 +60,7 @@ import Gargantext.Database.Schema.Node
...
@@ -59,6 +60,7 @@ import Gargantext.Database.Schema.Node
import
Gargantext.Database.Schema.NodeContext
import
Gargantext.Database.Schema.NodeContext
import
Gargantext.Prelude
(
printDebug
)
import
Gargantext.Prelude
(
printDebug
)
import
Gargantext.Database.Query.FacetTest
(
runTestAgg
)
------------------------------------------------------------------------
------------------------------------------------------------------------
...
@@ -198,19 +200,34 @@ viewDocumentsAgg :: CorpusId
...
@@ -198,19 +200,34 @@ viewDocumentsAgg :: CorpusId
->
Select
FacetDocAggPart
->
Select
FacetDocAggPart
viewDocumentsAgg
cId
t
ntId
mQuery
mYear
=
proc
()
->
do
viewDocumentsAgg
cId
t
ntId
mQuery
mYear
=
proc
()
->
do
(
c
,
nc
)
<-
viewDocumentsQuery
cId
t
ntId
mQuery
mYear
-<
()
(
c
,
nc
)
<-
viewDocumentsQuery
cId
t
ntId
mQuery
mYear
-<
()
cnng
<-
optionalRestrict
queryContextNodeNgramsTable
-<
agg
<-
OAgg
.
aggregate
sumInt4
(
aggQ
(
nc
^.
nc_node_id
)
(
c
^.
cs_id
))
-<
()
\
cnng'
->
(
cnng'
^.
cnng_node_id
)
.==
(
nc
^.
nc_node_id
)
.&&
-- agg <- OAgg.aggregate sumInt4
(
cnng'
^.
cnng_context_id
)
.==
(
c
^.
cs_id
)
-- (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)
returnA
-<
FacetDoc
{
facetDoc_id
=
_cs_id
c
returnA
-<
FacetDoc
{
facetDoc_id
=
_cs_id
c
,
facetDoc_created
=
_cs_date
c
,
facetDoc_created
=
_cs_date
c
,
facetDoc_title
=
_cs_name
c
,
facetDoc_title
=
_cs_name
c
,
facetDoc_hyperdata
=
_cs_hyperdata
c
,
facetDoc_hyperdata
=
_cs_hyperdata
c
,
facetDoc_category
=
nc
^.
nc_category
,
facetDoc_category
=
nc
^.
nc_category
,
facetDoc_ngramCount
=
fromMaybeFields
0
$
_cnng_doc_count
<$>
cnng
-- toNullable $ nc^.nc_score
,
facetDoc_ngramCount
=
fromIntegral
agg
-- , facetDoc_ngramCount = fromMaybeFields 0 $ _cnng_doc_count <$> cnng -- toNullable $ nc^.
nc_score
-- , facetDoc_ngramCount = toNullable $ toFields cnt
-- , facetDoc_ngramCount = toNullable $ toFields cnt
,
facetDoc_score
=
nc
^.
nc_score
,
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
)
-- TODO Join with context_node_ngrams at context_id/node_id and sum by
-- TODO Join with context_node_ngrams at context_id/node_id and sum by
-- doc_count.
-- doc_count.
viewDocumentsQuery
::
CorpusId
viewDocumentsQuery
::
CorpusId
...
...
src/Gargantext/Database/Schema/ContextNodeNgrams.hs
View file @
9dd4e321
...
@@ -18,7 +18,7 @@ Portability : POSIX
...
@@ -18,7 +18,7 @@ Portability : POSIX
module
Gargantext.Database.Schema.ContextNodeNgrams
module
Gargantext.Database.Schema.ContextNodeNgrams
where
where
import
Pr
e
lude
import
Pr
oto
lude
import
Gargantext.Core.Types
(
TermsCount
)
import
Gargantext.Core.Types
(
TermsCount
)
import
Gargantext.Database.Schema.Prelude
import
Gargantext.Database.Schema.Prelude
import
Gargantext.Database.Schema.Ngrams
(
NgramsTypeId
,
NgramsId
)
import
Gargantext.Database.Schema.Ngrams
(
NgramsTypeId
,
NgramsId
)
...
@@ -29,6 +29,11 @@ import Gargantext.Database.Admin.Types.Node
...
@@ -29,6 +29,11 @@ import Gargantext.Database.Admin.Types.Node
type
ContextNodeNgrams
=
type
ContextNodeNgrams
=
ContextNodeNgramsPoly
ContextId
ListId
NgramsId
NgramsTypeId
Double
TermsCount
ContextNodeNgramsPoly
ContextId
ListId
NgramsId
NgramsTypeId
Double
TermsCount
type
ContextNodeNgramsTest
=
ContextNodeNgramsPoly
ContextId
ListId
NgramsId
Int
Double
TermsCount
type
ContextNodeNgramsTest'
=
ContextNodeNgramsPoly
ContextId
ListId
NgramsId
Int
Double
Int64
data
ContextNodeNgramsPoly
c
n
ngrams_id
ngt
w
dc
data
ContextNodeNgramsPoly
c
n
ngrams_id
ngt
w
dc
=
ContextNodeNgrams
{
_cnng_context_id
::
!
c
=
ContextNodeNgrams
{
_cnng_context_id
::
!
c
...
@@ -55,6 +60,22 @@ type ContextNodeNgramsRead =
...
@@ -55,6 +60,22 @@ type ContextNodeNgramsRead =
(
Field
SqlFloat8
)
(
Field
SqlFloat8
)
(
Field
SqlInt4
)
(
Field
SqlInt4
)
type
ContextNodeNgramsAgg
=
ContextNodeNgramsPoly
(
Field
SqlInt4
)
(
Field
SqlInt4
)
(
Field
SqlInt4
)
(
Field
SqlInt4
)
(
Field
SqlFloat8
)
(
Field
SqlInt8
)
type
ContextNodeNgramsAggPart
=
ContextNodeNgramsPoly
(
Field
SqlInt4
)
(
Field
SqlInt4
)
(
Field
SqlInt4
)
(
Field
SqlInt4
)
(
Field
SqlFloat8
)
(
Field
SqlInt4
)
$
(
makeAdaptorAndInstance
"pContextNodeNgrams"
''
C
ontextNodeNgramsPoly
)
$
(
makeAdaptorAndInstance
"pContextNodeNgrams"
''
C
ontextNodeNgramsPoly
)
makeLenses
''
C
ontextNodeNgramsPoly
makeLenses
''
C
ontextNodeNgramsPoly
...
...
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