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
158
Issues
158
List
Board
Labels
Milestones
Merge Requests
11
Merge Requests
11
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
410f4e06
Commit
410f4e06
authored
Oct 24, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[DBFLOW] Taks list + cosmetics + mkNodeList.
parent
ca8ff794
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
43 deletions
+58
-43
Flow.hs
src/Gargantext/Database/Flow.hs
+14
-13
Node.hs
src/Gargantext/Database/Node.hs
+2
-0
NodeNgram.hs
src/Gargantext/Database/NodeNgram.hs
+5
-1
NodeNgramNgram.hs
src/Gargantext/Database/NodeNgramNgram.hs
+37
-29
No files found.
src/Gargantext/Database/Flow.hs
View file @
410f4e06
...
...
@@ -93,8 +93,8 @@ flow fp = do
runCmd'
$
del
[
corpusId2
,
corpusId
]
----------------------------------------------------------------
type
HashId
=
Tex
t
type
HashId
=
Text
type
NodeId
=
In
t
type
ToInsert
=
Map
HashId
HyperdataDocument
type
Inserted
=
Map
HashId
ReturnId
...
...
@@ -111,7 +111,6 @@ data DocumentWithId = DocumentWithId { documentId :: NodeId
,
documentData
::
HyperdataDocument
}
type
NodeId
=
Int
mergeData
::
Map
HashId
ReturnId
->
Map
HashId
HyperdataDocument
->
[
DocumentWithId
]
mergeData
rs
hs
=
map
(
\
(
hash
,
r
)
->
DocumentWithId
(
reId
r
)
(
lookup'
hash
hs
))
$
DM
.
toList
rs
...
...
@@ -123,7 +122,6 @@ data DocumentIdWithNgrams = DocumentIdWithNgrams { documentWithId :: DocumentWi
}
documentIdWithNgrams
::
(
HyperdataDocument
->
Map
(
NgramsT
Ngrams
)
Int
)
->
[
DocumentWithId
]
->
[
DocumentIdWithNgrams
]
documentIdWithNgrams
f
=
map
(
\
d
->
DocumentIdWithNgrams
d
((
f
.
documentData
)
d
))
...
...
@@ -143,19 +141,22 @@ indexNgrams ng2nId = do
insertToNodeNgrams
::
Map
(
NgramsT
NgramsIndexed
)
(
Map
NodeId
Int
)
->
Cmd
Int
insertToNodeNgrams
m
=
insertNodeNgrams
$
[
NodeNgram
Nothing
nId
((
_ngramsId
.
_ngramsT
)
ng
)
(
fromIntegral
n
)
((
ngramsTypeId
.
_ngramsType
)
ng
)
|
(
ng
,
nId2int
)
<-
DM
.
toList
m
,
(
nId
,
n
)
<-
DM
.
toList
nId2int
]
insertToNodeNgrams
m
=
insertNodeNgrams
$
[
NodeNgram
Nothing
nId
((
_ngramsId
.
_ngramsT
)
ng
)
(
fromIntegral
n
)
((
ngramsTypeId
.
_ngramsType
)
ng
)
|
(
ng
,
nId2int
)
<-
DM
.
toList
m
,
(
nId
,
n
)
<-
DM
.
toList
nId2int
]
-- mk List
Group
-- group
b
y fun
-- mk ListGroup
-- group
B
y fun
-- insertInto NodeNgramsNgrams
-- compute Candidate / Map
-- add column typelist
-- insertNodeNodeNgram
-- get data of NgramsTable
--
change List of n
grams
--
post :: update NodeNodeN
grams
-- group ngrams
src/Gargantext/Database/Node.hs
View file @
410f4e06
...
...
@@ -497,4 +497,6 @@ mkRoot uId = case uId > 0 of
mkCorpus
::
Maybe
Name
->
Maybe
HyperdataCorpus
->
ParentId
->
UserId
->
Cmd
[
Int
]
mkCorpus
n
h
p
u
=
insertNodesR'
[
nodeCorpusW
n
h
p
u
]
--mkNodeGroupList :: Maybe HyperdataAny -> ParentId -> UserId -> Cmd [Int]
--mkNodeGroupList h p u = insertNodesR' [nodeCorpusW (Just "Group List" h p u)]
src/Gargantext/Database/NodeNgram.hs
View file @
410f4e06
...
...
@@ -69,7 +69,11 @@ queryNodeNgramTable :: Query NodeNgramRead
queryNodeNgramTable
=
queryTable
nodeNgramTable
insertNodeNgrams
::
[
NodeNgram
]
->
Cmd
Int
insertNodeNgrams
nns
=
insertNodeNgramW
$
map
(
\
(
NodeNgram
i
n
g
w
t
)
->
NodeNgram
Nothing
(
pgInt4
n
)
(
pgInt4
g
)
(
pgDouble
w
)
(
pgInt4
t
)
)
nns
insertNodeNgrams
=
insertNodeNgramW
.
map
(
\
(
NodeNgram
_
n
g
w
t
)
->
NodeNgram
Nothing
(
pgInt4
n
)
(
pgInt4
g
)
(
pgDouble
w
)
(
pgInt4
t
)
)
insertNodeNgramW
::
[
NodeNgramWrite
]
->
Cmd
Int
insertNodeNgramW
nns
=
mkCmd
$
\
c
->
fromIntegral
<$>
runInsertMany
c
nodeNgramTable
nns
...
...
src/Gargantext/Database/NodeNgramNgram.hs
View file @
410f4e06
...
...
@@ -21,7 +21,7 @@ commentary with @some markup@.
module
Gargantext.Database.NodeNgramNgram
where
import
Prelude
import
Gargantext.
Prelude
import
Data.Maybe
(
Maybe
)
import
Data.Profunctor.Product.TH
(
makeAdaptorAndInstance
)
import
Control.Lens.TH
(
makeLensesWith
,
abbreviatedFields
)
...
...
@@ -29,42 +29,48 @@ import qualified Database.PostgreSQL.Simple as PGS
import
Opaleye
data
NodeNgramNgramPoly
node_id
ngram1_id
ngram2_id
weight
=
NodeNgramNgram
{
nodeNgramNgram_NodeNgramNgram
_NodeId
::
node_id
,
nodeNgramNgram_NodeNgramNgram
_Ngram1Id
::
ngram1_id
,
nodeNgramNgram_NodeNgramNgram
_Ngram2Id
::
ngram2_id
,
nodeNgramNgram_NodeNgramNgram
_Weight
::
weight
}
deriving
(
Show
)
data
NodeNgramNgramPoly
node_id
ngram1_id
ngram2_id
weight
=
NodeNgramNgram
{
nng
_NodeId
::
node_id
,
nng
_Ngram1Id
::
ngram1_id
,
nng
_Ngram2Id
::
ngram2_id
,
nng
_Weight
::
weight
}
deriving
(
Show
)
type
NodeNgramNgramWrite
=
NodeNgramNgramPoly
(
Maybe
(
Column
PGInt4
))
(
Column
PGInt4
)
(
Column
PGInt4
)
(
Maybe
(
Column
PGFloat8
))
type
NodeNgramNgramWrite
=
NodeNgramNgramPoly
(
Maybe
(
Column
PGInt4
))
(
Column
PGInt4
)
(
Column
PGInt4
)
(
Maybe
(
Column
PGFloat8
))
type
NodeNgramNgramRead
=
NodeNgramNgramPoly
(
Column
PGInt4
)
(
Column
PGInt4
)
(
Column
PGInt4
)
(
Column
PGFloat8
)
type
NodeNgramNgramRead
=
NodeNgramNgramPoly
(
Column
PGInt4
)
(
Column
PGInt4
)
(
Column
PGInt4
)
(
Column
PGFloat8
)
type
NodeNgramNgram
=
NodeNgramNgramPoly
(
Maybe
Int
)
Int
Int
(
Maybe
Double
)
type
NodeNgramNgram
=
NodeNgramNgramPoly
(
Maybe
Int
)
Int
Int
(
Maybe
Double
)
$
(
makeAdaptorAndInstance
"pNodeNgramNgram"
''
N
odeNgramNgramPoly
)
$
(
makeLensesWith
abbreviatedFields
''
N
odeNgramNgramPoly
)
$
(
makeAdaptorAndInstance
"pNodeNgramNgram"
''
N
odeNgramNgramPoly
)
$
(
makeLensesWith
abbreviatedFields
''
N
odeNgramNgramPoly
)
nodeNgramNgramTable
::
Table
NodeNgramNgramWrite
NodeNgramNgramRead
nodeNgramNgramTable
=
Table
"nodes_ngrams_ngrams"
(
pNodeNgramNgram
NodeNgramNgram
{
nodeNgramNgram_NodeNgramNgram_NodeId
=
optional
"node_id"
,
nodeNgramNgram_NodeNgramNgram_Ngram1Id
=
required
"ngram1_id"
,
nodeNgramNgram_NodeNgramNgram_Ngram2Id
=
required
"ngram2_id"
,
nodeNgramNgram_NodeNgramNgram_Weight
=
optional
"weight"
}
)
nodeNgramNgramTable
=
Table
"nodes_ngrams_ngrams"
(
pNodeNgramNgram
NodeNgramNgram
{
nng_NodeId
=
optional
"node_id"
,
nng_Ngram1Id
=
required
"ngram1_id"
,
nng_Ngram2Id
=
required
"ngram2_id"
,
nng_Weight
=
optional
"weight"
}
)
queryNodeNgramNgramTable
::
Query
NodeNgramNgramRead
queryNodeNgramNgramTable
=
queryTable
nodeNgramNgramTable
...
...
@@ -78,3 +84,5 @@ instance QueryRunnerColumnDefault PGInt4 (Maybe Int) where
instance
QueryRunnerColumnDefault
PGFloat8
(
Maybe
Double
)
where
queryRunnerColumnDefault
=
fieldQueryRunnerColumn
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