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
5523d058
Commit
5523d058
authored
Nov 02, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[API][NGRAMS][PATCH] basic change working with replace function.
parent
33a3fc84
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
14 deletions
+50
-14
Ngrams.hs
src/Gargantext/API/Ngrams.hs
+39
-10
Main.hs
src/Gargantext/Core/Types/Main.hs
+2
-1
Types.hs
src/Gargantext/Text/List/Types.hs
+9
-3
No files found.
src/Gargantext/API/Ngrams.hs
View file @
5523d058
...
@@ -32,14 +32,18 @@ import Data.Aeson (FromJSON, ToJSON)
...
@@ -32,14 +32,18 @@ import Data.Aeson (FromJSON, ToJSON)
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Map.Strict
(
Map
)
import
Data.Map.Strict
(
Map
)
import
Data.Map.Strict.Patch
(
Patch
,
apply
,
transformWith
)
import
qualified
Data.Map.Strict
as
DM
import
Data.Map.Strict.Patch
(
Patch
,
apply
,
Edit
,
EditV
,
replace
,
transformWith
,
fromList
)
import
Data.Text
(
Text
)
import
Data.Text
(
Text
)
import
Data.Maybe
(
catMaybes
)
import
Data.Set
(
Set
)
import
Data.Set
(
Set
)
import
qualified
Data.Set
as
Set
import
GHC.Generics
(
Generic
)
import
GHC.Generics
(
Generic
)
import
Gargantext.Database.Ngram
(
NgramsId
)
import
Gargantext.Database.Ngram
(
NgramsId
)
import
Gargantext.Database.User
(
UserId
)
import
Gargantext.Database.User
(
UserId
)
import
Gargantext.
Core
.Types
(
ListType
(
..
))
import
Gargantext.
Text.List
.Types
(
ListType
(
..
))
import
Gargantext.Core.Types.Main
(
Tree
(
..
))
import
Gargantext.Core.Types.Main
(
Tree
(
..
))
import
Gargantext.Core.Utils.Prefix
(
unPrefix
)
import
Gargantext.Core.Utils.Prefix
(
unPrefix
)
import
Gargantext.Prelude
import
Gargantext.Prelude
...
@@ -49,11 +53,12 @@ data NgramsElement =
...
@@ -49,11 +53,12 @@ data NgramsElement =
,
_ne_ngrams
::
Text
,
_ne_ngrams
::
Text
,
_ne_list
::
ListType
,
_ne_list
::
ListType
}
}
deriving
(
Ord
,
Eq
)
$
(
deriveJSON
(
unPrefix
"_ne_"
)
''
N
gramsElement
)
$
(
deriveJSON
(
unPrefix
"_ne_"
)
''
N
gramsElement
)
data
NgramsTable
=
NgramsTable
{
_ngramsTable
::
[
Tree
NgramsElement
]
}
data
NgramsTable
=
NgramsTable
{
_ngramsTable
::
[
Tree
NgramsElement
]
}
deriving
(
Generic
)
deriving
(
Ord
,
Eq
,
Generic
)
instance
ToJSON
NgramsTable
instance
ToJSON
NgramsTable
instance
FromJSON
NgramsTable
instance
FromJSON
NgramsTable
...
@@ -67,16 +72,40 @@ instance ToJSON (Tree NgramsElement)
...
@@ -67,16 +72,40 @@ instance ToJSON (Tree NgramsElement)
-- | SetListType NgramsId ListType
-- | SetListType NgramsId ListType
data
NgramsPatch
=
data
NgramsPatch
=
NgramsPatch
{
list_types
::
Map
UserId
ListType
NgramsPatch
{
_np_
list_types
::
Map
UserId
ListType
,
add_children
::
Set
NgramsId
,
_np_
add_children
::
Set
NgramsId
,
rem_children
::
Set
NgramsId
,
_np_
rem_children
::
Set
NgramsId
}
}
deriving
(
Ord
,
Eq
,
Show
)
$
(
deriveJSON
(
unPrefix
"_np_"
)
''
N
gramsPatch
)
type
NgramsIdPatch
=
Patch
NgramsId
NgramsPatch
------------------------------------------------------------------------
type
Version
=
Int
data
Versioned
a
=
Versioned
{
_v_version
::
Version
,
_v_data
::
a
}
ngramsPatch
::
NgramsPatch
ngramsPatch
=
NgramsPatch
(
DM
.
fromList
[(
1
,
StopList
)])
Set
.
empty
Set
.
empty
{-
toEdit :: NgramsId -> NgramsPatch -> Edit NgramsId NgramsPatch
toEdit n p = Edit n p
-}
ngramsIdPatch
::
Patch
NgramsId
NgramsPatch
ngramsIdPatch
=
fromList
$
catMaybes
$
reverse
[
replace
(
1
::
NgramsId
)
(
Just
ngramsPatch
)
Nothing
,
replace
(
1
::
NgramsId
)
Nothing
(
Just
ngramsPatch
)
,
replace
(
2
::
NgramsId
)
Nothing
(
Just
ngramsPatch
)
]
data
Patch
=
Map
NgramsId
NgramsPatch
-- applyPatchBack :: Patch -> IO Patch
-- applyPatchBack :: Patch -> IO Patch
-- isEmptyPatch = Map.all (\x -> Set.isEmpty (add_children x) && Set.isEmpty ... )
-- isEmptyPatch = Map.all (\x -> Set.isEmpty (add_children x) && Set.isEmpty ... )
-------------------------------------------------------------------
------------------------------------------------------------------------
-------------------------------------------------------------------
-------------------------------------------------------------------
src/Gargantext/Core/Types/Main.hs
View file @
5523d058
...
@@ -78,6 +78,7 @@ corpusTree nId t = TreeN (NodeTree ("Corpus " <> t) NodeCorpus nId) ( [ leafT
...
@@ -78,6 +78,7 @@ corpusTree nId t = TreeN (NodeTree ("Corpus " <> t) NodeCorpus nId) ( [ leafT
--data Classification = Favorites | MyClassifcation
--data Classification = Favorites | MyClassifcation
-- TODO multiple ListType declaration, remove it
data
ListType
=
Stop
|
Candidate
|
Map
data
ListType
=
Stop
|
Candidate
|
Map
deriving
(
Generic
)
deriving
(
Generic
)
...
@@ -132,7 +133,7 @@ type Offset = Int
...
@@ -132,7 +133,7 @@ type Offset = Int
------------------------------------------------------------------------
------------------------------------------------------------------------
-- All the Database is structred like a hierarchical Tree
-- All the Database is structred like a hierarchical Tree
data
Tree
a
=
TreeN
a
[
Tree
a
]
data
Tree
a
=
TreeN
a
[
Tree
a
]
deriving
(
Show
,
Read
,
Eq
,
Generic
)
deriving
(
Show
,
Read
,
Eq
,
Generic
,
Ord
)
instance
ToJSON
(
Tree
NodeTree
)
where
instance
ToJSON
(
Tree
NodeTree
)
where
toJSON
(
TreeN
node
nodes
)
=
toJSON
(
TreeN
node
nodes
)
=
...
...
src/Gargantext/Text/List/Types.hs
View file @
5523d058
...
@@ -11,19 +11,25 @@ CSV parser for Gargantext corpus files.
...
@@ -11,19 +11,25 @@ CSV parser for Gargantext corpus files.
-}
-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedStrings #-}
module
Gargantext.Text.List.Types
where
module
Gargantext.Text.List.Types
where
import
Prelude
(
Bounded
,
Enum
,
minBound
,
maxBound
)
import
Data.Aeson
(
FromJSON
,
ToJSON
)
import
Data.Text
(
Text
)
import
Data.Map
(
Map
,
empty
,
fromList
)
import
Data.Map
(
Map
,
empty
,
fromList
)
import
Data.Text
(
Text
)
import
GHC.Generics
(
Generic
)
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Prelude
(
Bounded
,
Enum
,
minBound
,
maxBound
)
-------------------------------------------------------------------
-------------------------------------------------------------------
data
ListType
=
GraphList
|
StopList
|
CandidateList
data
ListType
=
GraphList
|
StopList
|
CandidateList
deriving
(
Show
,
Eq
,
Ord
,
Enum
,
Bounded
)
deriving
(
Show
,
Eq
,
Ord
,
Enum
,
Bounded
,
Generic
)
instance
FromJSON
ListType
instance
ToJSON
ListType
type
Lists
=
Map
ListType
(
Map
Text
[
Text
])
type
Lists
=
Map
ListType
(
Map
Text
[
Text
])
...
...
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