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
Christian Merten
haskell-gargantext
Commits
1c3d5cfd
Commit
1c3d5cfd
authored
Aug 29, 2017
by
Sudhir Kumar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed warnings and upgraded to lts-9.2
parent
8f1a5663
Changes
21
Show whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
242 additions
and
312 deletions
+242
-312
.gitignore
.gitignore
+1
-0
gargantext.cabal
gargantext.cabal
+18
-16
Analysis.hs
src/Data/Gargantext/Analysis.hs
+0
-6
DSL.hs
src/Data/Gargantext/DSL.hs
+0
-18
Database.hs
src/Data/Gargantext/Database.hs
+15
-16
Instances.hs
src/Data/Gargantext/Database/Instances.hs
+4
-7
Ngram.hs
src/Data/Gargantext/Database/Ngram.hs
+7
-17
Node.hs
src/Data/Gargantext/Database/Node.hs
+29
-43
NodeNgram.hs
src/Data/Gargantext/Database/NodeNgram.hs
+20
-22
NodeNgramNgram.hs
src/Data/Gargantext/Database/NodeNgramNgram.hs
+18
-22
NodeNode.hs
src/Data/Gargantext/Database/NodeNode.hs
+8
-16
NodeNodeNgram.hs
src/Data/Gargantext/Database/NodeNodeNgram.hs
+16
-21
User.hs
src/Data/Gargantext/Database/User.hs
+32
-39
Occurrences.hs
src/Data/Gargantext/Parsers/Occurrences.hs
+1
-5
Prelude.hs
src/Data/Gargantext/Prelude.hs
+49
-13
Server.hs
src/Data/Gargantext/Server.hs
+4
-10
Main.hs
src/Data/Gargantext/Types/Main.hs
+9
-12
Node.hs
src/Data/Gargantext/Types/Node.hs
+2
-7
DateUtils.hs
src/Data/Gargantext/Utils/DateUtils.hs
+2
-4
Prefix.hs
src/Data/Gargantext/Utils/Prefix.hs
+5
-13
stack.yaml
stack.yaml
+2
-5
No files found.
.gitignore
0 → 100644
View file @
1c3d5cfd
.stack-work
\ No newline at end of file
gargantext.cabal
View file @
1c3d5cfd
...
@@ -75,7 +75,9 @@ library
...
@@ -75,7 +75,9 @@ library
, Data.Gargantext.Utils.DateUtils
, Data.Gargantext.Utils.DateUtils
, Data.Gargantext.Utils.Prefix
, Data.Gargantext.Utils.Prefix
default-language: Haskell2010
default-language: Haskell2010
ghc-options: -Wall
ghc-options: -Wall -Wincomplete-uni-patterns -Wincomplete-record-updates -Werror
-- -Werror
--executable gargantext-exe
--executable gargantext-exe
-- hs-source-dirs: app
-- hs-source-dirs: app
...
...
src/Data/Gargantext/Analysis.hs
View file @
1c3d5cfd
module
Data.Gargantext.Analysis
where
module
Data.Gargantext.Analysis
where
-- import qualified Data.Text.Lazy as DTL
-- import qualified Data.Text.Lazy as DTL
import
Data.Either.Extra
(
fromRight
)
import
Data.Gargantext.Database.Node
import
Data.Gargantext.Parsers.Occurrences
import
Data.Gargantext.Prelude
import
Data.Gargantext.Types
import
Data.Text
import
Data.Text
import
Opaleye
(
Column
,
PGInt4
)
import
Opaleye
(
Column
,
PGInt4
)
...
@@ -20,4 +15,3 @@ occOfDocument = undefined
...
@@ -20,4 +15,3 @@ occOfDocument = undefined
-- Left str -> error $ "[ERRROR] at file/function/line" ++ str
-- Left str -> error $ "[ERRROR] at file/function/line" ++ str
-- Right xs -> xs
-- Right xs -> xs
-- pure (sum result)
-- pure (sum result)
src/Data/Gargantext/DSL.hs
View file @
1c3d5cfd
module
Data.Gargantext.DSL
where
module
Data.Gargantext.DSL
where
import
Data.Gargantext.Database
import
Data.Gargantext.Prelude
import
Data.Gargantext.Types
import
Data.Text
import
Data.Text
type
Username
=
Text
type
Username
=
Text
...
@@ -37,18 +34,3 @@ type Password = Text
...
@@ -37,18 +34,3 @@ type Password = Text
-- projects :: User -> [Project]
-- projects :: User -> [Project]
-- projects u = undefined
-- projects u = undefined
src/Data/Gargantext/Database.hs
View file @
1c3d5cfd
module
Data.Gargantext.Database
(
module
Data
.
Gargantext
.
Database
.
Private
module
Data.Gargantext.Database
(
,
module
Data
.
Gargantext
.
Database
.
Instances
module
Data
.
Gargantext
.
Database
.
Private
-- , module Data.Gargantext.Database.Instances
,
module
Data
.
Gargantext
.
Database
.
User
,
module
Data
.
Gargantext
.
Database
.
User
,
module
Data
.
Gargantext
.
Database
.
Node
,
module
Data
.
Gargantext
.
Database
.
Node
,
module
Data
.
Gargantext
.
Database
.
NodeNode
,
module
Data
.
Gargantext
.
Database
.
NodeNode
...
@@ -7,14 +8,13 @@ module Data.Gargantext.Database ( module Data.Gargantext.Database.Private
...
@@ -7,14 +8,13 @@ module Data.Gargantext.Database ( module Data.Gargantext.Database.Private
,
module
Data
.
Gargantext
.
Database
.
NodeNgram
,
module
Data
.
Gargantext
.
Database
.
NodeNgram
,
module
Data
.
Gargantext
.
Database
.
NodeNodeNgram
,
module
Data
.
Gargantext
.
Database
.
NodeNodeNgram
,
module
Data
.
Gargantext
.
Database
.
NodeNgramNgram
,
module
Data
.
Gargantext
.
Database
.
NodeNgramNgram
-- , module Data.Gargantext.Database.Gargandb
-- , module Data.Gargantext.Database.Gargandb
-- , module Data.Gargantext.Database.Simple
-- , module Data.Gargantext.Database.Simple
-- , module Data.Gargantext.Database.InsertNode
-- , module Data.Gargantext.Database.InsertNode
-- , module Data.Gargantext.Database.NodeType
-- , module Data.Gargantext.Database.NodeType
)
where
)
where
import
Data.Gargantext.Database.Private
import
Data.Gargantext.Database.Private
import
Data.Gargantext.Database.Instances
--import Data.Gargantext.Database.Gargandb
--import Data.Gargantext.Database.Gargandb
import
Data.Gargantext.Database.User
import
Data.Gargantext.Database.User
import
Data.Gargantext.Database.Node
import
Data.Gargantext.Database.Node
...
@@ -26,4 +26,3 @@ import Data.Gargantext.Database.NodeNgramNgram
...
@@ -26,4 +26,3 @@ import Data.Gargantext.Database.NodeNgramNgram
--import Data.Gargantext.Database.Simple
--import Data.Gargantext.Database.Simple
--import Data.Gargantext.Database.NodeType
--import Data.Gargantext.Database.NodeType
--import Data.Gargantext.Database.InsertNode
--import Data.Gargantext.Database.InsertNode
src/Data/Gargantext/Database/Instances.hs
View file @
1c3d5cfd
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module
Data.Gargantext.Database.Instances
where
module
Data.Gargantext.Database.Instances
where
import
Data.Time
(
UTCTime
)
import
Data.Time
(
UTCTime
)
import
Opaleye
(
Column
,
PGBool
,
PGInt4
,
PGText
,
PGTimestamptz
,
PGFloat8
import
Opaleye
(
PGInt4
,
PGTimestamptz
,
PGFloat8
,
QueryRunnerColumnDefault
,
QueryRunnerColumnDefault
,
queryRunnerColumnDefault
,
queryRunnerColumnDefault
,
fieldQueryRunnerColumn
,
fieldQueryRunnerColumn
...
@@ -21,7 +22,3 @@ instance QueryRunnerColumnDefault PGInt4 (Maybe Int) where
...
@@ -21,7 +22,3 @@ instance QueryRunnerColumnDefault PGInt4 (Maybe Int) where
instance
QueryRunnerColumnDefault
PGTimestamptz
(
Maybe
UTCTime
)
where
instance
QueryRunnerColumnDefault
PGTimestamptz
(
Maybe
UTCTime
)
where
queryRunnerColumnDefault
=
fieldQueryRunnerColumn
queryRunnerColumnDefault
=
fieldQueryRunnerColumn
src/Data/Gargantext/Database/Ngram.hs
View file @
1c3d5cfd
...
@@ -7,24 +7,15 @@
...
@@ -7,24 +7,15 @@
module
Data.Gargantext.Database.Ngram
where
module
Data.Gargantext.Database.Ngram
where
import
Prelude
import
Prelude
import
Data.Time
(
UTCTime
)
import
Data.Text
(
Text
)
import
Data.Text
(
Text
)
import
Data.Maybe
(
Maybe
)
import
Data.Maybe
(
Maybe
)
import
Data.Profunctor.Product.TH
(
makeAdaptorAndInstance
)
import
Data.Profunctor.Product.TH
(
makeAdaptorAndInstance
)
import
Control.Lens.TH
(
makeLensesWith
,
abbreviatedFields
)
import
Control.Lens.TH
(
makeLensesWith
,
abbreviatedFields
)
import
Control.Arrow
(
returnA
)
import
qualified
Database.PostgreSQL.Simple
as
PGS
import
qualified
Database.PostgreSQL.Simple
as
PGS
import
qualified
Opaleye
as
O
import
Opaleye
import
Opaleye
(
Column
,
PGBool
,
PGInt4
,
PGText
,
PGTimestamptz
,
Table
(
Table
),
Query
,
QueryRunnerColumnDefault
,
queryRunnerColumnDefault
,
fieldQueryRunnerColumn
,
(
.==
),
(
.>
)
)
import
Data.Gargantext.Database.Private
(
infoGargandb
)
import
Data.Gargantext.Database.Private
(
infoGargandb
)
import
Data.Gargantext.Database.Instances
-- Functions only
-- Functions only
import
Data.List
(
find
)
import
Data.List
(
find
)
...
@@ -44,16 +35,16 @@ $(makeAdaptorAndInstance "pNgram" ''NgramPoly)
...
@@ -44,16 +35,16 @@ $(makeAdaptorAndInstance "pNgram" ''NgramPoly)
$
(
makeLensesWith
abbreviatedFields
''
N
gramPoly
)
$
(
makeLensesWith
abbreviatedFields
''
N
gramPoly
)
ngramTable
::
O
.
Table
NgramWrite
NgramRead
ngramTable
::
Table
NgramWrite
NgramRead
ngramTable
=
O
.
Table
"ngrams"
(
pNgram
Ngram
{
ngram_id
=
O
.
optional
"id"
ngramTable
=
Table
"ngrams"
(
pNgram
Ngram
{
ngram_id
=
optional
"id"
,
ngram_terms
=
O
.
required
"terms"
,
ngram_terms
=
required
"terms"
,
ngram_n
=
O
.
required
"n"
,
ngram_n
=
required
"n"
}
}
)
)
queryNgramTable
::
Query
NgramRead
queryNgramTable
::
Query
NgramRead
queryNgramTable
=
O
.
queryTable
ngramTable
queryNgramTable
=
queryTable
ngramTable
--selectUsers :: Query UserRead
--selectUsers :: Query UserRead
...
@@ -78,5 +69,4 @@ findWith f t = find (\x -> f x == t)
...
@@ -78,5 +69,4 @@ findWith f t = find (\x -> f x == t)
ngrams
::
IO
[
Ngram
]
ngrams
::
IO
[
Ngram
]
ngrams
=
do
ngrams
=
do
conn
<-
PGS
.
connect
infoGargandb
conn
<-
PGS
.
connect
infoGargandb
O
.
runQuery
conn
queryNgramTable
runQuery
conn
queryNgramTable
src/Data/Gargantext/Database/Node.hs
View file @
1c3d5cfd
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE Arrows #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module
Data.Gargantext.Database.Node
where
module
Data.Gargantext.Database.Node
where
import
Database.PostgreSQL.Simple.FromField
(
Conversion
,
ResultError
(
ConversionFailed
),
FromField
,
fromField
,
returnError
)
import
Database.PostgreSQL.Simple.FromField
(
Conversion
,
ResultError
(
ConversionFailed
),
FromField
,
fromField
,
returnError
)
import
Database.PostgreSQL.Simple.Internal
(
Field
)
import
Database.PostgreSQL.Simple.Internal
(
Field
)
import
Control.Arrow
(
returnA
)
import
Control.Arrow
(
returnA
)
import
Control.Lens.TH
(
makeLensesWith
,
abbreviatedFields
)
import
Control.Lens.TH
(
makeLensesWith
,
abbreviatedFields
)
import
Data.Aeson
import
Data.Aeson
import
Data.Aeson.TH
import
Data.Aeson.Types
import
Data.Gargantext.Database.Instances
import
Data.Gargantext.Database.Private
(
infoGargandb
)
import
Data.Gargantext.Database.Private
(
infoGargandb
)
import
Data.Gargantext.Prelude
import
Data.Gargantext.Types
import
Data.Gargantext.Types
import
Data.Gargantext.Utils.Prefix
import
Data.Maybe
(
Maybe
)
import
Data.Maybe
(
Maybe
)
import
Data.Profunctor.Product.TH
(
makeAdaptorAndInstance
)
import
Data.Profunctor.Product.TH
(
makeAdaptorAndInstance
)
import
Data.Text
(
Text
)
import
Data.Typeable
(
Typeable
)
import
Data.Time
(
UTCTime
)
import
Data.Typeable.Internal
(
Typeable
)
import
GHC.Generics
(
Generic
)
import
qualified
Data.ByteString.Internal
as
DBI
import
qualified
Data.ByteString.Internal
as
DBI
import
qualified
Database.PostgreSQL.Simple
as
PGS
import
qualified
Database.PostgreSQL.Simple
as
PGS
import
qualified
Opaleye
as
O
import
Opaleye
import
Opaleye
(
Column
,
PGBool
,
PGInt4
,
PGText
,
PGTimestamptz
,
PGFloat8
,
Table
(
Table
),
PGJsonb
,
Query
,
QueryRunnerColumnDefault
,
queryRunnerColumnDefault
,
fieldQueryRunnerColumn
,
(
.==
),
(
.>
)
)
-- | Types for Node Database Management
-- | Types for Node Database Management
...
@@ -70,13 +56,13 @@ fromField' field mb = do
...
@@ -70,13 +56,13 @@ fromField' field mb = do
where
where
valueToHyperdata
v
=
case
fromJSON
v
of
valueToHyperdata
v
=
case
fromJSON
v
of
Success
a
->
pure
a
Success
a
->
pure
a
Error
err
->
returnError
ConversionFailed
field
"cannot parse hyperdata"
Error
_
err
->
returnError
ConversionFailed
field
"cannot parse hyperdata"
instance
O
.
QueryRunnerColumnDefault
PGJsonb
HyperdataDocument
where
instance
QueryRunnerColumnDefault
PGJsonb
HyperdataDocument
where
queryRunnerColumnDefault
=
fieldQueryRunnerColumn
queryRunnerColumnDefault
=
fieldQueryRunnerColumn
instance
O
.
QueryRunnerColumnDefault
PGJsonb
HyperdataCorpus
where
instance
QueryRunnerColumnDefault
PGJsonb
HyperdataCorpus
where
queryRunnerColumnDefault
=
fieldQueryRunnerColumn
queryRunnerColumnDefault
=
fieldQueryRunnerColumn
...
@@ -86,55 +72,55 @@ $(makeAdaptorAndInstance "pNode" ''NodePoly)
...
@@ -86,55 +72,55 @@ $(makeAdaptorAndInstance "pNode" ''NodePoly)
$
(
makeLensesWith
abbreviatedFields
''
N
odePoly
)
$
(
makeLensesWith
abbreviatedFields
''
N
odePoly
)
nodeTable
::
O
.
Table
NodeWrite
NodeRead
nodeTable
::
Table
NodeWrite
NodeRead
nodeTable
=
O
.
Table
"nodes"
(
pNode
Node
{
node_id
=
O
.
optional
"id"
nodeTable
=
Table
"nodes"
(
pNode
Node
{
node_id
=
optional
"id"
,
node_typename
=
O
.
required
"typename"
,
node_typename
=
required
"typename"
,
node_userId
=
O
.
required
"user_id"
,
node_userId
=
required
"user_id"
,
node_parentId
=
O
.
required
"parent_id"
,
node_parentId
=
required
"parent_id"
,
node_name
=
O
.
required
"name"
,
node_name
=
required
"name"
,
node_date
=
O
.
optional
"date"
,
node_date
=
optional
"date"
,
node_hyperdata
=
O
.
required
"hyperdata"
,
node_hyperdata
=
required
"hyperdata"
}
}
)
)
selectNodes
::
Column
PGInt4
->
Query
(
Column
O
.
PGText
)
selectNodes
::
Column
PGInt4
->
Query
(
Column
PGText
)
selectNodes
node_id
=
proc
()
->
do
selectNodes
node_id
=
proc
()
->
do
row
@
(
Node
n_id
tn
u
p
n
d
h
)
<-
queryNodeTable
-<
()
(
Node
n_id
_tn
_u
_p
n
_d
_
h
)
<-
queryNodeTable
-<
()
O
.
restrict
-<
n_id
.==
node_id
restrict
-<
n_id
.==
node_id
returnA
-<
n
returnA
-<
n
instance
QueryRunnerColumnDefault
PGInt4
Integer
where
queryRunnerColumnDefault
=
fieldQueryRunnerColumn
runGetNodes
::
PGS
.
Connection
->
Query
NodeRead
->
IO
[
Document
]
runGetNodes
::
PGS
.
Connection
->
Query
NodeRead
->
IO
[
Document
]
runGetNodes
=
O
.
runQuery
runGetNodes
=
runQuery
queryNodeTable
::
Query
NodeRead
queryNodeTable
::
Query
NodeRead
queryNodeTable
=
O
.
queryTable
nodeTable
queryNodeTable
=
queryTable
nodeTable
selectNode
::
Column
PGInt4
->
Query
NodeRead
selectNode
::
Column
PGInt4
->
Query
NodeRead
selectNode
node_id
=
proc
()
->
do
selectNode
node_id
=
proc
()
->
do
row
@
(
Node
id
tn
u
p_id
n
d
h
)
<-
queryNodeTable
-<
()
row
@
(
Node
_id
_tn
_u
p_id
_n
_d
_
h
)
<-
queryNodeTable
-<
()
O
.
restrict
-<
p_id
.==
node_id
restrict
-<
p_id
.==
node_id
returnA
-<
row
returnA
-<
row
getNodes
::
Column
PGInt4
->
IO
[
Document
]
getNodes
::
Column
PGInt4
->
IO
[
Document
]
getNodes
node_id
=
do
getNodes
node_id
=
do
conn
<-
PGS
.
connect
infoGargandb
conn
<-
PGS
.
connect
infoGargandb
O
.
runQuery
conn
$
selectNode
node_id
runQuery
conn
$
selectNode
node_id
getCorpusDocument
::
Column
PGInt4
->
IO
[
Document
]
getCorpusDocument
::
Column
PGInt4
->
IO
[
Document
]
getCorpusDocument
node_id
=
PGS
.
connect
infoGargandb
>>=
getCorpusDocument
node_id
=
PGS
.
connect
infoGargandb
>>=
\
conn
->
O
.
runQuery
conn
(
selectNode
node_id
)
\
conn
->
runQuery
conn
(
selectNode
node_id
)
getProjectCorpora
::
Column
PGInt4
->
IO
[
Corpus
]
getProjectCorpora
::
Column
PGInt4
->
IO
[
Corpus
]
getProjectCorpora
node_id
=
do
getProjectCorpora
node_id
=
do
conn
<-
PGS
.
connect
infoGargandb
conn
<-
PGS
.
connect
infoGargandb
O
.
runQuery
conn
$
selectNode
node_id
runQuery
conn
$
selectNode
node_id
src/Data/Gargantext/Database/NodeNgram.hs
View file @
1c3d5cfd
...
@@ -3,28 +3,20 @@
...
@@ -3,28 +3,20 @@
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE Arrows #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module
Data.Gargantext.Database.NodeNgram
where
module
Data.Gargantext.Database.NodeNgram
where
import
Prelude
import
Prelude
import
Data.Time
(
UTCTime
)
import
Data.Text
(
Text
)
import
Data.Maybe
(
Maybe
)
import
Data.Maybe
(
Maybe
)
import
Data.Profunctor.Product.TH
(
makeAdaptorAndInstance
)
import
Data.Profunctor.Product.TH
(
makeAdaptorAndInstance
)
import
Control.Lens.TH
(
makeLensesWith
,
abbreviatedFields
)
import
Control.Lens.TH
(
makeLensesWith
,
abbreviatedFields
)
import
Control.Arrow
(
returnA
)
import
qualified
Database.PostgreSQL.Simple
as
PGS
import
qualified
Database.PostgreSQL.Simple
as
PGS
import
qualified
Opaleye
as
O
import
Opaleye
import
Opaleye
(
Column
,
PGBool
,
PGInt4
,
PGText
,
PGTimestamptz
,
PGFloat8
,
Table
(
Table
),
Query
,
QueryRunnerColumnDefault
,
queryRunnerColumnDefault
,
fieldQueryRunnerColumn
,
(
.==
),
(
.>
)
)
import
Data.Gargantext.Database.Private
(
infoGargandb
)
import
Data.Gargantext.Database.Private
(
infoGargandb
)
import
Data.Gargantext.Database.Instances
data
NodeNgramPoly
id
node_id
ngram_id
weight
data
NodeNgramPoly
id
node_id
ngram_id
weight
=
NodeNgram
{
nodeNgram_NodeNgramId
::
id
=
NodeNgram
{
nodeNgram_NodeNgramId
::
id
...
@@ -43,22 +35,28 @@ $(makeAdaptorAndInstance "pNodeNgram" ''NodeNgramPoly)
...
@@ -43,22 +35,28 @@ $(makeAdaptorAndInstance "pNodeNgram" ''NodeNgramPoly)
$
(
makeLensesWith
abbreviatedFields
''
N
odeNgramPoly
)
$
(
makeLensesWith
abbreviatedFields
''
N
odeNgramPoly
)
nodeNgramTable
::
O
.
Table
NodeNgramWrite
NodeNgramRead
nodeNgramTable
::
Table
NodeNgramWrite
NodeNgramRead
nodeNgramTable
=
O
.
Table
"nodes_ngrams"
(
pNodeNgram
NodeNgram
{
nodeNgram_NodeNgramId
=
O
.
optional
"id"
nodeNgramTable
=
Table
"nodes_ngrams"
(
pNodeNgram
NodeNgram
{
nodeNgram_NodeNgramId
=
optional
"id"
,
nodeNgram_NodeNgramNodeId
=
O
.
required
"node_id"
,
nodeNgram_NodeNgramNodeId
=
required
"node_id"
,
nodeNgram_NodeNgramNgramId
=
O
.
required
"ngram_id"
,
nodeNgram_NodeNgramNgramId
=
required
"ngram_id"
,
nodeNgram_NodeNgramWeight
=
O
.
optional
"weight"
,
nodeNgram_NodeNgramWeight
=
optional
"weight"
}
}
)
)
queryNodeNgramTable
::
Query
NodeNgramRead
queryNodeNgramTable
::
Query
NodeNgramRead
queryNodeNgramTable
=
O
.
queryTable
nodeNgramTable
queryNodeNgramTable
=
queryTable
nodeNgramTable
instance
QueryRunnerColumnDefault
PGInt4
(
Maybe
Int
)
where
queryRunnerColumnDefault
=
fieldQueryRunnerColumn
instance
QueryRunnerColumnDefault
PGFloat8
(
Maybe
Double
)
where
queryRunnerColumnDefault
=
fieldQueryRunnerColumn
-- | not optimized (get all ngrams without filters)
-- | not optimized (get all ngrams without filters)
nodeNgrams
::
IO
[
NodeNgram
]
nodeNgrams
::
IO
[
NodeNgram
]
nodeNgrams
=
do
nodeNgrams
=
do
conn
<-
PGS
.
connect
infoGargandb
conn
<-
PGS
.
connect
infoGargandb
O
.
runQuery
conn
queryNodeNgramTable
runQuery
conn
queryNodeNgramTable
src/Data/Gargantext/Database/NodeNgramNgram.hs
View file @
1c3d5cfd
...
@@ -3,28 +3,19 @@
...
@@ -3,28 +3,19 @@
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE Arrows #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module
Data.Gargantext.Database.NodeNgramNgram
where
module
Data.Gargantext.Database.NodeNgramNgram
where
import
Prelude
import
Prelude
import
Data.Time
(
UTCTime
)
import
Data.Text
(
Text
)
import
Data.Maybe
(
Maybe
)
import
Data.Maybe
(
Maybe
)
import
Data.Profunctor.Product.TH
(
makeAdaptorAndInstance
)
import
Data.Profunctor.Product.TH
(
makeAdaptorAndInstance
)
import
Control.Lens.TH
(
makeLensesWith
,
abbreviatedFields
)
import
Control.Lens.TH
(
makeLensesWith
,
abbreviatedFields
)
import
Control.Arrow
(
returnA
)
import
qualified
Database.PostgreSQL.Simple
as
PGS
import
qualified
Database.PostgreSQL.Simple
as
PGS
import
qualified
Opaleye
as
O
import
Opaleye
import
Opaleye
(
Column
,
PGBool
,
PGInt4
,
PGText
,
PGTimestamptz
,
PGFloat8
,
Table
(
Table
),
Query
,
QueryRunnerColumnDefault
,
queryRunnerColumnDefault
,
fieldQueryRunnerColumn
,
(
.==
),
(
.>
)
)
import
Data.Gargantext.Database.Private
(
infoGargandb
)
import
Data.Gargantext.Database.Private
(
infoGargandb
)
import
Data.Gargantext.Database.Instances
data
NodeNgramNgramPoly
node_id
ngram1_id
ngram2_id
weight
data
NodeNgramNgramPoly
node_id
ngram1_id
ngram2_id
weight
=
NodeNgramNgram
{
nodeNgramNgram_NodeNgramNgram_NodeId
::
node_id
=
NodeNgramNgram
{
nodeNgramNgram_NodeNgramNgram_NodeId
::
node_id
...
@@ -44,23 +35,28 @@ $(makeAdaptorAndInstance "pNodeNgramNgram" ''NodeNgramNgramPoly)
...
@@ -44,23 +35,28 @@ $(makeAdaptorAndInstance "pNodeNgramNgram" ''NodeNgramNgramPoly)
$
(
makeLensesWith
abbreviatedFields
''
N
odeNgramNgramPoly
)
$
(
makeLensesWith
abbreviatedFields
''
N
odeNgramNgramPoly
)
nodeNgramNgramTable
::
O
.
Table
NodeNgramNgramWrite
NodeNgramNgramRead
nodeNgramNgramTable
::
Table
NodeNgramNgramWrite
NodeNgramNgramRead
nodeNgramNgramTable
=
O
.
Table
"nodes_ngrams_ngrams"
(
pNodeNgramNgram
NodeNgramNgram
nodeNgramNgramTable
=
Table
"nodes_ngrams_ngrams"
(
pNodeNgramNgram
NodeNgramNgram
{
nodeNgramNgram_NodeNgramNgram_NodeId
=
O
.
optional
"node_id"
{
nodeNgramNgram_NodeNgramNgram_NodeId
=
optional
"node_id"
,
nodeNgramNgram_NodeNgramNgram_Ngram1Id
=
O
.
required
"ngram1_id"
,
nodeNgramNgram_NodeNgramNgram_Ngram1Id
=
required
"ngram1_id"
,
nodeNgramNgram_NodeNgramNgram_Ngram2Id
=
O
.
required
"ngram2_id"
,
nodeNgramNgram_NodeNgramNgram_Ngram2Id
=
required
"ngram2_id"
,
nodeNgramNgram_NodeNgramNgram_Weight
=
O
.
optional
"weight"
,
nodeNgramNgram_NodeNgramNgram_Weight
=
optional
"weight"
}
}
)
)
queryNodeNgramNgramTable
::
Query
NodeNgramNgramRead
queryNodeNgramNgramTable
::
Query
NodeNgramNgramRead
queryNodeNgramNgramTable
=
O
.
queryTable
nodeNgramNgramTable
queryNodeNgramNgramTable
=
queryTable
nodeNgramNgramTable
-- | not optimized (get all ngrams without filters)
-- | not optimized (get all ngrams without filters)
nodeNgramNgrams
::
IO
[
NodeNgramNgram
]
nodeNgramNgrams
::
IO
[
NodeNgramNgram
]
nodeNgramNgrams
=
do
nodeNgramNgrams
=
do
conn
<-
PGS
.
connect
infoGargandb
conn
<-
PGS
.
connect
infoGargandb
O
.
runQuery
conn
queryNodeNgramNgramTable
runQuery
conn
queryNodeNgramNgramTable
instance
QueryRunnerColumnDefault
PGInt4
(
Maybe
Int
)
where
queryRunnerColumnDefault
=
fieldQueryRunnerColumn
instance
QueryRunnerColumnDefault
PGFloat8
(
Maybe
Double
)
where
queryRunnerColumnDefault
=
fieldQueryRunnerColumn
src/Data/Gargantext/Database/NodeNode.hs
View file @
1c3d5cfd
...
@@ -3,29 +3,19 @@
...
@@ -3,29 +3,19 @@
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE Arrows #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module
Data.Gargantext.Database.NodeNode
where
module
Data.Gargantext.Database.NodeNode
where
import
Prelude
import
Prelude
import
Data.Time
(
UTCTime
)
import
Data.Text
(
Text
)
import
Data.Maybe
(
Maybe
)
import
Data.Maybe
(
Maybe
)
import
Data.Profunctor.Product.TH
(
makeAdaptorAndInstance
)
import
Data.Profunctor.Product.TH
(
makeAdaptorAndInstance
)
import
Control.Lens.TH
(
makeLensesWith
,
abbreviatedFields
)
import
Control.Lens.TH
(
makeLensesWith
,
abbreviatedFields
)
import
Control.Arrow
(
returnA
)
import
qualified
Database.PostgreSQL.Simple
as
PGS
import
qualified
Database.PostgreSQL.Simple
as
PGS
import
qualified
Opaleye
as
O
import
Opaleye
import
Opaleye
(
Column
,
PGBool
,
PGInt4
,
PGText
,
PGTimestamptz
,
PGFloat8
,
Table
(
Table
),
Query
,
QueryRunnerColumnDefault
,
queryRunnerColumnDefault
,
fieldQueryRunnerColumn
,
(
.==
),
(
.>
)
,
required
,
optional
)
import
Data.Gargantext.Database.Private
(
infoGargandb
)
import
Data.Gargantext.Database.Private
(
infoGargandb
)
import
Data.Gargantext.Database.Instances
data
NodeNodePoly
node1_id
node2_id
score
data
NodeNodePoly
node1_id
node2_id
score
=
NodeNode
{
nodeNode_node1_id
::
node1_id
=
NodeNode
{
nodeNode_node1_id
::
node1_id
...
@@ -43,8 +33,8 @@ $(makeAdaptorAndInstance "pNodeNode" ''NodeNodePoly)
...
@@ -43,8 +33,8 @@ $(makeAdaptorAndInstance "pNodeNode" ''NodeNodePoly)
$
(
makeLensesWith
abbreviatedFields
''
N
odeNodePoly
)
$
(
makeLensesWith
abbreviatedFields
''
N
odeNodePoly
)
nodeNodeTable
::
O
.
Table
NodeNodeWrite
NodeNodeRead
nodeNodeTable
::
Table
NodeNodeWrite
NodeNodeRead
nodeNodeTable
=
O
.
Table
"nodes_nodes"
(
pNodeNode
NodeNode
{
nodeNode_node1_id
=
required
"node1_id"
nodeNodeTable
=
Table
"nodes_nodes"
(
pNodeNode
NodeNode
{
nodeNode_node1_id
=
required
"node1_id"
,
nodeNode_node2_id
=
required
"node2_id"
,
nodeNode_node2_id
=
required
"node2_id"
,
nodeNode_score
=
optional
"score"
,
nodeNode_score
=
optional
"score"
}
}
...
@@ -52,12 +42,14 @@ nodeNodeTable = O.Table "nodes_nodes" (pNodeNode NodeNode { nodeNode_node1_id =
...
@@ -52,12 +42,14 @@ nodeNodeTable = O.Table "nodes_nodes" (pNodeNode NodeNode { nodeNode_node1_id =
queryNodeNodeTable
::
Query
NodeNodeRead
queryNodeNodeTable
::
Query
NodeNodeRead
queryNodeNodeTable
=
O
.
queryTable
nodeNodeTable
queryNodeNodeTable
=
queryTable
nodeNodeTable
-- | not optimized (get all ngrams without filters)
-- | not optimized (get all ngrams without filters)
nodeNodes
::
IO
[
NodeNode
]
nodeNodes
::
IO
[
NodeNode
]
nodeNodes
=
do
nodeNodes
=
do
conn
<-
PGS
.
connect
infoGargandb
conn
<-
PGS
.
connect
infoGargandb
O
.
runQuery
conn
queryNodeNodeTable
runQuery
conn
queryNodeNodeTable
instance
QueryRunnerColumnDefault
PGFloat8
(
Maybe
Double
)
where
queryRunnerColumnDefault
=
fieldQueryRunnerColumn
src/Data/Gargantext/Database/NodeNodeNgram.hs
View file @
1c3d5cfd
...
@@ -3,28 +3,20 @@
...
@@ -3,28 +3,20 @@
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE Arrows #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module
Data.Gargantext.Database.NodeNodeNgram
where
module
Data.Gargantext.Database.NodeNodeNgram
where
import
Prelude
import
Prelude
import
Data.Time
(
UTCTime
)
import
Data.Text
(
Text
)
import
Data.Maybe
(
Maybe
)
import
Data.Maybe
(
Maybe
)
import
Data.Profunctor.Product.TH
(
makeAdaptorAndInstance
)
import
Data.Profunctor.Product.TH
(
makeAdaptorAndInstance
)
import
Control.Lens.TH
(
makeLensesWith
,
abbreviatedFields
)
import
Control.Lens.TH
(
makeLensesWith
,
abbreviatedFields
)
import
Control.Arrow
(
returnA
)
import
qualified
Database.PostgreSQL.Simple
as
PGS
import
qualified
Database.PostgreSQL.Simple
as
PGS
import
qualified
Opaleye
as
O
import
Opaleye
import
Opaleye
(
Column
,
PGBool
,
PGInt4
,
PGText
,
PGTimestamptz
,
PGFloat8
,
Table
(
Table
),
Query
,
QueryRunnerColumnDefault
,
queryRunnerColumnDefault
,
fieldQueryRunnerColumn
,
(
.==
),
(
.>
)
)
import
Data.Gargantext.Database.Private
(
infoGargandb
)
import
Data.Gargantext.Database.Private
(
infoGargandb
)
import
Data.Gargantext.Database.Instances
data
NodeNodeNgramPoly
node1_id
node2_id
ngram_id
score
data
NodeNodeNgramPoly
node1_id
node2_id
ngram_id
score
=
NodeNodeNgram
{
nodeNodeNgram_node1_id
::
node1_id
=
NodeNodeNgram
{
nodeNodeNgram_node1_id
::
node1_id
...
@@ -44,23 +36,26 @@ $(makeAdaptorAndInstance "pNodeNodeNgram" ''NodeNodeNgramPoly)
...
@@ -44,23 +36,26 @@ $(makeAdaptorAndInstance "pNodeNodeNgram" ''NodeNodeNgramPoly)
$
(
makeLensesWith
abbreviatedFields
''
N
odeNodeNgramPoly
)
$
(
makeLensesWith
abbreviatedFields
''
N
odeNodeNgramPoly
)
nodeNodeNgramTable
::
O
.
Table
NodeNodeNgramWrite
NodeNodeNgramRead
nodeNodeNgramTable
::
Table
NodeNodeNgramWrite
NodeNodeNgramRead
nodeNodeNgramTable
=
O
.
Table
"nodes_nodes_ngrams"
(
pNodeNodeNgram
NodeNodeNgram
nodeNodeNgramTable
=
Table
"nodes_nodes_ngrams"
(
pNodeNodeNgram
NodeNodeNgram
{
nodeNodeNgram_node1_id
=
O
.
required
"node1_id"
{
nodeNodeNgram_node1_id
=
required
"node1_id"
,
nodeNodeNgram_node2_id
=
O
.
required
"node2_id"
,
nodeNodeNgram_node2_id
=
required
"node2_id"
,
nodeNodeNgram_ngram_id
=
O
.
required
"ngram_id"
,
nodeNodeNgram_ngram_id
=
required
"ngram_id"
,
nodeNodeNgram_score
=
O
.
optional
"score"
,
nodeNodeNgram_score
=
optional
"score"
}
}
)
)
queryNodeNodeNgramTable
::
Query
NodeNodeNgramRead
queryNodeNodeNgramTable
::
Query
NodeNodeNgramRead
queryNodeNodeNgramTable
=
O
.
queryTable
nodeNodeNgramTable
queryNodeNodeNgramTable
=
queryTable
nodeNodeNgramTable
-- | not optimized (get all ngrams without filters)
-- | not optimized (get all ngrams without filters)
nodeNodeNgrams
::
IO
[
NodeNodeNgram
]
nodeNodeNgrams
::
IO
[
NodeNodeNgram
]
nodeNodeNgrams
=
do
nodeNodeNgrams
=
do
conn
<-
PGS
.
connect
infoGargandb
conn
<-
PGS
.
connect
infoGargandb
O
.
runQuery
conn
queryNodeNodeNgramTable
runQuery
conn
queryNodeNodeNgramTable
instance
QueryRunnerColumnDefault
PGFloat8
(
Maybe
Double
)
where
queryRunnerColumnDefault
=
fieldQueryRunnerColumn
src/Data/Gargantext/Database/User.hs
View file @
1c3d5cfd
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE Arrows #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module
Data.Gargantext.Database.User
where
module
Data.Gargantext.Database.User
where
...
@@ -16,17 +19,8 @@ import Control.Lens.TH (makeLensesWith, abbreviatedFields)
...
@@ -16,17 +19,8 @@ import Control.Lens.TH (makeLensesWith, abbreviatedFields)
import
Control.Arrow
(
returnA
)
import
Control.Arrow
(
returnA
)
import
qualified
Database.PostgreSQL.Simple
as
PGS
import
qualified
Database.PostgreSQL.Simple
as
PGS
import
qualified
Opaleye
as
O
import
Opaleye
import
Opaleye
(
Column
,
PGBool
,
PGInt4
,
PGText
,
PGTimestamptz
,
Table
(
Table
),
Query
,
QueryRunnerColumnDefault
,
queryRunnerColumnDefault
,
fieldQueryRunnerColumn
,
(
.==
),
(
.>
)
,
required
,
optional
)
import
Data.Gargantext.Database.Private
(
infoGargandb
)
import
Data.Gargantext.Database.Private
(
infoGargandb
)
import
Data.Gargantext.Database.Instances
-- Functions only
-- Functions only
import
Data.List
(
find
)
import
Data.List
(
find
)
...
@@ -77,8 +71,8 @@ $(makeAdaptorAndInstance "pUser" ''UserPoly)
...
@@ -77,8 +71,8 @@ $(makeAdaptorAndInstance "pUser" ''UserPoly)
$
(
makeLensesWith
abbreviatedFields
''
U
serPoly
)
$
(
makeLensesWith
abbreviatedFields
''
U
serPoly
)
userTable
::
O
.
Table
UserWrite
UserRead
userTable
::
Table
UserWrite
UserRead
userTable
=
O
.
Table
"auth_user"
(
pUser
User
{
user_id
=
optional
"id"
userTable
=
Table
"auth_user"
(
pUser
User
{
user_id
=
optional
"id"
,
user_password
=
required
"password"
,
user_password
=
required
"password"
,
user_lastLogin
=
optional
"last_login"
,
user_lastLogin
=
optional
"last_login"
,
user_isSuperUser
=
required
"is_superuser"
,
user_isSuperUser
=
required
"is_superuser"
...
@@ -94,13 +88,13 @@ userTable = O.Table "auth_user" (pUser User { user_id = optional "id"
...
@@ -94,13 +88,13 @@ userTable = O.Table "auth_user" (pUser User { user_id = optional "id"
queryUserTable
::
Query
UserRead
queryUserTable
::
Query
UserRead
queryUserTable
=
O
.
queryTable
userTable
queryUserTable
=
queryTable
userTable
selectUsersLight
::
Query
UserRead
selectUsersLight
::
Query
UserRead
selectUsersLight
=
proc
()
->
do
selectUsersLight
=
proc
()
->
do
row
@
(
User
i
p
ll
is
un
fn
ln
m
iff
ive
dj
)
<-
queryUserTable
-<
()
row
@
(
User
i
_p
_ll
_is
_un
_fn
_ln
_m
_iff
_ive
_
dj
)
<-
queryUserTable
-<
()
O
.
restrict
-<
i
.==
1
restrict
-<
i
.==
1
--returnA -< User i p ll is un fn ln m iff ive dj
--returnA -< User i p ll is un fn ln m iff ive dj
returnA
-<
row
returnA
-<
row
...
@@ -114,17 +108,16 @@ userWithUsername t xs = userWith user_username t xs
...
@@ -114,17 +108,16 @@ userWithUsername t xs = userWith user_username t xs
userWithId
::
Int
->
[
User
]
->
Maybe
User
userWithId
::
Int
->
[
User
]
->
Maybe
User
userWithId
t
xs
=
userWith
user_id
t
xs
userWithId
t
xs
=
userWith
user_id
t
xs
instance
QueryRunnerColumnDefault
PGTimestamptz
(
Maybe
UTCTime
)
where
queryRunnerColumnDefault
=
fieldQueryRunnerColumn
users
::
IO
[
User
]
users
::
IO
[
User
]
users
=
do
users
=
do
conn
<-
PGS
.
connect
infoGargandb
conn
<-
PGS
.
connect
infoGargandb
O
.
runQuery
conn
queryUserTable
runQuery
conn
queryUserTable
usersLight
::
IO
[
UserLight
]
usersLight
::
IO
[
UserLight
]
usersLight
=
do
usersLight
=
do
conn
<-
PGS
.
connect
infoGargandb
conn
<-
PGS
.
connect
infoGargandb
pm
toUserLight
<$>
O
.
runQuery
conn
queryUserTable
pm
toUserLight
<$>
runQuery
conn
queryUserTable
src/Data/Gargantext/Parsers/Occurrences.hs
View file @
1c3d5cfd
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
module
Data.Gargantext.Parsers.Occurrences
where
module
Data.Gargantext.Parsers.Occurrences
where
import
Data.Gargantext.Prelude
import
Data.Attoparsec.Text
import
Data.Attoparsec.Text
import
Data.Text
(
Text
)
import
Data.Text
(
Text
)
...
@@ -23,6 +22,3 @@ occurrencesParser txt = case txt of
...
@@ -23,6 +22,3 @@ occurrencesParser txt = case txt of
parseOccurrences
::
Text
->
Text
->
Either
String
Int
parseOccurrences
::
Text
->
Text
->
Either
String
Int
parseOccurrences
x
=
parseOnly
(
occurrencesParser
x
)
parseOccurrences
x
=
parseOnly
(
occurrencesParser
x
)
src/Data/Gargantext/Prelude.hs
View file @
1c3d5cfd
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
{-# OPTIONS_GHC -fno-warn-type-defaults #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NoImplicitPrelude #-}
module
Data.Gargantext.Prelude
where
module
Data.Gargantext.Prelude
where
import
Protolude
import
Protolude
(
Bool
(
True
,
False
),
Int
,
Double
,
Integer
,
Fractional
,
Num
,
Maybe
,
Floating
,
Char
,
Ord
,
Integral
,
Foldable
,
RealFrac
,
Monad
,
filter
,
reverse
,
map
,
zip
,
drop
,
take
,
zipWith
,
sum
,
fromIntegral
,
length
,
fmap
,
takeWhile
,
sqrt
,
undefined
,
identity
,
abs
,
maximum
,
minimum
,
return
,
snd
,
truncate
,
(
+
),
(
*
),
(
/
),
(
-
),
(
.
),
(
>=
),
(
$
),
(
**
),
(
^
)
)
-- TODO import functions optimized in Utils.Count
-- TODO import functions optimized in Utils.Count
-- import Protolude hiding (head, last, all, any, sum, product, length)
-- import Protolude hiding (head, last, all, any, sum, product, length)
...
@@ -13,16 +37,28 @@ import qualified Control.Monad as M
...
@@ -13,16 +37,28 @@ import qualified Control.Monad as M
import
qualified
Data.Map
as
Map
import
qualified
Data.Map
as
Map
import
qualified
Data.Vector
as
V
import
qualified
Data.Vector
as
V
pf
::
(
a
->
Bool
)
->
[
a
]
->
[
a
]
pf
=
filter
pf
=
filter
pr
::
[
a
]
->
[
a
]
pr
=
reverse
pr
=
reverse
pm
::
(
a
->
b
)
->
[
a
]
->
[
b
]
pm
=
map
pm
=
map
pm2
::
(
t
->
b
)
->
[[
t
]]
->
[[
b
]]
pm2
::
(
t
->
b
)
->
[[
t
]]
->
[[
b
]]
pm2
fun
=
pm
(
pm
fun
)
pm2
fun
=
pm
(
pm
fun
)
pz
::
[
a
]
->
[
b
]
->
[(
a
,
b
)]
pz
=
zip
pz
=
zip
pd
::
Int
->
[
a
]
->
[
a
]
pd
=
drop
pd
=
drop
ptk
::
Int
->
[
a
]
->
[
a
]
ptk
=
take
ptk
=
take
pzw
::
(
a
->
b
->
c
)
->
[
a
]
->
[
b
]
->
[
c
]
pzw
=
zipWith
pzw
=
zipWith
-- Exponential Average
-- Exponential Average
...
@@ -59,7 +95,7 @@ chunkAlong a b l = only (while dropAlong)
...
@@ -59,7 +95,7 @@ chunkAlong a b l = only (while dropAlong)
where
where
only
=
pm
(
take
a
)
only
=
pm
(
take
a
)
while
=
takeWhile
(
\
x
->
length
x
>=
a
)
while
=
takeWhile
(
\
x
->
length
x
>=
a
)
dropAlong
=
L
.
scanl
(
\
x
y
->
drop
b
x
)
l
[
1
..
]
dropAlong
=
L
.
scanl
(
\
x
_y
->
drop
b
x
)
l
([
1
..
]
::
[
Integer
])
-- | Optimized version (Vector)
-- | Optimized version (Vector)
chunkAlong'
::
Int
->
Int
->
V
.
Vector
a
->
V
.
Vector
(
V
.
Vector
a
)
chunkAlong'
::
Int
->
Int
->
V
.
Vector
a
->
V
.
Vector
(
V
.
Vector
a
)
...
@@ -67,7 +103,7 @@ chunkAlong' a b l = only (while dropAlong)
...
@@ -67,7 +103,7 @@ chunkAlong' a b l = only (while dropAlong)
where
where
only
=
V
.
map
(
V
.
take
a
)
only
=
V
.
map
(
V
.
take
a
)
while
=
V
.
takeWhile
(
\
x
->
V
.
length
x
>=
a
)
while
=
V
.
takeWhile
(
\
x
->
V
.
length
x
>=
a
)
dropAlong
=
V
.
scanl
(
\
x
y
->
V
.
drop
b
x
)
l
(
V
.
fromList
[
1
..
])
dropAlong
=
V
.
scanl
(
\
x
_
y
->
V
.
drop
b
x
)
l
(
V
.
fromList
[
1
..
])
-- | TODO Inverse of chunk ? unchunkAlong ?
-- | TODO Inverse of chunk ? unchunkAlong ?
unchunkAlong
::
Int
->
Int
->
[[
a
]]
->
[
a
]
unchunkAlong
::
Int
->
Int
->
[[
a
]]
->
[
a
]
...
@@ -123,7 +159,7 @@ trunc' n x = fromIntegral $ truncate $ (x * 10^n)
...
@@ -123,7 +159,7 @@ trunc' n x = fromIntegral $ truncate $ (x * 10^n)
bool2int
::
Num
a
=>
Bool
->
a
bool2int
::
Num
a
=>
Bool
->
a
bool2int
b
ool
=
case
bool
of
bool2int
b
=
case
b
of
True
->
1
True
->
1
False
->
0
False
->
0
...
@@ -135,6 +171,7 @@ bool2double bool = case bool of
...
@@ -135,6 +171,7 @@ bool2double bool = case bool of
-- Normalizing && scaling data
-- Normalizing && scaling data
scale
::
[
Double
]
->
[
Double
]
scale
=
scaleMinMax
scale
=
scaleMinMax
scaleMinMax
::
[
Double
]
->
[
Double
]
scaleMinMax
::
[
Double
]
->
[
Double
]
...
@@ -167,4 +204,3 @@ zipFst f xs = zip (f xs) xs
...
@@ -167,4 +204,3 @@ zipFst f xs = zip (f xs) xs
zipSnd
::
([
a
]
->
[
b
])
->
[
a
]
->
[(
a
,
b
)]
zipSnd
::
([
a
]
->
[
b
])
->
[
a
]
->
[(
a
,
b
)]
zipSnd
f
xs
=
zip
xs
(
f
xs
)
zipSnd
f
xs
=
zip
xs
(
f
xs
)
src/Data/Gargantext/Server.hs
View file @
1c3d5cfd
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeOperators #-}
...
@@ -7,13 +8,10 @@ module Data.Gargantext.Server
...
@@ -7,13 +8,10 @@ module Data.Gargantext.Server
-- )
-- )
where
where
import
Control.Concurrent
import
Control.Monad
import
Control.Monad
import
Control.Monad.IO.Class
import
Control.Monad.IO.Class
import
Data.Aeson
import
Data.Aeson
import
Data.Aeson.TH
import
Data.Aeson.TH
import
Data.Gargantext.Types
import
Network.HTTP.Client.MultipartFormData
import
Network.Wai
import
Network.Wai
import
Network.Wai.Handler.Warp
import
Network.Wai.Handler.Warp
import
Servant
import
Servant
...
@@ -87,7 +85,3 @@ upload multipartData = do
...
@@ -87,7 +85,3 @@ upload multipartData = do
++
" at "
++
fdFilePath
file
++
" at "
++
fdFilePath
file
putStrLn
content
putStrLn
content
pure
"Data loaded"
pure
"Data loaded"
src/Data/Gargantext/Types/Main.hs
View file @
1c3d5cfd
...
@@ -7,7 +7,6 @@ module Data.Gargantext.Types.Main where
...
@@ -7,7 +7,6 @@ module Data.Gargantext.Types.Main where
import
Protolude
(
fromMaybe
)
import
Protolude
(
fromMaybe
)
import
Data.Text
(
Text
)
import
Data.Text
(
Text
)
import
Data.Time
(
UTCTime
)
import
Data.Time
(
UTCTime
)
import
Data.Gargantext.Prelude
import
Data.Gargantext.Types.Node
(
NodePoly
import
Data.Gargantext.Types.Node
(
NodePoly
,
HyperdataFolder
,
HyperdataCorpus
,
HyperdataDocument
,
HyperdataFolder
,
HyperdataCorpus
,
HyperdataDocument
,
HyperdataFavorites
,
HyperdataResource
,
HyperdataFavorites
,
HyperdataResource
...
@@ -128,5 +127,3 @@ nodeTypes = [
...
@@ -128,5 +127,3 @@ nodeTypes = [
--
--
nodeTypeId
::
NodeType
->
NodeTypeId
nodeTypeId
::
NodeType
->
NodeTypeId
nodeTypeId
tn
=
fromMaybe
(
error
(
"Typename "
++
show
tn
++
" does not exist"
))
(
lookup
tn
nodeTypes
)
nodeTypeId
tn
=
fromMaybe
(
error
(
"Typename "
++
show
tn
++
" does not exist"
))
(
lookup
tn
nodeTypes
)
src/Data/Gargantext/Types/Node.hs
View file @
1c3d5cfd
...
@@ -4,13 +4,10 @@
...
@@ -4,13 +4,10 @@
module
Data.Gargantext.Types.Node
where
module
Data.Gargantext.Types.Node
where
import
Data.Text
(
Text
)
import
Data.Text
(
Text
)
import
Data.List
(
lookup
)
import
GHC.Generics
(
Generic
)
import
GHC.Generics
(
Generic
)
import
Data.Time
(
UTCTime
)
import
Data.Time
(
UTCTime
)
import
Data.Gargantext.Utils.Prefix
import
Data.Gargantext.Utils.Prefix
(
unPrefix
)
import
Data.Aeson.TH
import
Data.Aeson.TH
(
deriveJSON
)
data
NodePoly
id
typename
userId
parentId
name
date
hyperdata
=
Node
{
node_id
::
id
data
NodePoly
id
typename
userId
parentId
name
date
hyperdata
=
Node
{
node_id
::
id
,
node_typename
::
typename
,
node_typename
::
typename
...
@@ -113,5 +110,3 @@ $(deriveJSON (unPrefix "hyperdataPhylo_") ''HyperdataPhylo)
...
@@ -113,5 +110,3 @@ $(deriveJSON (unPrefix "hyperdataPhylo_") ''HyperdataPhylo)
data
HyperdataNotebook
=
HyperdataNotebook
{
hyperdataNotebook_Preferences
::
Maybe
Text
data
HyperdataNotebook
=
HyperdataNotebook
{
hyperdataNotebook_Preferences
::
Maybe
Text
}
deriving
(
Show
,
Generic
)
}
deriving
(
Show
,
Generic
)
$
(
deriveJSON
(
unPrefix
"hyperdataNotebook_"
)
''
H
yperdataNotebook
)
$
(
deriveJSON
(
unPrefix
"hyperdataNotebook_"
)
''
H
yperdataNotebook
)
src/Data/Gargantext/Utils/DateUtils.hs
View file @
1c3d5cfd
module
Data.Gargantext.Utils.DateUtils
where
module
Data.Gargantext.Utils.DateUtils
where
import
Data.Time
import
Data.Time
(
UTCTime
,
toGregorian
,
utctDay
)
--import Data.Dates
--
--
--readInt :: IO [Char] -> IO Int
--readInt :: IO [Char] -> IO Int
...
@@ -14,7 +13,7 @@ utc2gregorian :: UTCTime -> (Integer, Int, Int)
...
@@ -14,7 +13,7 @@ utc2gregorian :: UTCTime -> (Integer, Int, Int)
utc2gregorian
date
=
toGregorian
$
utctDay
date
utc2gregorian
date
=
toGregorian
$
utctDay
date
gregorian2year
::
(
Integer
,
Int
,
Int
)
->
Integer
gregorian2year
::
(
Integer
,
Int
,
Int
)
->
Integer
gregorian2year
(
y
,
m
,
d
)
=
y
gregorian2year
(
y
,
_m
,
_
d
)
=
y
utc2year
::
UTCTime
->
Integer
utc2year
::
UTCTime
->
Integer
utc2year
date
=
gregorian2year
$
utc2gregorian
date
utc2year
date
=
gregorian2year
$
utc2gregorian
date
...
@@ -29,4 +28,3 @@ averageLength l = fromIntegral (sum (map length l)) / fromIntegral (length l)
...
@@ -29,4 +28,3 @@ averageLength l = fromIntegral (sum (map length l)) / fromIntegral (length l)
charToString
::
Char
->
String
charToString
::
Char
->
String
charToString
=
(
:
[]
)
charToString
=
(
:
[]
)
src/Data/Gargantext/Utils/Prefix.hs
View file @
1c3d5cfd
module
Data.Gargantext.Utils.Prefix
where
module
Data.Gargantext.Utils.Prefix
where
import
Data.Aeson
(
Value
,
defaultOptions
,
parseJSON
)
import
Control.Monad
as
X
(
mzero
)
import
Data.Aeson.TH
(
Options
,
fieldLabelModifier
,
omitNothingFields
)
import
Data.Aeson
as
X
import
Data.Aeson.Types
(
Parser
)
import
Data.Aeson.TH
as
X
import
Data.Char
(
toLower
)
import
Data.Aeson.Types
as
X
import
Data.Monoid
((
<>
))
import
Data.Char
as
X
(
toLower
)
-- import Data.Decimal as X
import
Data.Maybe
as
X
(
catMaybes
)
import
Data.Monoid
as
X
((
<>
))
-- import Data.Scientific as X
import
Data.String
as
X
(
IsString
(
..
),
fromString
)
import
Data.Text
as
X
(
Text
,
unpack
,
pack
)
import
Data.Text.Encoding
as
X
import
Text.Read
(
readMaybe
)
import
Text.Read
(
readMaybe
)
...
...
stack.yaml
View file @
1c3d5cfd
flags
:
{}
flags
:
{}
extra-package-dbs
:
[]
extra-package-dbs
:
[]
packages
:
packages
:
-
'
.'
-
.
extra-deps
:
extra-deps
:
-
servant-0.11
-
servant-multipart-0.10.0.1
-
servant-multipart-0.10.0.1
-
servant-server-0.11
resolver
:
lts-9.2
#- utc-0.2.0.1
resolver
:
lts-8.21
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