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
160
Issues
160
List
Board
Labels
Milestones
Merge Requests
14
Merge Requests
14
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
2ccdaf09
Verified
Commit
2ccdaf09
authored
Dec 10, 2024
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[utils] fix nonemptyIntercalate
parent
79b7fa9c
Pipeline
#7107
passed with stages
in 47 minutes and 29 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
19 deletions
+16
-19
Hal.hs
src/Gargantext/Core/Text/Corpus/API/Hal.hs
+3
-3
Istex.hs
src/Gargantext/Core/Text/Corpus/Parsers/JSON/Istex.hs
+4
-4
Utils.hs
src/Gargantext/Core/Utils.hs
+4
-7
Utils.hs
test/Test/Core/Utils.hs
+5
-5
No files found.
src/Gargantext/Core/Text/Corpus/API/Hal.hs
View file @
2ccdaf09
...
...
@@ -17,7 +17,7 @@ import Data.LanguageCodes qualified as ISO639
import
Data.Map.Strict
qualified
as
Map
import
Data.Text
(
pack
)
import
Gargantext.Core.Text.Corpus.Parsers.Date
qualified
as
Date
import
Gargantext.Core.Utils
(
nonempty
Join
)
import
Gargantext.Core.Utils
(
nonempty
Intercalate
)
import
Gargantext.Database.Admin.Types.Hyperdata.Document
(
HyperdataDocument
(
..
)
)
import
Gargantext.Defaults
qualified
as
Defaults
import
Gargantext.Prelude
hiding
(
intercalate
)
...
...
@@ -53,8 +53,8 @@ toDoc' la (HAL.Document { .. }) = do
,
_hd_url
=
Nothing
,
_hd_page
=
Nothing
,
_hd_title
=
Just
$
unwords
_document_title
,
_hd_authors
=
Just
$
nonempty
Join
", "
_document_authors_names
,
_hd_institutes
=
Just
$
nonempty
Join
", "
$
zipWith
(
\
affialition
structId
->
affialition
<>
" | "
<>
structId
)
_document_authors_affiliations
$
map
show
_document_struct_id
,
_hd_authors
=
Just
$
nonempty
Intercalate
", "
_document_authors_names
,
_hd_institutes
=
Just
$
nonempty
Intercalate
", "
$
zipWith
(
\
affialition
structId
->
affialition
<>
" | "
<>
structId
)
_document_authors_affiliations
$
map
show
_document_struct_id
,
_hd_source
=
Just
$
maybe
"Nothing"
identity
_document_source
,
_hd_abstract
=
Just
abstract
,
_hd_publication_date
=
fmap
show
utctime
...
...
src/Gargantext/Core/Text/Corpus/Parsers/JSON/Istex.hs
View file @
2ccdaf09
...
...
@@ -19,7 +19,7 @@ module Gargantext.Core.Text.Corpus.Parsers.JSON.Istex where
import
Data.Text
qualified
as
T
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Core.Text.Corpus.Parsers.Date
qualified
as
Date
import
Gargantext.Core.Utils
(
nonempty
Join
)
import
Gargantext.Core.Utils
(
nonempty
Intercalate
)
import
Gargantext.Database.Admin.Types.Hyperdata.Document
(
HyperdataDocument
(
..
))
import
Gargantext.Defaults
qualified
as
Defaults
import
Gargantext.Prelude
hiding
(
length
)
...
...
@@ -39,9 +39,9 @@ toDoc la (ISTEX.Document i t a ab d s) = do
,
_hd_url
=
Nothing
,
_hd_page
=
Nothing
,
_hd_title
=
t
,
_hd_authors
=
Just
$
nonempty
Join
", "
(
map
ISTEX
.
_author_name
a
)
,
_hd_institutes
=
Just
$
nonempty
Join
", "
(
concatMap
ISTEX
.
_author_affiliations
a
)
,
_hd_source
=
Just
$
nonempty
Join
", "
$
maybeToList
$
join
(
ISTEX
.
_source_title
<$>
s
)
,
_hd_authors
=
Just
$
nonempty
Intercalate
", "
(
map
ISTEX
.
_author_name
a
)
,
_hd_institutes
=
Just
$
nonempty
Intercalate
", "
(
concatMap
ISTEX
.
_author_affiliations
a
)
,
_hd_source
=
Just
$
nonempty
Intercalate
", "
$
maybeToList
$
join
(
ISTEX
.
_source_title
<$>
s
)
,
_hd_abstract
=
ab
,
_hd_publication_date
=
fmap
(
T
.
pack
.
show
)
utctime
,
_hd_publication_year
=
pub_year
...
...
src/Gargantext/Core/Utils.hs
View file @
2ccdaf09
...
...
@@ -23,7 +23,7 @@ module Gargantext.Core.Utils (
,
addTuples
,
(
?!
)
,
(
?|
)
,
nonempty
Join
,
nonempty
Intercalate
)
where
import
Data.List
qualified
as
List
...
...
@@ -91,9 +91,6 @@ infixr 4 ?|
(
?|
)
=
flip
fromMaybe
-- | Join strings, but only nonempty ones
nonemptyJoin
::
Text
->
[
Text
]
->
Text
nonemptyJoin
_sep
[]
=
""
nonemptyJoin
_sep
[
x
]
=
x
nonemptyJoin
sep
(
""
:
xs
)
=
nonemptyJoin
sep
xs
nonemptyJoin
sep
(
x
:
xs
)
=
x
<>
sep
<>
(
nonemptyJoin
sep
xs
)
-- | Intercalate strings, but only nonempty ones
nonemptyIntercalate
::
Text
->
[
Text
]
->
Text
nonemptyIntercalate
sep
xs
=
T
.
intercalate
sep
$
filter
(
/=
""
)
xs
test/Test/Core/Utils.hs
View file @
2ccdaf09
...
...
@@ -21,11 +21,11 @@ test = do
describe
"check if groupWithCounts works"
$
do
it
"simple integer array"
$
groupWithCounts
testArray
`
shouldBe
`
groupedArray
it
"string"
$
groupWithCounts
testString
`
shouldBe
`
groupedString
describe
"check nonempty
Join
"
$
do
it
"empty list"
$
nonempty
Join
","
[]
`
shouldBe
`
""
it
"simple list"
$
nonempty
Join
","
[
"x"
]
`
shouldBe
`
"x"
it
"two-element list"
$
nonempty
Join
","
[
"x"
,
"y"
]
`
shouldBe
`
"x,y"
it
"with empty strings"
$
nonempty
Join
","
[
"a"
,
""
,
"b"
,
""
,
"c"
,
""
]
`
shouldBe
`
"a,b,c"
describe
"check nonempty
Intercalate
"
$
do
it
"empty list"
$
nonempty
Intercalate
","
[]
`
shouldBe
`
""
it
"simple list"
$
nonempty
Intercalate
","
[
"x"
]
`
shouldBe
`
"x"
it
"two-element list"
$
nonempty
Intercalate
","
[
"x"
,
"y"
]
`
shouldBe
`
"x,y"
it
"with empty strings"
$
nonempty
Intercalate
","
[
"a"
,
""
,
"b"
,
""
,
"c"
,
""
]
`
shouldBe
`
"a,b,c"
where
testArray
::
[
Int
]
testArray
=
[
1
,
2
,
3
,
1
,
2
,
3
]
...
...
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