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
163
Issues
163
List
Board
Labels
Milestones
Merge Requests
9
Merge Requests
9
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
f54f2036
Verified
Commit
f54f2036
authored
Jun 06, 2025
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[terms] added test for multi terms docNgrams functionality
parent
b7d03cf6
Pipeline
#7648
failed with stages
in 53 minutes and 38 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
7 deletions
+21
-7
README.md
README.md
+7
-0
Terms.hs
test/Test/Ngrams/Terms.hs
+14
-7
No files found.
README.md
View file @
f54f2036
...
@@ -437,6 +437,13 @@ experience strange errors like
...
@@ -437,6 +437,13 @@ experience strange errors like
fatal: Could not parse object '316d48b6a89593faaf1f2102e9714cea7e416e56'.
fatal: Could not parse object '316d48b6a89593faaf1f2102e9714cea7e416e56'.
```
```
If you're using emacs, you could fire up an interactive REPL directly
via e.g. `haskell-interactive-bring`.
In repl, the `.ghci` file from our repo would be loaded which contains
a useful `:ggload` macro that imports all exposed modules from the
`gargantext` library.
## Running the tests <a name="running-tests"></a>
## Running the tests <a name="running-tests"></a>
Running the tests can be done via the following command:
Running the tests can be done via the following command:
...
...
test/Test/Ngrams/Terms.hs
View file @
f54f2036
...
@@ -4,7 +4,7 @@ module Test.Ngrams.Terms (tests) where
...
@@ -4,7 +4,7 @@ module Test.Ngrams.Terms (tests) where
import
Data.HashMap.Strict
qualified
as
HashMap
import
Data.HashMap.Strict
qualified
as
HashMap
import
Data.Map.Strict
qualified
as
Map
import
Data.Map.Strict
qualified
as
Map
import
Gargantext.API.Ngrams
import
Gargantext.API.Ngrams
.Types
(
NgramsTerm
)
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Core.Text.Context
(
TermList
)
import
Gargantext.Core.Text.Context
(
TermList
)
import
Gargantext.Core.Text.Ngrams
(
NgramsType
(
NgramsTerms
),
Ngrams
(
..
))
import
Gargantext.Core.Text.Ngrams
(
NgramsType
(
NgramsTerms
),
Ngrams
(
..
))
...
@@ -15,8 +15,8 @@ import Gargantext.Database.Admin.Types.Hyperdata.Document ( HyperdataDocument(..
...
@@ -15,8 +15,8 @@ import Gargantext.Database.Admin.Types.Hyperdata.Document ( HyperdataDocument(..
import
Gargantext.Database.Admin.Types.Node
(
NodeId
(
..
))
import
Gargantext.Database.Admin.Types.Node
(
NodeId
(
..
))
import
Gargantext.Database.Schema.Context
(
ContextPolyOnlyId
(
..
)
)
import
Gargantext.Database.Schema.Context
(
ContextPolyOnlyId
(
..
)
)
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Test.Tasty
import
Test.Tasty
(
TestTree
,
testGroup
)
import
Test.Tasty.HUnit
import
Test.Tasty.HUnit
(
Assertion
,
testCase
,
(
@?=
)
)
tests
::
TestTree
tests
::
TestTree
...
@@ -34,6 +34,7 @@ unitTests = testGroup "Terms tests"
...
@@ -34,6 +34,7 @@ unitTests = testGroup "Terms tests"
,
testCase
"termsInText works 04 (related to issue #221)"
testTermsInText04
,
testCase
"termsInText works 04 (related to issue #221)"
testTermsInText04
,
testCase
"extractTermsWithList' works 01"
testExtractTermsWithList'01
,
testCase
"extractTermsWithList' works 01"
testExtractTermsWithList'01
,
testCase
"extractTermsWithList' works 02 (#471)"
testExtractTermsWithList'02
,
testCase
"docNgrams works 01"
testDocNgrams01
,
testCase
"docNgrams works 01"
testDocNgrams01
,
testCase
"docNgrams works 02"
testDocNgrams02
,
testCase
"docNgrams works 02"
testDocNgrams02
...
@@ -112,12 +113,18 @@ testExtractTermsWithList'01 = do
...
@@ -112,12 +113,18 @@ testExtractTermsWithList'01 = do
let
termList
=
[([
"chat blanc"
],
[[
"chat"
,
"blanc"
]])]
::
TermList
let
termList
=
[([
"chat blanc"
],
[[
"chat"
,
"blanc"
]])]
::
TermList
extractTermsWithList'
(
buildPatterns
termList
)
"Le chat blanc"
@?=
[
"chat blanc"
]
extractTermsWithList'
(
buildPatterns
termList
)
"Le chat blanc"
@?=
[
"chat blanc"
]
-- #471
testExtractTermsWithList'02
::
Assertion
testExtractTermsWithList'02
=
do
let
termList
=
[([
"patients"
],
[]
),
([
"patients"
,
"with"
],
[]
)]
::
TermList
extractTermsWithList'
(
buildPatterns
termList
)
"patients with problems"
@?=
[
"patients"
,
"patientswith"
]
testDocNgrams01
::
Assertion
testDocNgrams01
::
Assertion
testDocNgrams01
=
do
testDocNgrams01
=
do
let
terms
=
[
"hello"
,
"world"
]
::
[
NgramsTerm
]
let
terms
=
[
"hello"
,
"world"
]
::
[
NgramsTerm
]
let
hd
=
emptyHyperdataDocument
{
_hd_title
=
Just
"hello world"
let
hd
=
emptyHyperdataDocument
{
_hd_title
=
Just
"hello world"
,
_hd_abstract
=
Nothing
}
,
_hd_abstract
=
Nothing
}
let
ctx
=
ContextOnlyId
1
hd
let
ctx
=
ContextOnlyId
{
_context_oid_id
=
1
,
_context_oid_hyperdata
=
hd
}
let
dNgrams
=
docNgrams
EN
terms
ctx
let
dNgrams
=
docNgrams
EN
terms
ctx
length
dNgrams
@?=
2
length
dNgrams
@?=
2
...
@@ -126,7 +133,7 @@ testDocNgrams02 = do
...
@@ -126,7 +133,7 @@ testDocNgrams02 = do
let
terms
=
[
"hello"
,
"world"
]
::
[
NgramsTerm
]
let
terms
=
[
"hello"
,
"world"
]
::
[
NgramsTerm
]
let
hd
=
emptyHyperdataDocument
{
_hd_title
=
Just
"hello world, kaboom"
let
hd
=
emptyHyperdataDocument
{
_hd_title
=
Just
"hello world, kaboom"
,
_hd_abstract
=
Nothing
}
,
_hd_abstract
=
Nothing
}
let
ctx
=
ContextOnlyId
1
hd
let
ctx
=
ContextOnlyId
{
_context_oid_id
=
1
,
_context_oid_hyperdata
=
hd
}
let
dNgrams
=
docNgrams
EN
terms
ctx
let
dNgrams
=
docNgrams
EN
terms
ctx
length
dNgrams
@?=
2
length
dNgrams
@?=
2
...
@@ -135,10 +142,10 @@ testNgramsByDoc01 = do
...
@@ -135,10 +142,10 @@ testNgramsByDoc01 = do
let
terms
=
[
"hello"
,
"world"
]
::
[
NgramsTerm
]
let
terms
=
[
"hello"
,
"world"
]
::
[
NgramsTerm
]
let
hd1
=
emptyHyperdataDocument
{
_hd_title
=
Just
"hello world, kaboom"
let
hd1
=
emptyHyperdataDocument
{
_hd_title
=
Just
"hello world, kaboom"
,
_hd_abstract
=
Nothing
}
,
_hd_abstract
=
Nothing
}
let
ctx1
=
ContextOnlyId
1
hd1
let
ctx1
=
ContextOnlyId
{
_context_oid_id
=
1
,
_context_oid_hyperdata
=
hd1
}
let
hd2
=
emptyHyperdataDocument
{
_hd_title
=
Just
"world, boom world"
let
hd2
=
emptyHyperdataDocument
{
_hd_title
=
Just
"world, boom world"
,
_hd_abstract
=
Nothing
}
,
_hd_abstract
=
Nothing
}
let
ctx2
=
ContextOnlyId
2
hd2
let
ctx2
=
ContextOnlyId
{
_context_oid_id
=
2
,
_context_oid_hyperdata
=
hd2
}
ngramsByDoc
EN
NgramsTerms
terms
ctx1
@?=
ngramsByDoc
EN
NgramsTerms
terms
ctx1
@?=
HashMap
.
fromList
HashMap
.
fromList
...
...
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