Skip to content

Commit

Permalink
Partial work for AaJson
Browse files Browse the repository at this point in the history
  • Loading branch information
kharus committed Oct 3, 2024
1 parent ce30384 commit 38cc083
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 312 deletions.
3 changes: 1 addition & 2 deletions lib/haskell/natural4/src/LS/XPile/AaJson.hs
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,7 @@ translate2AaJson nlgEnvs eng l4i = do
case hornByLang of
Left err -> xpError err
Right hornByLang -> xpReturn [__i|
#{nlgEnvStrLower} :: Object.Object (Item String)
#{nlgEnvStrLower} = Object.fromFoldable
{
#{pShowNoColor $ DL.nub hornByLang}
|]
-- mutterdhsf 2 "qaHornsAllLangs" pShowNoColorS qaHornsRights
Expand Down
16 changes: 7 additions & 9 deletions lib/haskell/natural4/test/LS/XPile/AaJsonSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ loadNLGEnv tracer engE =
transpileFile :: String -> IO TL.Text
transpileFile filename = do
let tracer =
-- Use the 'prettyTracer' if you need logs for debugging
-- prettyTracer
mempty
let testPath = "test" </> "testdata" </> "golden" </> "AaJsonSpec" </> filename <.> "csv"
opts = SFL4.defaultOptions {SFL4.file = [testPath]}
Expand All @@ -79,7 +77,7 @@ transpileFile filename = do
nlgEnvs = justNLGDate.allEnv
eng = justNLGDate.env
(psResult, _) = xpLog do
fmapE (<> ("\n\n" <> "allLang = [\"" <> strLangs <> "\"]")) (translate2AaJson nlgEnvs eng l4i)
fmapE (<> ("\n\n" <> "allLang = [\"" <> strLangs <> "\"]")) (translate2AaJson [eng] eng l4i)

case psResult of
Left err -> do
Expand All @@ -96,8 +94,8 @@ goldenGeneric name myoutput =
encodePretty = TL.unpack,
writeToFile = TL.writeFile,
readFromFile = TL.readFile,
goldenFile = testPath <.> "purs.expected",
actualFile = Just (testPath <.> "purs.actual"),
goldenFile = testPath <.> "json.expected",
actualFile = Just (testPath <.> "json.actual"),
failFirstTime = False
}
where
Expand All @@ -112,7 +110,7 @@ spec = do
must_sing_purs <- transpileFile "must_sing"
pure $ goldenGeneric "must_sing" must_sing_purs

describe "rodents" do
it "convert must sing to AaJson" do
rodents_purs <- transpileFile "rodents"
pure $ goldenGeneric "rodents" rodents_purs
-- describe "rodents" do
-- it "convert must sing to AaJson" do
-- rodents_purs <- transpileFile "rodents"
-- pure $ goldenGeneric "rodents" rodents_purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@


{
"Person": {
"All": {
"label": {
"Pre": "all of:"
},
"children": [
{
"Leaf": "does the person walk?"
},
{
"Any": {
"label": {
"Pre": "any of:"
},
"children": [
{
"Leaf": "does the person eat?"
},
{
"Leaf": "does the person drink?"
}
]
}
}
]
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@


nl4eng :: Object.Object (Item String)
nl4eng = Object.fromFoldable
[ Tuple "Covered If …"
( Not
( All
( Pre "all of:" )
[ Any
( Pre "Is the Loss or Damage caused by" )
[ Leaf "rodents?"
, Leaf "insects?"
, Leaf "vermin?"
, Leaf "birds?"
]
, Not
( Any
( Pre "any of:" )
[ All
( Pre "all of:" )
[ Leaf "is Loss or Damage to contents?"
, Leaf "is Loss or Damage caused by birds?"
]
, All
( Pre "all of:" )
[ Leaf "is Loss or Damage ensuing covered loss?"
, Not
( Any
( Pre "any of:" )
[ Leaf "does any other exclusion apply?"
, Any
( Pre "did an animal cause water to escape from" )
[ Leaf "a household appliance?"
, Leaf "a swimming pool?"
, Leaf "a plumbing, heating, or air conditioning system?"
]
]
)
]
]
)
]
)
)
, Tuple "Not Covered If …"
( All
( Pre "all of:" )
[ Any
( Pre "Is the Loss or Damage caused by" )
[ Leaf "rodents?"
, Leaf "insects?"
, Leaf "vermin?"
, Leaf "birds?"
]
, Not
( Any
( Pre "any of:" )
[ All
( Pre "all of:" )
[ Leaf "is Loss or Damage to contents?"
, Leaf "is Loss or Damage caused by birds?"
]
, All
( Pre "all of:" )
[ Leaf "is Loss or Damage ensuing covered loss?"
, Not
( Any
( Pre "any of:" )
[ Leaf "does any other exclusion apply?"
, Any
( Pre "did an animal cause water to escape from" )
[ Leaf "a household appliance?"
, Leaf "a swimming pool?"
, Leaf "a plumbing, heating, or air conditioning system?"
]
]
)
]
]
)
]
)
]



allLang = ["nl4chi", "nl4eng", "nl4may"]
Loading

0 comments on commit 38cc083

Please sign in to comment.