Commit 66198af7 authored by Alfredo Di Napoli's avatar Alfredo Di Napoli

Add test for complex ngrams forest hierarchy

parent 1964cc3c
......@@ -104,6 +104,7 @@ tests = describe "Ngrams" $ do
describe "ngram forests" $ do
it "building a simple tree works" testBuildNgramsTree_01
it "building a complex tree works" testBuildNgramsTree_02
it "building a complex deep tree works" testBuildNgramsTree_03
it "pruning a simple tree works" testPruningNgramsForest_01
it "pruning a complex tree works" testPruningNgramsForest_02
prop "destroyForest . buildForest === id" buildDestroyForestRoundtrips
......@@ -194,6 +195,80 @@ testBuildNgramsTree_02 =
`- ford
|]
testBuildNgramsTree_03 :: Property
testBuildNgramsTree_03 =
let input = Map.fromList [
("animalia", mkMapTerm "animalia" & ne_children .~ mSetFromList ["chordata"])
, ("chordata", mkMapTerm "chordata" & ne_root .~ Just "animalia"
& ne_parent .~ Just "animalia"
& ne_children .~ mSetFromList ["mammalia"])
, ("mammalia", mkMapTerm "mammalia" & ne_root .~ Just "animalia"
& ne_parent .~ Just "chordata"
& ne_children .~ mSetFromList ["carnivora", "primates"]
)
, ("carnivora", mkMapTerm "carnivora" & ne_root .~ Just "animalia"
& ne_parent .~ Just "mammalia"
& ne_children .~ mSetFromList ["felidae"]
)
, ("felidae", mkMapTerm "felidae" & ne_root .~ Just "animalia"
& ne_parent .~ Just "carnivora"
& ne_children .~ mSetFromList ["panthera"]
)
, ("panthera", mkMapTerm "panthera" & ne_root .~ Just "animalia"
& ne_parent .~ Just "felidae"
& ne_children .~ mSetFromList ["panthera leo", "panthera tigris"]
)
, ("panthera leo", mkMapTerm "panthera leo" & ne_root .~ Just "animalia"
& ne_parent .~ Just "pathera"
)
, ("panthera tigris", mkMapTerm "panthera tigris" & ne_root .~ Just "animalia"
& ne_parent .~ Just "panthera"
)
, ("panthera tigris", mkMapTerm "panthera tigris" & ne_root .~ Just "animalia"
& ne_parent .~ Just "panthera"
)
, ("primates", mkMapTerm "primates" & ne_root .~ Just "animalia"
& ne_parent .~ Just "mammalia"
& ne_children .~ mSetFromList ["hominidae"]
)
, ("hominidae", mkMapTerm "hominidae" & ne_root .~ Just "animalia"
& ne_parent .~ Just "primates"
& ne_children .~ mSetFromList ["homo"]
)
, ("homo", mkMapTerm "homo" & ne_root .~ Just "animalia"
& ne_parent .~ Just "hominidae"
& ne_children .~ mSetFromList ["homo sapiens"]
)
, ("homo sapies", mkMapTerm "homo sapiens" & ne_root .~ Just "animalia"
& ne_parent .~ Just "homo"
)
]
in pruneForest (buildForest input) `compareForestVisually` [r|
animalia
|
`- chordata
|
`- mammalia
|
+- carnivora
| |
| `- felidae
| |
| `- panthera
| |
| +- panthera leo
| |
| `- panthera tigris
|
`- primates
|
`- hominidae
|
`- homo
|]
newtype TableMapLockStep = TableMapLockStep { getTableMap :: Map NgramsTerm NgramsElement }
deriving (Show, Eq)
......@@ -227,3 +302,4 @@ testPruningNgramsForest_02 =
|
`- ford
|]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment