From 751a841191543bf9e67ebe905fb70863da301a66 Mon Sep 17 00:00:00 2001 From: aarne Date: Sun, 8 Jul 2007 12:43:07 +0000 Subject: [PATCH] peb's forest patch --- doc/tutorial/Makefile | 6 +++--- lib/resource-1.0/german/NounGer.gf | 2 +- src/GF/Formalism/Utilities.hs | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/doc/tutorial/Makefile b/doc/tutorial/Makefile index 1902994ea..ee040382a 100644 --- a/doc/tutorial/Makefile +++ b/doc/tutorial/Makefile @@ -1,6 +1,6 @@ html: txt2tags -thtml --toc gf-tutorial2_8.txt tex: - txt2tags -ttex --toc gf-tutorial2.txt - pdflatex gf-tutorial2.tex - pdflatex gf-tutorial2.tex + txt2tags -ttex --toc gf-tutorial2_8.txt + pdflatex gf-tutorial2_8.tex + pdflatex gf-tutorial2_8.tex diff --git a/lib/resource-1.0/german/NounGer.gf b/lib/resource-1.0/german/NounGer.gf index fb03e72b2..46bb68a5e 100644 --- a/lib/resource-1.0/german/NounGer.gf +++ b/lib/resource-1.0/german/NounGer.gf @@ -72,7 +72,7 @@ concrete NounGer of Noun = CatGer ** open ResGer, Prelude in { NumInt n = {s = n.s; n = table (Predef.Ints 1 * Predef.Ints 9) { <0,1> => Sg ; _ => Pl - } ! + } ! <1,2> ---- parser bug (AR 2/6/2007) } ; OrdInt n = {s = \\_ => n.s ++ "."} ; diff --git a/src/GF/Formalism/Utilities.hs b/src/GF/Formalism/Utilities.hs index 0d303b175..633064692 100644 --- a/src/GF/Formalism/Utilities.hs +++ b/src/GF/Formalism/Utilities.hs @@ -258,6 +258,21 @@ chart2forests :: (Ord n, Ord e) => -- In essence, the result is a map from 'n' to forest daughters -- simplest implementation + +chart2forests chart isMeta = concatMap (edge2forests []) + where edge2forests edges edge + | isMeta edge = [FMeta] + | edge `elem` edges = [] + | otherwise = map (item2forest (edge:edges)) $ chart ? edge + item2forest edges (SMeta) = FMeta + item2forest edges (SNode name children) = + FNode name $ children >>= mapM (edge2forests edges) + item2forest edges (SString s) = FString s + item2forest edges (SInt n) = FInt n + item2forest edges (SFloat f) = FFloat f + +{- -before AR inserted peb's patch 8/7/2007, this was: + chart2forests chart isMeta = concatMap edge2forests where edge2forests edge = if isMeta edge then [FMeta] else map item2forest $ chart ? edge @@ -267,6 +282,7 @@ chart2forests chart isMeta = concatMap edge2forests item2forest (SInt n) = FInt n item2forest (SFloat f) = FFloat f +-} {- -- more intelligent(?) implementation,