Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
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
Przemyslaw Kaminski
haskell-gargantext
Commits
1453190a
Commit
1453190a
authored
Mar 02, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FACET] adding ngrams count to the type and the mock.
parent
88944266
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
85 additions
and
81 deletions
+85
-81
Facet.hs
src/Gargantext/Database/Facet.hs
+85
-81
No files found.
src/Gargantext/Database/Facet.hs
View file @
1453190a
...
...
@@ -60,65 +60,69 @@ import Gargantext.Utils.Prefix (unPrefix)
------------------------------------------------------------------------
-- | DocFacet
type
FacetDoc
=
Facet
NodeId
UTCTime
HyperdataDocument
Bool
-- Double
--type FacetDoc = Facet NodeId UTCTime HyperdataDocument Bool -- Double
--
--data Facet id created hyperdata favorite =
-- FacetDoc { facetDoc_id :: id
-- , facetDoc_created :: created
-- , facetDoc_hyperdata :: hyperdata
-- , facetDoc_favorite :: favorite
-- } deriving (Show, Generic)
-- $(deriveJSON (unPrefix "facetDoc_") ''Facet)
--
--instance Arbitrary FacetDoc where
-- arbitrary = elements [ FacetDoc id' (jour year 01 01) hp fav
-- | id' <- [ 1..10 ]
-- , year <- [1990..2000 ]
-- , fav <- [True, False]
-- , hp <- hyperdataDocuments
-- ]
--
--instance ToSchema FacetDoc
--
---- Facets / Views for the Front End
--type FacetDocRead = Facet (Column PGInt4 )
-- (Column PGTimestamptz)
-- (Column PGJsonb )
-- (Column PGBool ) -- (Column PGFloat8)
--
-- $(makeAdaptorAndInstance "pFacetDoc" ''Facet)
-- $(makeLensesWith abbreviatedFields ''Facet)
--
------------------------------------------------------------------------
type
FacetDoc
=
Facet
NodeId
UTCTime
HyperdataDocument
Bool
Int
data
Facet
id
created
hyperdata
favorite
=
data
Facet
id
created
hyperdata
favorite
ngramCount
=
FacetDoc
{
facetDoc_id
::
id
,
facetDoc_created
::
created
,
facetDoc_hyperdata
::
hyperdata
,
facetDoc_favorite
::
favorite
}
deriving
(
Show
,
Generic
)
,
facetDoc_created
::
created
,
facetDoc_hyperdata
::
hyperdata
,
facetDoc_favorite
::
favorite
,
facetDoc_ngramCount
::
ngramCount
}
deriving
(
Show
,
Generic
)
$
(
deriveJSON
(
unPrefix
"facetDoc_"
)
''
F
acet
)
instance
Arbitrary
FacetDoc
where
arbitrary
=
elements
[
FacetDoc
id'
(
jour
year
01
01
)
hp
fav
|
id'
<-
[
1
..
10
]
,
year
<-
[
1990
..
2000
]
,
fav
<-
[
True
,
False
]
,
hp
<-
hyperdataDocuments
]
instance
ToSchema
FacetDoc
-- Facets / Views for the Front End
type
FacetDocRead
=
Facet
(
Column
PGInt4
)
(
Column
PGTimestamptz
)
(
Column
PGJsonb
)
(
Column
PGBool
)
-- (Column PGFloat8)
$
(
makeAdaptorAndInstance
"pFacetDoc"
''
F
acet
)
$
(
makeLensesWith
abbreviatedFields
''
F
acet
)
------------------------------------------------------------------------
type
FacetDoc'
=
Facet'
NodeId
UTCTime
HyperdataDocument
Bool
Int
data
Facet'
id
created
hyperdata
favorite
ngramCount
=
FacetDoc'
{
facetDocP_id
::
id
,
facetDocP_created
::
created
,
facetDocP_hyperdata
::
hyperdata
,
facetDocP_favorite
::
favorite
,
facetDocP_ngramCount
::
ngramCount
}
deriving
(
Show
)
$
(
deriveJSON
(
unPrefix
"facetDocP_"
)
''
F
acet'
)
instance
Arbitrary
FacetDoc'
where
arbitrary
=
elements
[
FacetDoc'
id'
(
jour
year
01
01
)
hp
fav
ngramCount
arbitrary
=
elements
[
FacetDoc
id'
(
jour
year
01
01
)
hp
fav
ngramCount
|
id'
<-
[
1
..
10
]
,
year
<-
[
1990
..
2000
]
,
hp
<-
hyperdataDocuments
,
fav
<-
[
True
,
False
]
,
ngramCount
<-
[
1
..
1
0
]
,
ngramCount
<-
[
3
..
10
0
]
]
-- Facets / Views for the Front End
type
FacetDocRead'
=
Facet'
(
Column
PGInt4
)
(
Column
PGTimestamptz
)
(
Column
PGJsonb
)
(
Column
PGBool
)
(
Column
PGInt4
)
type
FacetDocRead
=
Facet
(
Column
PGInt4
)
(
Column
PGTimestamptz
)
(
Column
PGJsonb
)
(
Column
PGBool
)
(
Column
PGInt4
)
instance
ToSchema
FacetDoc
$
(
makeAdaptorAndInstance
"pFacetDoc
P"
''
F
acet'
)
$
(
makeLensesWith
abbreviatedFields
''
F
acet'
)
$
(
makeAdaptorAndInstance
"pFacetDoc
"
''
F
acet
)
$
(
makeLensesWith
abbreviatedFields
''
F
acet
)
------------------------------------------------------------------------
...
...
@@ -213,13 +217,13 @@ leftJoin3''' = leftJoin3 queryNodeNodeTable queryNodeTable queryNodeTable cond12
=
((
.==
)
(
nId
)
(
nId'
))
getDocTest'
::
Connection
->
IO
[
FacetDoc'
]
getDocTest'
conn
=
runQuery
conn
selectDocFacet''
-- getDocTest :: Connection -> IO [FacetDoc
]
-- getDocTest conn = runQuery conn selectDocFacet
-- | Building the facet
-- selectDocFacet' :: ParentId -> Maybe NodeType -> Query FacetDocRead
selectDocFacet'
'
::
Query
FacetDocRead'
selectDocFacet'
'
=
proc
()
->
do
selectDocFacet'
::
ParentId
->
Maybe
NodeType
->
Query
FacetDocRead
selectDocFacet'
_
_
=
proc
()
->
do
(
n1
,(
nn
,
n2
))
<-
leftJoin3'''
-<
()
restrict
-<
(
.&&
)
(
node_parentId
n1
.==
(
toNullable
$
pgInt4
347476
))
(
node_typename
n1
.==
(
pgInt4
4
))
...
...
@@ -232,8 +236,7 @@ selectDocFacet'' = proc () -> do
let
isFav
=
ifThenElse
(
isNull
$
nodeNode_score
nn
)
(
pgBool
False
)
(
pgBool
True
)
--
returnA
-<
FacetDoc'
(
node_id
n1
)
(
node_date
n1
)
(
node_hyperdata
n1
)
(
isFav
)
(
pgInt4
1
)
returnA
-<
FacetDoc
(
node_id
n1
)
(
node_date
n1
)
(
node_hyperdata
n1
)
(
isFav
)
(
pgInt4
1
)
...
...
@@ -247,32 +250,33 @@ selectDocFacet'' = proc () -> do
selectDocFacet'
::
ParentId
->
Maybe
NodeType
->
Query
FacetDocRead
selectDocFacet'
parentId
_
=
proc
()
->
do
node
<-
(
proc
()
->
do
-- Favorite Column
-- (Node docId docTypeId _ docParentId _ created docHyperdata, (Node _ favTypeId _ favParentId _ _ _, NodeNode _ docId' _)) <- leftJoin3'' -< ()
(
Node
docId
docTypeId
_
docParentId
_
created
docHyperdata
,
(
NodeNode
_
docId'
_
,
(
Node
_
favTypeId
_
favParentId
_
_
_
)))
<-
leftJoin3'''
-<
()
restrict
-<
docTypeId
.==
(
pgInt4
15
)
.&&
docParentId
.==
(
toNullable
$
pgInt4
parentId
)
-- select nn.score from nodes n left join nodes_nodes nn on n.id = nn.node2_id where n.typename =4;
-- Selecting the documents and joining Favorite Node
restrict
-<
favParentId
.==
(
toNullable
$
pgInt4
parentId
)
.&&
favTypeId
.==
(
toNullable
4
)
-- let docTypeId'' = maybe 0 nodeTypeId (Just Document)
-- Getting favorite data
let
isFav
=
ifThenElse
(
isNull
docId'
)
(
pgBool
False
)
(
pgBool
True
)
-- Ngram count by document
-- Counting the ngram
-- (Node occId occTypeId _ _ _ _ _, NodeNode _ _ _ count) <- nodeNodeNgramLeftJoin -< ()
-- restrict -< occId .== 347540
--returnA -< (FacetDoc n_id hyperdata isFav ngramCount)) -< ()
returnA
-<
(
FacetDoc
docId
created
docHyperdata
isFav
))
-<
()
returnA
-<
node
--
--
--selectDocFacet' :: ParentId -> Maybe NodeType -> Query FacetDocRead
--selectDocFacet' parentId _ = proc () -> do
-- node <- (proc () -> do
--
-- -- Favorite Column
-- -- (Node docId docTypeId _ docParentId _ created docHyperdata, (Node _ favTypeId _ favParentId _ _ _, NodeNode _ docId' _)) <- leftJoin3'' -< ()
-- (Node docId docTypeId _ docParentId _ created docHyperdata, (NodeNode _ docId' _, (Node _ favTypeId _ favParentId _ _ _))) <- leftJoin3''' -< ()
--
-- restrict -< docTypeId .== (pgInt4 15) .&& docParentId .== (toNullable $ pgInt4 parentId)
--
-- -- select nn.score from nodes n left join nodes_nodes nn on n.id = nn.node2_id where n.typename =4;
-- -- Selecting the documents and joining Favorite Node
--
-- restrict -< favParentId .== (toNullable $ pgInt4 parentId) .&& favTypeId .== (toNullable 4)
--
-- -- let docTypeId'' = maybe 0 nodeTypeId (Just Document)
--
-- -- Getting favorite data
-- let isFav = ifThenElse (isNull docId') (pgBool False) (pgBool True)
-- -- Ngram count by document
-- -- Counting the ngram
-- -- (Node occId occTypeId _ _ _ _ _, NodeNode _ _ _ count) <- nodeNodeNgramLeftJoin -< ()
-- -- restrict -< occId .== 347540
--
-- --returnA -< (FacetDoc n_id hyperdata isFav ngramCount)) -< ()
-- returnA -< (FacetDoc docId created docHyperdata isFav)) -< ()
-- returnA -< node
--
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