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
13
Merge Requests
13
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
bb469f39
Commit
bb469f39
authored
Jan 18, 2021
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[TYPES] group type for lems
parent
0ad7fc65
Pipeline
#1353
failed with stage
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
13 deletions
+27
-13
Core.hs
src/Gargantext/Core.hs
+4
-0
WithStem.hs
src/Gargantext/Core/Text/List/Group/WithStem.hs
+23
-10
NgramsPostag.hs
src/Gargantext/Database/Query/Table/NgramsPostag.hs
+0
-3
No files found.
src/Gargantext/Core.hs
View file @
bb469f39
...
...
@@ -12,6 +12,7 @@ Portability : POSIX
module
Gargantext.Core
where
import
Data.Text
(
Text
)
import
Data.Aeson
import
Data.Either
(
Either
(
Left
))
import
Data.Hashable
(
Hashable
)
...
...
@@ -67,6 +68,9 @@ instance HasDBid Lang where
fromDBid
2
=
EN
fromDBid
_
=
panic
"HasDBid lang, not implemented"
------------------------------------------------------------------------
type
Form
=
Text
type
Lem
=
Text
------------------------------------------------------------------------
data
PosTagAlgo
=
CoreNLP
deriving
(
Show
,
Read
,
Eq
,
Ord
,
Generic
)
...
...
src/Gargantext/Core/Text/List/Group/WithStem.hs
View file @
bb469f39
...
...
@@ -17,16 +17,18 @@ Portability : POSIX
module
Gargantext.Core.Text.List.Group.WithStem
where
import
Data.HashMap.Strict
(
HashMap
)
import
Data.HashSet
(
HashSet
)
import
Data.Map
(
Map
)
import
Data.Maybe
(
catMaybes
)
import
Gargantext.API.Ngrams.Types
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Core
(
Lang
(
..
)
,
PosTagAlgo
(
..
),
Form
,
Lem
)
import
Gargantext.Core.Text.List.Group.Prelude
import
Gargantext.Core.Text.List.Social.Patch
import
Gargantext.Core.Text.List.Social.Prelude
import
Gargantext.Core.Text.Terms.Mono.Stem
(
stem
)
import
Gargantext.Prelude
import
qualified
Data.HashMap.Strict
as
HashMap
import
qualified
Data.HashSet
as
Set
import
qualified
Data.List
as
List
import
qualified
Data.Map
as
Map
...
...
@@ -57,23 +59,33 @@ data GroupParams = GroupParams { unGroupParams_lang :: !Lang
,
unGroupParams_stopSize
::
!
StopSize
}
|
GroupIdentity
|
GroupWithPosTag
{
_gwl_lang
::
!
Lang
,
_gwl_algo
::
!
PosTagAlgo
,
_gwl_map
::
!
(
HashMap
Form
Lem
)
}
deriving
(
Eq
)
------------------------------------------------------------------------
groupWith
::
GroupParams
->
NgramsTerm
->
NgramsTerm
groupWith
GroupIdentity
=
identity
groupWith
(
GroupParams
l
_m
_n
_
)
=
groupWith
GroupIdentity
t
=
identity
t
groupWith
(
GroupParams
l
_m
_n
_
)
t
=
NgramsTerm
.
Text
.
intercalate
" "
.
map
(
stem
l
)
$
Text
.
intercalate
" "
$
map
(
stem
l
)
-- . take n
.
List
.
sort
$
List
.
sort
-- . (List.filter (\t -> Text.length t > m))
.
Text
.
splitOn
" "
.
Text
.
replace
"-"
" "
.
unNgramsTerm
$
Text
.
splitOn
" "
$
Text
.
replace
"-"
" "
$
unNgramsTerm
t
groupWith
(
GroupWithPosTag
_
_
m
)
t
=
case
HashMap
.
lookup
(
unNgramsTerm
t
)
m
of
Nothing
->
t
Just
t'
->
NgramsTerm
t'
--------------------------------------------------------------------
stemPatches
::
GroupParams
->
HashSet
NgramsTerm
...
...
@@ -81,7 +93,8 @@ stemPatches :: GroupParams
stemPatches
groupParams
=
patches
.
Map
.
fromListWith
(
<>
)
.
map
(
\
ng
->
(
groupWith
groupParams
ng
,
Set
.
singleton
ng
)
,
Set
.
singleton
ng
)
)
.
Set
.
toList
...
...
src/Gargantext/Database/Query/Table/NgramsPostag.hs
View file @
bb469f39
...
...
@@ -136,9 +136,6 @@ 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
...
...
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