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
148
Issues
148
List
Board
Labels
Milestones
Merge Requests
10
Merge Requests
10
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
c738e89d
Commit
c738e89d
authored
Oct 14, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[SocialList] ListType for groups, tested for stop, ok
parent
47e7a53a
Pipeline
#1152
failed with stage
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
18 deletions
+30
-18
List.hs
src/Gargantext/Core/Text/List.hs
+11
-6
Types.hs
src/Gargantext/Core/Text/Types.hs
+19
-12
No files found.
src/Gargantext/Core/Text/List.hs
View file @
c738e89d
...
...
@@ -15,6 +15,7 @@ module Gargantext.Core.Text.List
where
import
Control.Lens
((
^.
))
import
Data.Maybe
(
fromMaybe
,
catMaybes
)
import
Data.Ord
(
Down
(
..
))
import
Data.Map
(
Map
)
...
...
@@ -31,7 +32,7 @@ import Gargantext.API.Ngrams.Types (RepoCmdM)
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Core.Text
(
size
)
import
Gargantext.Core.Text.List.Learn
(
Model
(
..
))
import
Gargantext.Core.Text.List.Social
(
flowSocialList
)
import
Gargantext.Core.Text.List.Social
(
flowSocialList
,
invertForw
)
import
Gargantext.Core.Text.Metrics
(
scored'
,
Scored
(
..
),
normalizeGlobal
,
normalizeLocal
)
import
Gargantext.Core.Text.Types
import
Gargantext.Core.Types
(
ListType
(
..
),
MasterCorpusId
,
UserCorpusId
)
...
...
@@ -142,14 +143,15 @@ buildNgramsTermsList user l n m _s uCid mCid = do
printDebug
"
\n
* socialLists *
\n
"
socialLists
{-
let
_socialMap = fromMaybe Set.empty $ Map.lookup MapTerm socialLists
_socialCand = fromMaybe Set.empty $ Map.lookup CandidateTerm socialLists
socialStop = fromMaybe Set.empty $ Map.lookup StopTerm socialLists
-- stopTerms ignored for now (need to be tagged already)
(
stopTerms
,
candidateTerms
)
=
List
.
partition
((
\
t
->
Set
.
member
t
socialStop
)
.
fst
)
allTerms
-- (stopTerms, candidateTerms) = List.partition ((\t -> Set.member t socialStop) . fst) allTerms
-}
printDebug
"
\n
* stopTerms *
\n
"
stopTerms
-- Grouping the ngrams and keeping the maximum score for label
let
grouped
=
groupStems'
...
...
@@ -157,10 +159,13 @@ buildNgramsTermsList user l n m _s uCid mCid = do
in
(
stem
,
GroupedText
Nothing
t
d
Set
.
empty
(
size
t
)
stem
Set
.
empty
)
)
candidate
Terms
)
all
Terms
(
groupedMono
,
groupedMult
)
=
Map
.
partition
(
\
gt
->
_gt_size
gt
<
2
)
grouped
groupedWithList
=
map
(
addListType
(
invertForw
socialLists
))
grouped
(
stopTerms
,
candidateTerms
)
=
Map
.
partition
(
\
t
->
t
^.
gt_listType
==
Just
StopTerm
)
groupedWithList
(
groupedMono
,
groupedMult
)
=
Map
.
partition
(
\
gt
->
_gt_size
gt
<
2
)
candidateTerms
-- printDebug "\n * stopTerms * \n" stopTerms
-- printDebug "groupedMult" groupedMult
-- splitting monterms and multiterms to take proportional candidates
let
...
...
@@ -288,8 +293,8 @@ buildNgramsTermsList user l n m _s uCid mCid = do
[
Map
.
fromList
[(
NgramsTerms
,
(
List
.
concat
$
map
toNgramsElement
$
termListHead
)
<>
(
List
.
concat
$
map
toNgramsElement
$
termListTail
)
<>
(
List
.
concat
$
map
toNgramsElement
$
stopTerms
)
)]
,
toElements
NgramsTerms
StopTerm
stopTerms
]
-- printDebug "\n result \n" r
pure
result
...
...
src/Gargantext/Core/Text/Types.hs
View file @
c738e89d
...
...
@@ -14,7 +14,7 @@ Portability : POSIX
module
Gargantext.Core.Text.Types
where
import
Control.Lens
(
makeLenses
)
import
Control.Lens
(
makeLenses
,
set
)
import
Data.Set
(
Set
)
import
Data.Map
(
Map
)
import
Data.Text
(
Text
)
...
...
@@ -26,15 +26,6 @@ import qualified Data.Set as Set
import
qualified
Data.Map
as
Map
import
qualified
Data.List
as
List
------------------------------------------------------------------------------
hasListType
::
Map
Text
ListType
->
GroupedText
a
->
Maybe
ListType
hasListType
m
(
GroupedText
_
label
_
g
_
_
_
)
=
List
.
foldl'
(
<>
)
Nothing
$
map
(
\
t
->
Map
.
lookup
t
m
)
$
Set
.
toList
$
Set
.
insert
label
g
------------------------------------------------------------------------------
type
Group
=
Lang
->
Int
->
Int
->
Text
->
Text
type
Stem
=
Text
...
...
@@ -59,7 +50,23 @@ instance (Eq a, Ord a) => Ord (GroupedText a) where
compare
(
GroupedText
_
_
score1
_
_
_
_
)
(
GroupedText
_
_
score2
_
_
_
_
)
=
compare
score1
score2
-- Lenses Instances
makeLenses
'G
r
oupedText
------------------------------------------------------------------------------
addListType
::
Map
Text
ListType
->
GroupedText
a
->
GroupedText
a
addListType
m
g
=
set
gt_listType
lt
g
where
lt
=
hasListType
m
g
hasListType
::
Map
Text
ListType
->
GroupedText
a
->
Maybe
ListType
hasListType
m
(
GroupedText
_
label
_
g
_
_
_
)
=
List
.
foldl'
(
<>
)
Nothing
$
map
(
\
t
->
Map
.
lookup
t
m
)
$
Set
.
toList
$
Set
.
insert
label
g
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