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
57cc77e9
Commit
57cc77e9
authored
Jan 18, 2022
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[CLEAN] unused functions after check of Graph computation
parent
40fad03b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
140 deletions
+7
-140
NgramsByContext.hs
src/Gargantext/Database/Action/Metrics/NgramsByContext.hs
+7
-140
No files found.
src/Gargantext/Database/Action/Metrics/NgramsByContext.hs
View file @
57cc77e9
...
...
@@ -96,18 +96,6 @@ getContextsByNgramsUser cId nt =
------------------------------------------------------------------------
-- TODO add groups
{-
getOccByNgramsOnlyFast :: HasDBid NodeType
=> CorpusId
-> NgramsType
-> [NgramsTerm]
-> Cmd err (HashMap NgramsTerm Int)
getOccByNgramsOnlyFast cId nt ngs =
HM.fromListWith (+) <$> selectNgramsOccurrencesOnlyByContextUser cId nt ngs
-}
getOccByNgramsOnlyFast_withSample
::
HasDBid
NodeType
=>
CorpusId
->
Int
...
...
@@ -156,75 +144,6 @@ getOccByNgramsOnlyFast' cId lId nt tms = -- trace (show (cId, lId)) $
|]
{-
-- just slower than getOccByNgramsOnlyFast
getOccByNgramsOnlySlow :: HasDBid NodeType
=> NodeType
-> CorpusId
-> [ListId]
-> NgramsType
-> [NgramsTerm]
-> Cmd err (HashMap NgramsTerm Int)
getOccByNgramsOnlySlow t cId ls nt ngs =
HM.map Set.size <$> getScore' t cId ls nt ngs
where
getScore' NodeCorpus = getContextsByNgramsOnlyUser
getScore' NodeDocument = getNgramsByDocOnlyUser
getScore' _ = getContextsByNgramsOnlyUser
getOccByNgramsOnlySafe :: HasDBid NodeType
=> CorpusId
-> [ListId]
-> NgramsType
-> [NgramsTerm]
-> Cmd err (HashMap NgramsTerm Int)
getOccByNgramsOnlySafe cId ls nt ngs = do
printDebug "getOccByNgramsOnlySafe" (cId, nt, length ngs)
fast <- getOccByNgramsOnlyFast cId nt ngs
slow <- getOccByNgramsOnlySlow NodeCorpus cId ls nt ngs
when (fast /= slow) $
printDebug "getOccByNgramsOnlySafe: difference"
(HM.difference slow fast, HM.difference fast slow)
-- diff slow fast :: PatchMap Text (Replace (Maybe Int))
pure slow
selectNgramsOccurrencesOnlyByContextUser :: HasDBid NodeType
=> CorpusId
-> NgramsType
-> [NgramsTerm]
-> Cmd err [(NgramsTerm, Int)]
selectNgramsOccurrencesOnlyByContextUser cId nt tms =
fmap (first NgramsTerm) <$>
runPGSQuery queryNgramsOccurrencesOnlyByContextUser
( Values fields ((DPS.Only . unNgramsTerm) <$> tms)
, cId
, toDBid NodeDocument
, ngramsTypeId nt
)
where
fields = [QualifiedIdentifier Nothing "text"]
-- same as queryNgramsOnlyByNodeUser but using COUNT on the node ids.
-- Question: with the grouping is the result exactly the same (since Set NodeId for
-- equivalent ngrams intersections are not empty)
queryNgramsOccurrencesOnlyByContextUser :: DPS.Query
queryNgramsOccurrencesOnlyByContextUser = [sql|
WITH input_rows(terms) AS (?)
SELECT ng.terms, COUNT(cng.context_id) FROM context_node_ngrams cng
JOIN ngrams ng ON cng.ngrams_id = ng.id
JOIN input_rows ir ON ir.terms = ng.terms
JOIN nodes_contexts nn ON nn.context_id = cng.context_id
JOIN nodes n ON nn.node_id = n.id
WHERE nn.node_id = ? -- CorpusId
AND n.typename = ? -- toDBid
AND cng.ngrams_type = ? -- NgramsTypeId
AND nn.category > 0
GROUP BY cng.context_id, ng.terms
|]
-}
selectNgramsOccurrencesOnlyByContextUser_withSample
::
HasDBid
NodeType
=>
CorpusId
->
Int
...
...
@@ -263,23 +182,6 @@ queryNgramsOccurrencesOnlyByContextUser_withSample = [sql|
|]
{-
queryNgramsOccurrencesOnlyByContextUser' :: DPS.Query
queryNgramsOccurrencesOnlyByContextUser' = [sql|
WITH input_rows(terms) AS (?)
SELECT ng.terms, COUNT(cng.node_id) FROM context_node_ngrams cng
JOIN ngrams ng ON cng.ngrams_id = ng.id
JOIN input_rows ir ON ir.terms = ng.terms
JOIN nodes_nodes nn ON nn.node2_id = cng.node_id
JOIN nodes n ON nn.node2_id = n.id
WHERE nn.node1_id = ? -- CorpusId
AND n.typename = ? -- toDBid
AND cng.ngrams_type = ? -- NgramsTypeId
AND nn.category > 0
GROUP BY cng.node_id, ng.terms
|]
-}
------------------------------------------------------------------------
getContextsByNgramsOnlyUser
::
HasDBid
NodeType
...
...
@@ -336,53 +238,18 @@ queryNgramsOnlyByContextUser = [sql|
WITH input_rows(terms) AS (?),
input_list(id) AS (?)
SELECT ng.terms, cng.context_id FROM context_node_ngrams cng
JOIN ngrams
ng
ON cng.ngrams_id = ng.id
JOIN input_rows ir ON ir.terms = ng.terms
JOIN input_list il ON il.id = cng.node_id
JOIN nodes_contexts n
n ON nn
.context_id = cng.context_id
JOIN contexts
c ON nn
.context_id = c.id
WHERE n
n
.node_id = ? -- CorpusId
JOIN ngrams
ng
ON cng.ngrams_id = ng.id
JOIN input_rows
ir ON ir.terms = ng.terms
JOIN input_list
il ON il.id = cng.node_id
JOIN nodes_contexts n
c ON nc
.context_id = cng.context_id
JOIN contexts
c ON nc
.context_id = c.id
WHERE n
c
.node_id = ? -- CorpusId
AND c.typename = ? -- toDBid (maybe not useful with context table)
AND cng.ngrams_type = ? -- NgramsTypeId
AND n
n
.category > 0
AND n
c
.category > 0
GROUP BY ng.terms, cng.context_id
|]
{-
selectNgramsOnlyByContextUser' :: HasDBid NodeType
=> CorpusId
-> [ListId]
-> NgramsType
-> [Text]
-> Cmd err [(Text, Int)]
selectNgramsOnlyByContextUser' cId ls nt tms =
runPGSQuery queryNgramsOnlyByContextUser
( Values fields (DPS.Only <$> tms)
, Values [QualifiedIdentifier Nothing "int4"]
(DPS.Only <$> (map (\(NodeId n) -> n) ls))
, cId
, toDBid NodeDocument
, ngramsTypeId nt
)
where
fields = [QualifiedIdentifier Nothing "text"]
queryNgramsOnlyByContextUser' :: DPS.Query
queryNgramsOnlyByContextUser' = [sql|
WITH input_rows(terms) AS (?),
input_list(id) AS (?)
SELECT ng.terms, cng.weight FROM context_node_ngrams cng
JOIN ngrams ng ON cng.ngrams_id = ng.id
JOIN input_rows ir ON ir.terms = ng.terms
JOIN input_list il ON il.id = cng.node_id
WHERE cng.context_id = ? -- CorpusId
AND cng.ngrams_type = ? -- NgramsTypeId
-- AND nn.category > 0
GROUP BY ng.terms, cng.weight
|]
-}
getNgramsByDocOnlyUser
::
DocId
->
[
ListId
]
->
NgramsType
...
...
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