mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-23 09:52:55 -06:00
Improve base case in table handling, cleanup. Add run-phrasebook script, current output:
Bul ✗ Cat ✗ Chi ✓ Dan ✓ Dut ✓ Eng ✓ Est ✓ Fin ✗ Fre ✗ Ger ✓ Hin ✓ Ita ✗ Jpn ✓ Lav ✓ Nor ✓ Pol ✓ Ron ✓ Snd ✗ Spa ✗ Swe ✓ Tha ✓ Urd ✓ Passed 15 | Failed 7 | Total 22
This commit is contained in:
@@ -174,11 +174,15 @@ mkCanon2lpgf opts gr am = do
|
|||||||
-- remove one level of depth and recurse
|
-- remove one level of depth and recurse
|
||||||
let
|
let
|
||||||
handleGroup :: [C.TableRowValue] -> Either String (L.LinFun, Maybe C.LinType)
|
handleGroup :: [C.TableRowValue] -> Either String (L.LinFun, Maybe C.LinType)
|
||||||
handleGroup [C.TableRow _ lv] = val2lin lv -- TODO suspect
|
handleGroup [C.TableRow patt lv] =
|
||||||
|
case reducePattern patt of
|
||||||
|
Just patt' -> do
|
||||||
|
(lf,lt) <- handleGroup [C.TableRow patt' lv]
|
||||||
|
return (L.Tuple [lf],lt)
|
||||||
|
Nothing -> val2lin lv
|
||||||
handleGroup rows = do
|
handleGroup rows = do
|
||||||
let reductions = map reduceRow rows
|
let rows' = map reduceRow rows
|
||||||
let rows' = map fromJust reductions
|
val2lin (C.TableValue lt rows') -- lt is wrong here, but is unused
|
||||||
val2lin (C.TableValue lt rows') -- TODO lt is wrong here
|
|
||||||
|
|
||||||
reducePattern :: C.LinPattern -> Maybe C.LinPattern
|
reducePattern :: C.LinPattern -> Maybe C.LinPattern
|
||||||
reducePattern patt =
|
reducePattern patt =
|
||||||
@@ -198,11 +202,10 @@ mkCanon2lpgf opts gr am = do
|
|||||||
|
|
||||||
_ -> error $ printf "Unhandled pattern in reducing: %s" (show patt)
|
_ -> error $ printf "Unhandled pattern in reducing: %s" (show patt)
|
||||||
|
|
||||||
reduceRow :: C.TableRowValue -> Maybe C.TableRowValue
|
reduceRow :: C.TableRowValue -> C.TableRowValue
|
||||||
reduceRow row@(C.TableRow patt lv) =
|
reduceRow (C.TableRow patt lv) =
|
||||||
case reducePattern patt of
|
let Just patt' = reducePattern patt
|
||||||
Just patt' -> Just $ C.TableRow patt' lv
|
in C.TableRow patt' lv
|
||||||
Nothing -> Nothing
|
|
||||||
|
|
||||||
-- ts :: [(L.LinFun, Maybe C.LinType)]
|
-- ts :: [(L.LinFun, Maybe C.LinType)]
|
||||||
ts <- mapM handleGroup grps
|
ts <- mapM handleGroup grps
|
||||||
|
|||||||
27
testsuite/lpgf/run-phrasebook.sh
Executable file
27
testsuite/lpgf/run-phrasebook.sh
Executable file
@@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Run testsuite on all Phrasebook languages individually and show report
|
||||||
|
|
||||||
|
PREFIX="$(dirname $0)/phrasebook/Phrasebook"
|
||||||
|
LANGS="Bul Cat Chi Dan Dut Eng Est Fin Fre Ger Hin Ita Jpn Lav Nor Pol Ron Snd Spa Swe Tha Urd"
|
||||||
|
|
||||||
|
stack build --test --bench --no-run-tests --no-run-benchmarks
|
||||||
|
|
||||||
|
PASS=0
|
||||||
|
FAIL=0
|
||||||
|
TOTAL=0
|
||||||
|
for LANG in $LANGS; do
|
||||||
|
printf "$LANG "
|
||||||
|
stack test gf:test:lpgf --test-arguments="${PREFIX} ${LANG}" > /dev/null 2>&1
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
printf "\033[0;32m✓\033[0m\n"
|
||||||
|
((PASS=PASS+1))
|
||||||
|
else
|
||||||
|
printf "\033[0;31m✗\033[0m\n"
|
||||||
|
((FAIL=FAIL+1))
|
||||||
|
fi
|
||||||
|
((TOTAL=TOTAL+1))
|
||||||
|
done
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Passed ${PASS} | Failed ${FAIL} | Total ${TOTAL}"
|
||||||
Reference in New Issue
Block a user