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
199
Issues
199
List
Board
Labels
Milestones
Merge Requests
12
Merge Requests
12
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
c37cdf4b
Commit
c37cdf4b
authored
Jul 03, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[WithList] merge function is right thx to @npouillard
parent
3ac3fa94
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
9 deletions
+6
-9
Terms.hs
src/Gargantext/Text/Terms.hs
+1
-3
WithList.hs
src/Gargantext/Text/Terms/WithList.hs
+5
-6
No files found.
src/Gargantext/Text/Terms.hs
View file @
c37cdf4b
...
@@ -62,8 +62,6 @@ terms :: TermType Lang -> Text -> IO [Terms]
...
@@ -62,8 +62,6 @@ terms :: TermType Lang -> Text -> IO [Terms]
terms
(
Mono
lang
)
txt
=
pure
$
monoTerms
lang
txt
terms
(
Mono
lang
)
txt
=
pure
$
monoTerms
lang
txt
terms
(
Multi
lang
)
txt
=
multiterms
lang
txt
terms
(
Multi
lang
)
txt
=
multiterms
lang
txt
terms
(
MonoMulti
lang
)
txt
=
terms
(
Multi
lang
)
txt
terms
(
MonoMulti
lang
)
txt
=
terms
(
Multi
lang
)
txt
terms
(
WithList
list
)
txt
=
pure
.
map
(
\
x
->
Terms
x
Set
.
empty
{-TODO-}
)
$
extractTermsWithList
labelPolicy
list
txt
terms
(
WithList
list
)
txt
=
pure
.
map
(
\
x
->
Terms
x
Set
.
empty
{-TODO-}
)
$
extractTermsWithList
list
txt
where
labelPolicy
=
undefined
------------------------------------------------------------------------
------------------------------------------------------------------------
src/Gargantext/Text/Terms/WithList.hs
View file @
c37cdf4b
...
@@ -33,8 +33,8 @@ type TermList = [(Label, [[Term]])]
...
@@ -33,8 +33,8 @@ type TermList = [(Label, [[Term]])]
type
Patterns
=
[(
Pattern
,
Int
,
Label
)]
type
Patterns
=
[(
Pattern
,
Int
,
Label
)]
replaceTerms
::
(
Term
->
Label
)
->
Patterns
->
Sentence
Term
->
Sentence
Label
replaceTerms
::
Patterns
->
Sentence
Term
->
Sentence
Label
replaceTerms
labelPolicy
pats
terms
=
go
0
terms
replaceTerms
pats
terms
=
go
0
terms
where
where
go
_
[]
=
[]
go
_
[]
=
[]
go
!
ix
(
t
:
ts
)
=
go
!
ix
(
t
:
ts
)
=
...
@@ -43,9 +43,8 @@ replaceTerms labelPolicy pats terms = go 0 terms
...
@@ -43,9 +43,8 @@ replaceTerms labelPolicy pats terms = go 0 terms
Just
(
len
,
label
)
->
Just
(
len
,
label
)
->
label
:
go
(
ix
+
len
)
(
drop
(
len
-
1
)
ts
)
label
:
go
(
ix
+
len
)
(
drop
(
len
-
1
)
ts
)
-- | merge with labelPolicy (can be a Map Term label)
merge
(
len1
,
lab1
)
(
len2
,
lab2
)
=
merge
(
len1
,
lab1
)
(
len2
,
lab2
)
=
if
(
labelPolicy
lab1
)
==
lab2
then
(
len2
,
lab2
)
else
(
len1
,
lab1
)
if
len2
<
len1
then
(
len1
,
lab1
)
else
(
len2
,
lab2
)
m
=
m
=
IntMap
.
fromListWith
merge
IntMap
.
fromListWith
merge
...
@@ -59,5 +58,5 @@ buildPatterns = concatMap buildPattern
...
@@ -59,5 +58,5 @@ buildPatterns = concatMap buildPattern
where
where
f
alt
=
(
KMP
.
build
alt
,
length
alt
,
label
)
f
alt
=
(
KMP
.
build
alt
,
length
alt
,
label
)
extractTermsWithList
::
(
Term
->
Label
)
->
Patterns
->
Text
->
Corpus
Label
extractTermsWithList
::
Patterns
->
Text
->
Corpus
Label
extractTermsWithList
labelPolicy
pats
=
map
(
replaceTerms
labelPolicy
pats
)
.
monoTextsBySentence
extractTermsWithList
pats
=
map
(
replaceTerms
pats
)
.
monoTextsBySentence
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