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
191
Issues
191
List
Board
Labels
Milestones
Merge Requests
8
Merge Requests
8
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
5ca033e9
Verified
Commit
5ca033e9
authored
Jul 25, 2025
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[test] fix ngrams test by having a better non-empty terms generator
Ref
#488
parent
9be580a4
Pipeline
#7791
passed with stages
in 46 minutes and 4 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
Ngrams.hs
test/Test/Offline/Ngrams.hs
+8
-6
No files found.
test/Test/Offline/Ngrams.hs
View file @
5ca033e9
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE ViewPatterns #-}
module
Test.Offline.Ngrams
(
tests
)
where
import
Prelude
import
Control.Lens
import
Data.Char
(
isSpace
)
import
Data.Char
qualified
as
Char
import
Data.Map.Strict
(
Map
)
import
Data.Map.Strict
qualified
as
Map
import
Data.Text
qualified
as
T
import
Data.Tree
import
Gargantext.API.Ngrams
(
filterNgramsNodes
,
buildForest
,
destroyForest
,
pruneForest
)
import
Gargantext.API.Ngrams.Types
import
Gargantext.API.Ngrams.Types
qualified
as
NT
...
...
@@ -20,15 +25,12 @@ import Gargantext.Database.Admin.Types.Hyperdata
import
Gargantext.Database.Schema.Context
import
Test.HUnit
import
Test.Hspec
import
Test.Hspec.QuickCheck
(
prop
)
import
Test.Instances
()
import
Test.Ngrams.Query
(
mkMapTerm
)
import
Test.QuickCheck
import
Test.QuickCheck
qualified
as
QC
import
Data.Tree
import
Text.RawString.QQ
(
r
)
import
Data.Char
(
isSpace
)
import
Data.Map.Strict
(
Map
)
import
Test.Hspec.QuickCheck
(
prop
)
genScientificText
::
Gen
T
.
Text
...
...
@@ -54,12 +56,12 @@ punctuation = ",.();:-"
genNgramsTermNonEmpty
::
Gen
NgramsTermNonEmpty
genNgramsTermNonEmpty
=
do
singleChar
<-
arbitrary
`
suchThat
`
(
\
x
->
x
/=
' '
&&
isAllowed
x
)
singleChar
<-
arbitrary
`
suchThat
`
isAllowed
txt
<-
filter
isAllowed
<$>
listOf1
genScientificChar
pure
$
NgramsTermNonEmpty
$
(
T
.
pack
$
singleChar
:
txt
)
where
isAllowed
::
Char
->
Bool
isAllowed
s
=
not
(
s
`
elem
`
punctuation
)
&&
not
(
s
`
elem
`
ws
)
&&
not
(
isSep
s
)
isAllowed
s
=
not
(
Char
.
isSpace
s
)
&&
not
(
s
`
elem
`
punctuation
)
&&
not
(
s
`
elem
`
ws
)
&&
not
(
isSep
s
)
-- In order to test the behaviour of 'docNgrams' we create wrappers around 'NgramsTerm' to have two
-- different 'Arbitrary' flavours, one that always produces non-empty 'Text' fragments, and one that
...
...
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