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
163
Issues
163
List
Board
Labels
Milestones
Merge Requests
9
Merge Requests
9
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
f280b7e1
Commit
f280b7e1
authored
May 26, 2025
by
Alfredo Di Napoli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor cleanup of flow functions
parent
64987614
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
16 deletions
+22
-16
Flow.hs
src/Gargantext/Database/Action/Flow.hs
+5
-5
Utils.hs
src/Gargantext/Database/Action/Flow/Utils.hs
+17
-11
No files found.
src/Gargantext/Database/Action/Flow.hs
View file @
f280b7e1
...
...
@@ -87,7 +87,7 @@ import Gargantext.Core.Types.Main ( ListType(MapTerm) )
import
Gargantext.Database.Action.Flow.Extract
()
-- ExtractNgramsT instances
import
Gargantext.Database.Action.Flow.List
(
flowList_DbRepo
,
toNodeNgramsW'
)
import
Gargantext.Database.Action.Flow.Types
(
do_api
,
DataOrigin
(
..
),
DataText
(
..
),
FlowCorpus
)
import
Gargantext.Database.Action.Flow.Utils
(
documentIdWithNgrams
,
insertDocNgrams
,
insertDocs
,
mapNodeIdNgrams
,
ngramsByDoc
)
import
Gargantext.Database.Action.Flow.Utils
(
insertDocNgrams
,
insertDocs
,
mkNodeIdNgramsMap
,
ngramsByDoc
,
mapDocumentIdWithNgrams
)
import
Gargantext.Database.Action.Metrics
(
updateNgramsOccurrences
,
updateContextScore
)
import
Gargantext.Database.Action.Search
(
searchDocInDatabase
)
import
Gargantext.Database.Admin.Types.Hyperdata.Contact
(
HyperdataContact
)
...
...
@@ -441,15 +441,15 @@ insertMasterDocs cfg nlpServer c lang hs = do
-- add documents to the corpus (create node_node link)
-- this will enable global database monitoring
mapNgramsDocs'
::
HashMap
.
HashMap
ExtractedNgrams
(
Map
NgramsType
(
Map
NodeId
(
TermsWeight
,
TermsCount
)))
<-
m
apNodeIdNgrams
<$>
d
ocumentIdWithNgrams
ngramsDocsMap
::
HashMap
.
HashMap
ExtractedNgrams
(
Map
NgramsType
(
Map
NodeId
(
TermsWeight
,
TermsCount
)))
<-
m
kNodeIdNgramsMap
<$>
mapD
ocumentIdWithNgrams
(
extractNgrams
nlpServer
$
withLang
lang
documentsWithId
)
(
map
(
B
.
first
contextId2NodeId
)
documentsWithId
)
runDBTx
$
do
lId
<-
getOrMkList
masterCorpusId
masterUserId
_
<-
saveDocNgramsWith
lId
mapNgramsDocs'
_
<-
saveDocNgramsWith
lId
ngramsDocsMap
pure
$
map
contextId2NodeId
ids'
...
...
src/Gargantext/Database/Action/Flow/Utils.hs
View file @
f280b7e1
...
...
@@ -12,9 +12,10 @@ Portability : POSIX
module
Gargantext.Database.Action.Flow.Utils
(
docNgrams
,
documentIdWithNgrams
,
mapDocumentIdWithNgrams
,
insertDocNgrams
,
insertDocs
,
m
apNodeIdNgrams
,
m
kNodeIdNgramsMap
,
ngramsByDoc
)
where
...
...
@@ -38,7 +39,6 @@ import Gargantext.Database.Prelude
import
Gargantext.Database.Query.Table.ContextNodeNgrams
(
ContextNodeNgramsPoly
(
..
),
insertContextNodeNgrams
)
import
Gargantext.Database.Query.Table.Node.Document.Add
qualified
as
Doc
(
add
)
import
Gargantext.Database.Query.Table.Node.Document.Insert
(
ReturnId
,
addUniqId
,
insertDb
,
reId
,
reInserted
,
reUniqId
)
import
Gargantext.Database.Query.Table.Node.Error
(
HasNodeError
(
..
))
import
Gargantext.Database.Schema.Context
(
context_oid_hyperdata
,
context_oid_id
)
import
Gargantext.Database.Schema.Ngrams
(
NgramsId
,
NgramsTypeId
(
..
),
text2ngrams
)
import
Gargantext.Database.Types
(
Indexed
(
..
),
index
)
...
...
@@ -85,26 +85,32 @@ docNgrams lang ts doc =
)
documentIdWithNgrams
::
HasNodeError
err
=>
(
a
->
DBCmd
err
(
HashMap
.
HashMap
b
(
Map
NgramsType
TermsWeight
,
TermsCount
))
)
->
[
Indexed
NodeId
a
]
->
DBCmd
err
[
DocumentIdWithNgrams
a
b
]
documentIdWithNgrams
f
=
traverse
toDocumentIdWithNgrams
documentIdWithNgrams
::
Monad
m
=>
(
a
->
m
(
HashMap
.
HashMap
b
(
Map
NgramsType
TermsWeight
,
TermsCount
))
)
->
Indexed
NodeId
a
->
m
(
DocumentIdWithNgrams
a
b
)
documentIdWithNgrams
f
=
toDocumentIdWithNgrams
where
toDocumentIdWithNgrams
d
=
do
e
<-
f
$
_unIndex
d
pure
$
DocumentIdWithNgrams
d
e
mapDocumentIdWithNgrams
::
Monad
m
=>
(
a
->
m
(
HashMap
.
HashMap
b
(
Map
NgramsType
TermsWeight
,
TermsCount
))
)
->
[
Indexed
NodeId
a
]
->
m
[
DocumentIdWithNgrams
a
b
]
mapDocumentIdWithNgrams
f
=
mapM
(
documentIdWithNgrams
f
)
-- | TODO check optimization
mapNodeIdNgrams
::
(
Ord
b
,
Hashable
b
)
-- | Creates a NodeIdNgrams map out of the input 'DocumentIdWithNgrams' list.
-- TODO check optimization
mkNodeIdNgramsMap
::
(
Ord
b
,
Hashable
b
)
=>
[
DocumentIdWithNgrams
a
b
]
->
HashMap
.
HashMap
b
(
Map
NgramsType
(
Map
NodeId
(
TermsWeight
,
TermsCount
))
)
m
apNodeIdNgrams
=
HashMap
.
unionsWith
(
DM
.
unionWith
(
DM
.
unionWith
addTuples
))
.
fmap
f
m
kNodeIdNgramsMap
=
HashMap
.
unionsWith
(
DM
.
unionWith
(
DM
.
unionWith
addTuples
))
.
fmap
f
where
-- | NOTE We are somehow multiplying 'TermsCount' here: If the
-- same ngrams term has different ngrams types, the 'TermsCount'
...
...
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