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
193c1ba1
Unverified
Commit
193c1ba1
authored
Feb 28, 2019
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename ListType constructors to align with the frontend
parent
67d296e1
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
27 deletions
+27
-27
Ngrams.hs
src/Gargantext/API/Ngrams.hs
+16
-16
Main.hs
src/Gargantext/Core/Types/Main.hs
+4
-4
Flow.hs
src/Gargantext/Database/Flow.hs
+3
-3
Utils.hs
src/Gargantext/Database/Flow/Utils.hs
+2
-2
Count.hs
src/Gargantext/Database/Metrics/Count.hs
+2
-2
No files found.
src/Gargantext/API/Ngrams.hs
View file @
193c1ba1
...
@@ -157,7 +157,7 @@ mkNgramsElement ngrams list parent children =
...
@@ -157,7 +157,7 @@ mkNgramsElement ngrams list parent children =
instance
ToSchema
NgramsElement
instance
ToSchema
NgramsElement
instance
Arbitrary
NgramsElement
where
instance
Arbitrary
NgramsElement
where
arbitrary
=
elements
[
mkNgramsElement
"sport"
Graph
List
Nothing
mempty
]
arbitrary
=
elements
[
mkNgramsElement
"sport"
Graph
Term
Nothing
mempty
]
------------------------------------------------------------------------
------------------------------------------------------------------------
newtype
NgramsTable
=
NgramsTable
[
NgramsElement
]
newtype
NgramsTable
=
NgramsTable
[
NgramsElement
]
...
@@ -199,18 +199,18 @@ toNgramsElement ns = map toNgramsElement' ns
...
@@ -199,18 +199,18 @@ toNgramsElement ns = map toNgramsElement' ns
mockTable
::
NgramsTable
mockTable
::
NgramsTable
mockTable
=
NgramsTable
mockTable
=
NgramsTable
[
mkNgramsElement
"animal"
Graph
List
Nothing
(
mSetFromList
[
"dog"
,
"cat"
])
[
mkNgramsElement
"animal"
Graph
Term
Nothing
(
mSetFromList
[
"dog"
,
"cat"
])
,
mkNgramsElement
"cat"
Graph
List
(
Just
"animal"
)
mempty
,
mkNgramsElement
"cat"
Graph
Term
(
Just
"animal"
)
mempty
,
mkNgramsElement
"cats"
Stop
List
Nothing
mempty
,
mkNgramsElement
"cats"
Stop
Term
Nothing
mempty
,
mkNgramsElement
"dog"
Graph
List
(
Just
"animal"
)(
mSetFromList
[
"dogs"
])
,
mkNgramsElement
"dog"
Graph
Term
(
Just
"animal"
)(
mSetFromList
[
"dogs"
])
,
mkNgramsElement
"dogs"
Stop
List
(
Just
"dog"
)
mempty
,
mkNgramsElement
"dogs"
Stop
Term
(
Just
"dog"
)
mempty
,
mkNgramsElement
"fox"
Graph
List
Nothing
mempty
,
mkNgramsElement
"fox"
Graph
Term
Nothing
mempty
,
mkNgramsElement
"object"
Candidate
List
Nothing
mempty
,
mkNgramsElement
"object"
Candidate
Term
Nothing
mempty
,
mkNgramsElement
"nothing"
Stop
List
Nothing
mempty
,
mkNgramsElement
"nothing"
Stop
Term
Nothing
mempty
,
mkNgramsElement
"organic"
Graph
List
Nothing
(
mSetFromList
[
"flower"
])
,
mkNgramsElement
"organic"
Graph
Term
Nothing
(
mSetFromList
[
"flower"
])
,
mkNgramsElement
"flower"
Graph
List
(
Just
"organic"
)
mempty
,
mkNgramsElement
"flower"
Graph
Term
(
Just
"organic"
)
mempty
,
mkNgramsElement
"moon"
Candidate
List
Nothing
mempty
,
mkNgramsElement
"moon"
Candidate
Term
Nothing
mempty
,
mkNgramsElement
"sky"
Stop
List
Nothing
mempty
,
mkNgramsElement
"sky"
Stop
Term
Nothing
mempty
]
]
instance
Arbitrary
NgramsTable
where
instance
Arbitrary
NgramsTable
where
...
@@ -501,7 +501,7 @@ instance Arbitrary a => Arbitrary (Versioned a) where
...
@@ -501,7 +501,7 @@ instance Arbitrary a => Arbitrary (Versioned a) where
type NgramsIdPatch = Patch NgramsId NgramsPatch
type NgramsIdPatch = Patch NgramsId NgramsPatch
ngramsPatch :: Int -> NgramsPatch
ngramsPatch :: Int -> NgramsPatch
ngramsPatch n = NgramsPatch (DM.fromList [(1, Stop
List
)]) (Set.fromList [n]) Set.empty
ngramsPatch n = NgramsPatch (DM.fromList [(1, Stop
Term
)]) (Set.fromList [n]) Set.empty
toEdit :: NgramsId -> NgramsPatch -> Edit NgramsId NgramsPatch
toEdit :: NgramsId -> NgramsPatch -> Edit NgramsId NgramsPatch
toEdit n p = Edit n p
toEdit n p = Edit n p
...
@@ -553,8 +553,8 @@ ngramError nne = throwError $ _NgramError # nne
...
@@ -553,8 +553,8 @@ ngramError nne = throwError $ _NgramError # nne
{-
{-
-- TODO: Replace.old is ignored which means that if the current list
-- TODO: Replace.old is ignored which means that if the current list
-- `Graph
List` and that the patch is `Replace CandidateList StopList
` then
-- `Graph
Term` and that the patch is `Replace CandidateTerm StopTerm
` then
-- the list is going to be `Stop
List` while it should keep `GraphList
`.
-- the list is going to be `Stop
Term` while it should keep `GraphTerm
`.
-- However this should not happen in non conflicting situations.
-- However this should not happen in non conflicting situations.
mkListsUpdate :: NgramsType -> NgramsTablePatch -> [(NgramsTypeId, NgramsTerm, ListTypeId)]
mkListsUpdate :: NgramsType -> NgramsTablePatch -> [(NgramsTypeId, NgramsTerm, ListTypeId)]
mkListsUpdate nt patches =
mkListsUpdate nt patches =
...
...
src/Gargantext/Core/Types/Main.hs
View file @
193c1ba1
...
@@ -87,7 +87,7 @@ type HashId = Text
...
@@ -87,7 +87,7 @@ type HashId = Text
type
TypeId
=
Int
type
TypeId
=
Int
-- TODO multiple ListType declaration, remove it
-- TODO multiple ListType declaration, remove it
data
ListType
=
Stop
List
|
CandidateList
|
GraphList
data
ListType
=
Stop
Term
|
CandidateTerm
|
GraphTerm
deriving
(
Generic
,
Eq
,
Ord
,
Show
,
Read
,
Enum
,
Bounded
)
deriving
(
Generic
,
Eq
,
Ord
,
Show
,
Read
,
Enum
,
Bounded
)
instance
ToJSON
ListType
instance
ToJSON
ListType
...
@@ -103,9 +103,9 @@ instance FromHttpApiData ListType where
...
@@ -103,9 +103,9 @@ instance FromHttpApiData ListType where
type
ListTypeId
=
Int
type
ListTypeId
=
Int
listTypeId
::
ListType
->
ListTypeId
listTypeId
::
ListType
->
ListTypeId
listTypeId
Stop
List
=
0
listTypeId
Stop
Term
=
0
listTypeId
Candidate
List
=
1
listTypeId
Candidate
Term
=
1
listTypeId
Graph
List
=
2
listTypeId
Graph
Term
=
2
fromListTypeId
::
ListTypeId
->
Maybe
ListType
fromListTypeId
::
ListTypeId
->
Maybe
ListType
fromListTypeId
i
=
lookup
i
$
fromList
[
(
listTypeId
l
,
l
)
|
l
<-
[
minBound
..
maxBound
]]
fromListTypeId
i
=
lookup
i
$
fromList
[
(
listTypeId
l
,
l
)
|
l
<-
[
minBound
..
maxBound
]]
...
...
src/Gargantext/Database/Flow.hs
View file @
193c1ba1
...
@@ -317,7 +317,7 @@ flowListUser uId cId ngsM _n = do
...
@@ -317,7 +317,7 @@ flowListUser uId cId ngsM _n = do
trace
(
"flowListBase"
<>
show
lId
)
flowListBase
lId
ngsM
trace
(
"flowListBase"
<>
show
lId
)
flowListBase
lId
ngsM
putListNgrams
lId
NgramsTerms
$
putListNgrams
lId
NgramsTerms
$
[
mkNgramsElement
(
tficf_ngramsTerms
ng
)
GraphList
Nothing
mempty
[
mkNgramsElement
ng
GraphTerm
Nothing
mempty
|
ng
<-
ngs
|
ng
<-
ngs
]
]
...
@@ -327,7 +327,7 @@ flowListUser uId cId ngsM _n = do
...
@@ -327,7 +327,7 @@ flowListUser uId cId ngsM _n = do
ngrams2list
::
Map
NgramsIndexed
(
Map
NgramsType
a
)
ngrams2list
::
Map
NgramsIndexed
(
Map
NgramsType
a
)
->
[(
ListType
,
(
NgramsType
,
NgramsIndexed
))]
->
[(
ListType
,
(
NgramsType
,
NgramsIndexed
))]
ngrams2list
m
=
ngrams2list
m
=
[
(
Candidate
List
,
(
t
,
ng
))
[
(
Candidate
Term
,
(
t
,
ng
))
|
(
ng
,
tm
)
<-
DM
.
toList
m
|
(
ng
,
tm
)
<-
DM
.
toList
m
,
t
<-
DM
.
keys
tm
,
t
<-
DM
.
keys
tm
]
]
...
@@ -335,7 +335,7 @@ ngrams2list m =
...
@@ -335,7 +335,7 @@ ngrams2list m =
ngrams2list'
::
Map
NgramsIndexed
(
Map
NgramsType
a
)
ngrams2list'
::
Map
NgramsIndexed
(
Map
NgramsType
a
)
->
Map
NgramsType
[
NgramsElement
]
->
Map
NgramsType
[
NgramsElement
]
ngrams2list'
m
=
fromListWith
(
<>
)
ngrams2list'
m
=
fromListWith
(
<>
)
[
(
t
,
[
mkNgramsElement
(
_ngramsTerms
$
_ngrams
ng
)
Candidate
List
Nothing
mempty
])
[
(
t
,
[
mkNgramsElement
(
_ngramsTerms
$
_ngrams
ng
)
Candidate
Term
Nothing
mempty
])
|
(
ng
,
tm
)
<-
DM
.
toList
m
|
(
ng
,
tm
)
<-
DM
.
toList
m
,
t
<-
DM
.
keys
tm
,
t
<-
DM
.
keys
tm
]
]
...
...
src/Gargantext/Database/Flow/Utils.hs
View file @
193c1ba1
...
@@ -54,10 +54,10 @@ data DocumentIdWithNgrams a =
...
@@ -54,10 +54,10 @@ data DocumentIdWithNgrams a =
,
document_ngrams
::
Map
(
NgramsT
Ngrams
)
Int
,
document_ngrams
::
Map
(
NgramsT
Ngrams
)
Int
}
deriving
(
Show
)
}
deriving
(
Show
)
-- | TODO for now, list Type is Candidate
List because Graph Terms
-- | TODO for now, list Type is Candidate
Term because Graph Terms
-- have to be detected in next step in the flow
-- have to be detected in next step in the flow
insertToNodeNgrams
::
Map
NgramsIndexed
(
Map
NgramsType
(
Map
NodeId
Int
))
->
Cmd
err
Int
insertToNodeNgrams
::
Map
NgramsIndexed
(
Map
NgramsType
(
Map
NodeId
Int
))
->
Cmd
err
Int
insertToNodeNgrams
m
=
insertNodeNgrams
[
NodeNgram
n
(
_ngramsId
ng
)
Nothing
(
ngramsTypeId
t
)
(
listTypeId
Candidate
List
)
(
fromIntegral
i
)
insertToNodeNgrams
m
=
insertNodeNgrams
[
NodeNgram
n
(
_ngramsId
ng
)
Nothing
(
ngramsTypeId
t
)
(
listTypeId
Candidate
Term
)
(
fromIntegral
i
)
|
(
ng
,
t2n2i
)
<-
DM
.
toList
m
|
(
ng
,
t2n2i
)
<-
DM
.
toList
m
,
(
t
,
n2i
)
<-
DM
.
toList
t2n2i
,
(
t
,
n2i
)
<-
DM
.
toList
t2n2i
,
(
n
,
i
)
<-
DM
.
toList
n2i
,
(
n
,
i
)
<-
DM
.
toList
n2i
...
...
src/Gargantext/Database/Metrics/Count.hs
View file @
193c1ba1
...
@@ -65,7 +65,7 @@ getNgramsByDoc cId lId =
...
@@ -65,7 +65,7 @@ getNgramsByDoc cId lId =
getNgramsByDocDb
::
CorpusId
->
ListId
->
Cmd
err
[(
NodeId
,
NgramsId
,
Text
,
Int
)]
getNgramsByDocDb
::
CorpusId
->
ListId
->
Cmd
err
[(
NodeId
,
NgramsId
,
Text
,
Int
)]
getNgramsByDocDb
cId
lId
=
runPGSQuery
query
params
getNgramsByDocDb
cId
lId
=
runPGSQuery
query
params
where
where
params
=
(
cId
,
lId
,
listTypeId
Graph
List
,
ngramsTypeId
NgramsTerms
)
params
=
(
cId
,
lId
,
listTypeId
Graph
Term
,
ngramsTypeId
NgramsTerms
)
query
=
[
sql
|
query
=
[
sql
|
-- TODO add CTE
-- TODO add CTE
...
@@ -208,7 +208,7 @@ getNgramsElementsWithParentNodeId nId = do
...
@@ -208,7 +208,7 @@ getNgramsElementsWithParentNodeId nId = do
ns
<-
getNgramsWithParentNodeId
nId
ns
<-
getNgramsWithParentNodeId
nId
pure
$
fromListWith
(
<>
)
pure
$
fromListWith
(
<>
)
[
(
maybe
(
panic
"error"
)
identity
$
fromNgramsTypeId
nt
,
[
(
maybe
(
panic
"error"
)
identity
$
fromNgramsTypeId
nt
,
[
mkNgramsElement
ng
Candidate
List
Nothing
mempty
])
[
mkNgramsElement
ng
Candidate
Term
Nothing
mempty
])
|
(
_
,(
nt
,
ng
))
<-
ns
|
(
_
,(
nt
,
ng
))
<-
ns
]
]
...
...
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