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
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
Julien Moutinho
haskell-gargantext
Commits
88489429
Commit
88489429
authored
Jul 24, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Pairing] clean code
parent
a3e0a249
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
17 deletions
+12
-17
Pairing.hs
src/Gargantext/Database/Action/Flow/Pairing.hs
+12
-17
No files found.
src/Gargantext/Database/Action/Flow/Pairing.hs
View file @
88489429
...
@@ -16,35 +16,34 @@ module Gargantext.Database.Action.Flow.Pairing
...
@@ -16,35 +16,34 @@ module Gargantext.Database.Action.Flow.Pairing
-- (pairing)
-- (pairing)
where
where
import
Gargantext.Database.Action.Metrics.NgramsByNode
(
getNodesByNgramsOnlyUser
)
import
Debug.Trace
(
trace
)
import
Data.Set
(
Set
)
import
Control.Lens
(
_Just
,
(
^.
))
import
Control.Lens
(
_Just
,
(
^.
))
import
Data.Map
(
Map
,
fromList
,
fromListWith
)
import
Data.Map
(
Map
,
fromList
,
fromListWith
)
import
Data.Maybe
(
catMaybes
,
fromMaybe
)
import
Data.Maybe
(
catMaybes
,
fromMaybe
)
import
Data.Text
(
Text
,
toLower
)
import
Data.Set
(
Set
)
import
Data.Text
(
Text
)
import
Gargantext.API.Ngrams.Tools
import
Gargantext.API.Prelude
(
GargNoServer
)
import
Gargantext.Core.Types
(
TableResult
(
..
),
Term
)
import
Gargantext.Core.Types
(
TableResult
(
..
),
Term
)
import
Gargantext.Database
import
Gargantext.Core.Types.Main
import
Gargantext.Core.Types.Main
import
Gargantext.API.Prelude
(
GargNoServer
)
import
Gargantext.Database
import
Gargantext.Database.Action.Metrics.NgramsByNode
(
getNodesByNgramsOnlyUser
)
import
Gargantext.Database.Admin.Config
import
Gargantext.Database.Admin.Config
import
Gargantext.Database.Admin.Config
(
nodeTypeId
)
import
Gargantext.Database.Admin.Types.Hyperdata
-- (HyperdataContact(..))
import
Gargantext.Database.Admin.Types.Hyperdata
-- (HyperdataContact(..))
import
Gargantext.Database.Admin.Types.Node
-- (AnnuaireId, CorpusId, ListId, DocId, ContactId, NodeId)
import
Gargantext.Database.Admin.Types.Node
-- (AnnuaireId, CorpusId, ListId, DocId, ContactId, NodeId)
import
Gargantext.Database.Prelude
(
Cmd
,
runOpaQuery
)
import
Gargantext.Database.Prelude
(
Cmd
,
runOpaQuery
)
import
Gargantext.Database.Query.Prelude
(
leftJoin2
,
returnA
,
queryNodeNodeTable
)
import
Gargantext.Database.Query.Prelude
(
leftJoin2
,
returnA
,
queryNodeNodeTable
)
import
Gargantext.Database.Query.Table.Node.Children
(
getAllContacts
)
import
Gargantext.Database.Query.Table.Node.Children
(
getAllContacts
)
import
Gargantext.API.Ngrams.Tools
import
Gargantext.Database.Query.Table.Node.Select
(
selectNodesWithUsername
)
import
Gargantext.Database.Query.Table.Node.Select
(
selectNodesWithUsername
)
import
Gargantext.Database.Schema.Ngrams
-- (NgramsType(..))
import
Gargantext.Database.Schema.Ngrams
-- (NgramsType(..))
import
Gargantext.Database.Admin.Config
(
nodeTypeId
)
import
Gargantext.Database.Schema.Node
import
Gargantext.Database.Schema.Node
import
Gargantext.Prelude
hiding
(
sum
)
import
Gargantext.Prelude
hiding
(
sum
)
import
Opaleye
import
Safe
(
lastMay
)
import
Safe
(
lastMay
)
import
qualified
Data.List
as
List
import
qualified
Data.List
as
List
import
qualified
Data.Map
as
Map
import
qualified
Data.Map
as
Map
import
qualified
Data.Text
as
DT
import
qualified
Data.Set
as
Set
import
qualified
Data.Set
as
Set
import
Opaleye
import
qualified
Data.Text
as
DT
-- | isPairedWith
-- | isPairedWith
...
@@ -71,7 +70,7 @@ isPairedWith nt nId = runOpaQuery (selectQuery nt nId)
...
@@ -71,7 +70,7 @@ isPairedWith nt nId = runOpaQuery (selectQuery nt nId)
-----------------------------------------------------------------------
-----------------------------------------------------------------------
pairing
::
AnnuaireId
->
CorpusId
->
ListId
->
GargNoServer
Int
pairing
::
AnnuaireId
->
CorpusId
->
ListId
->
GargNoServer
Int
pairing
a
c
l
=
do
pairing
a
c
l
=
do
dataPaired
<-
dataPairing
a
(
c
,
l
,
Authors
)
lastName
last
Name
dataPaired
<-
dataPairing
a
(
c
,
l
,
Authors
)
takeName
take
Name
insertDB
$
prepareInsert
dataPaired
insertDB
$
prepareInsert
dataPaired
...
@@ -115,12 +114,8 @@ projectionFrom ss f = fromList $ map (\s -> (s, f s)) (Set.toList ss)
...
@@ -115,12 +114,8 @@ projectionFrom ss f = fromList $ map (\s -> (s, f s)) (Set.toList ss)
projectionTo
::
Set
DocAuthor
->
(
DocAuthor
->
Projected
)
->
Map
Projected
(
Set
DocAuthor
)
projectionTo
::
Set
DocAuthor
->
(
DocAuthor
->
Projected
)
->
Map
Projected
(
Set
DocAuthor
)
projectionTo
ss
f
=
fromListWith
(
<>
)
$
map
(
\
s
->
(
f
s
,
Set
.
singleton
s
))
(
Set
.
toList
ss
)
projectionTo
ss
f
=
fromListWith
(
<>
)
$
map
(
\
s
->
(
f
s
,
Set
.
singleton
s
))
(
Set
.
toList
ss
)
------------------------------------------------------------------------
------------------------------------------------------------------------
namePolicy
::
Term
->
Term
takeName
::
Term
->
Term
namePolicy
x
=
trace
(
show
x
)
$
toLower
x
takeName
texte
=
DT
.
toLower
texte'
lastName
::
Term
->
Term
lastName
texte
=
DT
.
toLower
texte'
where
where
texte'
=
maybe
texte
(
\
x
->
if
DT
.
length
x
>
3
then
x
else
texte
)
texte'
=
maybe
texte
(
\
x
->
if
DT
.
length
x
>
3
then
x
else
texte
)
(
lastName'
texte
)
(
lastName'
texte
)
...
...
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