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
574c5e08
Commit
574c5e08
authored
Mar 04, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FLOW] NgramsElements NgramsTerms fix.
parent
c898b780
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
10 deletions
+25
-10
List.hs
src/Gargantext/Text/List.hs
+25
-10
No files found.
src/Gargantext/Text/List.hs
View file @
574c5e08
...
...
@@ -20,6 +20,7 @@ commentary with @some markup@.
module
Gargantext.Text.List
where
import
Data.Set
(
Set
)
import
Data.Map
(
Map
)
import
Data.Text
(
Text
)
import
Gargantext.API.Ngrams
(
NgramsElement
,
mkNgramsElement
,
mSetFromList
)
...
...
@@ -32,24 +33,38 @@ import Gargantext.Prelude
import
qualified
Data.Map
as
Map
import
qualified
Data.Set
as
Set
import
qualified
Data.Text
as
Text
import
qualified
Data.List
as
List
buildNgramsList
::
UserCorpusId
->
MasterCorpusId
->
Cmd
err
(
Map
NgramsType
[
NgramsElement
])
buildNgramsList
::
UserCorpusId
->
MasterCorpusId
->
Cmd
err
(
Map
NgramsType
[
NgramsElement
])
buildNgramsList
uCid
mCid
=
do
candidates
<-
sortTficf
<$>
getTficf'
uCid
mCid
(
ngramsGroup
EN
2
)
printDebug
"candidate"
(
length
candidates
)
let
termList
=
toTermList
(
isStopTerm
.
fst
)
candidates
printDebug
"termlist"
(
length
termList
)
--printDebug "candidate" (length candidates)
let
termList
=
toTermList
(
isStopTerm
.
fst
)
candidates
--printDebug "termlist" (length termList)
let
ngs
=
map
(
\
(
lt
,
(
stm
,
(
_score
,
setext
)))
->
mkNgramsElement
stm
lt
(
Just
stm
)
(
mSetFromList
$
Set
.
toList
setext
)
)
termList
let
ngs
=
List
.
concat
$
map
toNgramsElement
termList
pure
$
Map
.
fromList
[(
NgramsTerms
,
ngs
)]
toNgramsElement
::
(
ListType
,
(
Text
,
(
Double
,
Set
Text
)))
->
[
NgramsElement
]
toNgramsElement
(
listType
,
(
_stem
,
(
_score
,
setNgrams
)))
=
case
Set
.
toList
setNgrams
of
[]
->
[]
(
parent
:
children
)
->
[
parentElem
]
<>
childrenElems
where
parentElem
=
mkNgramsElement
parent
listType
Nothing
(
mSetFromList
children
)
childrenElems
=
map
(
\
t
->
mkNgramsElement
t
listType
(
Just
parent
)
(
mSetFromList
[]
)
)
children
toTermList
::
(
a
->
Bool
)
->
[
a
]
->
[(
ListType
,
a
)]
toTermList
stop
ns
=
map
(
toTermList'
stop
CandidateTerm
)
xs
<>
map
(
toTermList'
stop
GraphTerm
)
ys
...
...
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