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
159
Issues
159
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
97b483d7
Commit
97b483d7
authored
May 26, 2025
by
Alfredo Di Napoli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add docNgrams test
parent
45371e41
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
0 deletions
+44
-0
gargantext.cabal
gargantext.cabal
+1
-0
Context.hs
src/Gargantext/Database/Schema/Context.hs
+3
-0
Ngrams.hs
test/Test/Offline/Ngrams.hs
+38
-0
Main.hs
test/drivers/tasty/Main.hs
+2
-0
No files found.
gargantext.cabal
View file @
97b483d7
...
...
@@ -861,6 +861,7 @@ test-suite garg-test-tasty
Test.Ngrams.Terms
Test.Offline.Errors
Test.Offline.JSON
Test.Offline.Ngrams
Test.Offline.Phylo
Test.Offline.Stemming.Lancaster
Test.Parsers.Date
...
...
src/Gargantext/Database/Schema/Context.hs
View file @
97b483d7
...
...
@@ -61,6 +61,9 @@ data ContextPolyOnlyId id hyperdata =
,
_context_oid_hyperdata
::
!
hyperdata
}
deriving
(
Show
,
Generic
)
instance
(
Arbitrary
id
,
Arbitrary
hyperdata
)
=>
Arbitrary
(
ContextPolyOnlyId
id
hyperdata
)
where
arbitrary
=
ContextOnlyId
<$>
arbitrary
<*>
arbitrary
------------------------------------------------------------------------
-- Automatic instances derivation
$
(
deriveJSON
(
unPrefix
"_context_oid_"
)
''
C
ontextPolyOnlyId
)
...
...
test/Test/Offline/Ngrams.hs
0 → 100644
View file @
97b483d7
module
Test.Offline.Ngrams
(
tests
)
where
import
Prelude
import
Data.Text
qualified
as
T
import
Gargantext.API.Ngrams.Types
qualified
as
NT
import
Gargantext.Core
import
Gargantext.Core.Types
import
Gargantext.Database.Action.Flow.Utils
(
docNgrams
)
import
Gargantext.Database.Admin.Types.Hyperdata
import
Test.Instances
()
import
Test.QuickCheck
import
Test.Tasty
import
Test.Tasty.QuickCheck
(
testProperty
)
-- 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
-- /might/ occasionally generate empty text fragments.
newtype
NgramsTermNonEmpty
=
NgramsTermNonEmpty
{
unNgramsTermNonEmpty
::
T
.
Text
}
deriving
(
Eq
,
Show
)
instance
Arbitrary
NgramsTermNonEmpty
where
arbitrary
=
do
singleChar
<-
arbitrary
`
suchThat
`
((
/=
)
' '
)
txt
<-
arbitrary
pure
$
NgramsTermNonEmpty
$
(
T
.
singleton
singleChar
<>
txt
)
tests
::
TestTree
tests
=
testGroup
"Ngrams"
[
testGroup
"docNgrams"
[
testProperty
"return results for non-empty input ngrams"
testDocNgramsWithTerms
]
]
testDocNgramsWithTerms
::
Lang
->
NonEmptyList
NgramsTermNonEmpty
->
ContextOnlyId
HyperdataDocument
->
Property
testDocNgramsWithTerms
lang
ts
doc
=
let
ts'
=
map
(
NT
.
NgramsTerm
.
unNgramsTermNonEmpty
)
$
getNonEmpty
ts
in
counterexample
"docNgrams returned no results"
$
length
(
docNgrams
lang
ts'
doc
)
>
0
test/drivers/tasty/Main.hs
View file @
97b483d7
...
...
@@ -27,6 +27,7 @@ import qualified Test.Ngrams.Query as NgramsQuery
import
qualified
Test.Ngrams.Terms
as
NgramsTerms
import
qualified
Test.Offline.Errors
as
Errors
import
qualified
Test.Offline.JSON
as
JSON
import
qualified
Test.Offline.Ngrams
as
Ngrams
import
qualified
Test.Offline.Phylo
as
Phylo
import
qualified
Test.Offline.Stemming.Lancaster
as
Lancaster
import
qualified
Test.Parsers.Date
as
PD
...
...
@@ -70,6 +71,7 @@ main = do
,
CorpusQuery
.
tests
,
TSVParser
.
tests
,
JSON
.
tests
,
Ngrams
.
tests
,
Errors
.
tests
,
similaritySpec
,
Phylo
.
tests
...
...
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