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
186214c6
Commit
186214c6
authored
Jul 28, 2025
by
Alfredo Di Napoli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code review polishing tweaks
Generalise fully 'GeneralisedNgramsTree' and add more commentary.
parent
d0ecd7cf
Pipeline
#7784
passed with stages
in 94 minutes
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
1 deletion
+8
-1
NgramsTree.hs
src/Gargantext/API/Ngrams/NgramsTree.hs
+8
-1
No files found.
src/Gargantext/API/Ngrams/NgramsTree.hs
View file @
186214c6
...
@@ -45,6 +45,9 @@ import Test.QuickCheck ( Arbitrary(arbitrary) )
...
@@ -45,6 +45,9 @@ import Test.QuickCheck ( Arbitrary(arbitrary) )
-- * Aciclic: each tree is a DAG, and therefore there must be no cycles within the tree,
-- * Aciclic: each tree is a DAG, and therefore there must be no cycles within the tree,
-- and no cycles between trees in the forest.
-- and no cycles between trees in the forest.
--
--
-- /NOTE/: An 'NgramsForest' and a 'GeneralisedNgramsTree' are essentially isomorphic to the \"Tree\"
-- and \"Forest\" types from the \"containers\" library, but our version allows storing both a label and
-- a value for each node.
newtype
NgramsForest
=
newtype
NgramsForest
=
NgramsForest
{
getNgramsForest
::
[
NgramsTree
]
}
NgramsForest
{
getNgramsForest
::
[
NgramsTree
]
}
deriving
(
Show
,
Eq
,
Ord
)
deriving
(
Show
,
Eq
,
Ord
)
...
@@ -55,7 +58,7 @@ type NgramsTree = GeneralisedNgramsTree Text Int
...
@@ -55,7 +58,7 @@ type NgramsTree = GeneralisedNgramsTree Text Int
data
GeneralisedNgramsTree
l
m
=
data
GeneralisedNgramsTree
l
m
=
GeneralisedNgramsTree
{
mt_label
::
l
GeneralisedNgramsTree
{
mt_label
::
l
,
mt_value
::
m
,
mt_value
::
m
,
mt_children
::
[
NgramsTree
]
,
mt_children
::
[
GeneralisedNgramsTree
l
m
]
}
}
deriving
(
Generic
,
Show
,
Eq
,
Ord
)
deriving
(
Generic
,
Show
,
Eq
,
Ord
)
...
@@ -83,9 +86,13 @@ instance Arbitrary NgramsTree
...
@@ -83,9 +86,13 @@ instance Arbitrary NgramsTree
-- Constructing trees and forests
-- Constructing trees and forests
--
--
-- | Given a 'Tree' from the \"containers\" library that has an 'NgramsTerm' and a score at the leaves,
-- converts it into a gargantext 'NgramsTree' tree.
toNgramsTree
::
Tree
(
NgramsTerm
,
Int
)
->
NgramsTree
toNgramsTree
::
Tree
(
NgramsTerm
,
Int
)
->
NgramsTree
toNgramsTree
(
Node
(
NgramsTerm
l
,
v
)
xs
)
=
GeneralisedNgramsTree
l
v
(
map
toNgramsTree
xs
)
toNgramsTree
(
Node
(
NgramsTerm
l
,
v
)
xs
)
=
GeneralisedNgramsTree
l
v
(
map
toNgramsTree
xs
)
-- | Given a 'ListType', which informs which category of terms we want to focus on (stop, map, candidate)
-- and two hashmaps mapping an 'NgramsTerm' to their values, builds an 'NgramsForest'.
toNgramsForest
::
ListType
toNgramsForest
::
ListType
->
HashMap
NgramsTerm
(
Set
NodeId
)
->
HashMap
NgramsTerm
(
Set
NodeId
)
->
HashMap
NgramsTerm
NgramsRepoElement
->
HashMap
NgramsTerm
NgramsRepoElement
...
...
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