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
154
Issues
154
List
Board
Labels
Milestones
Merge Requests
14
Merge Requests
14
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
0ad7fc65
Commit
0ad7fc65
authored
Jan 18, 2021
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEAT] SQL fun to get lems
parent
6a3a5ca2
Pipeline
#1352
canceled with stage
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
1 deletion
+26
-1
Prelude.hs
src/Gargantext/Database/Prelude.hs
+0
-1
NgramsPostag.hs
src/Gargantext/Database/Query/Table/NgramsPostag.hs
+26
-0
No files found.
src/Gargantext/Database/Prelude.hs
View file @
0ad7fc65
...
...
@@ -13,7 +13,6 @@ Portability : POSIX
module
Gargantext.Database.Prelude
where
-- import Control.Monad.Error.Class -- (MonadError(..), Error)
import
Control.Exception
import
Control.Lens
(
Getter
,
view
)
import
Control.Monad.Except
...
...
src/Gargantext/Database/Query/Table/NgramsPostag.hs
View file @
0ad7fc65
...
...
@@ -135,3 +135,29 @@ SELECT terms,id FROM ins_form_ret
|]
type
Form
=
Text
type
Lem
=
Text
selectLems
::
[
Ngrams
]
->
Cmd
err
[(
Form
,
Lem
)]
selectLems
ns
=
runPGSQuery
querySelectLems
(
PGS
.
Only
$
Values
fields
(
map
toRow
ns
))
where
fields
=
map
(
\
t
->
QualifiedIdentifier
Nothing
t
)
[
"text"
,
"int4"
]
----------------------
querySelectLems
::
PGS
.
Query
querySelectLems
=
[
sql
|
WITH input_rows(terms,n)
AS (?) -- ((VALUES ('automata' :: "text")))
, lems AS ( select n1.terms as t1 ,n2.terms as t2 ,sum(np.score) as score from input_rows ir
JOIN ngrams n1 ON ir.terms = n1.terms
JOIN ngrams_postag np ON np.ngrams_id = n1.id
JOIN ngrams n2 ON n2.id = np.lemm_id
GROUP BY n1.terms, n2.terms
ORDER BY score DESC
)
SELECT t1,t2 from lems
|]
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