forked from GitHub/gf-core
gr for several metas fixed ; commented out one alternative in SammieGer to make it compile
This commit is contained in:
@@ -108,7 +108,7 @@ oper
|
|||||||
|
|
||||||
all_art = a_Art | the_Art ;
|
all_art = a_Art | the_Art ;
|
||||||
|
|
||||||
artist_Prep = by8agent_Prep | with_Prep ;
|
artist_Prep = by8agent_Prep ; ---- | with_Prep ;
|
||||||
|
|
||||||
this cn =
|
this cn =
|
||||||
mkNP this_Quant cn
|
mkNP this_Quant cn
|
||||||
|
|||||||
@@ -199,6 +199,7 @@ lin
|
|||||||
albums_all = mkSet album ;
|
albums_all = mkSet album ;
|
||||||
albums_by_artist artist =
|
albums_by_artist artist =
|
||||||
mkSet (mkCN album (mkAdv artist_Prep artist)) ;
|
mkSet (mkCN album (mkAdv artist_Prep artist)) ;
|
||||||
|
|
||||||
albums_by_genre = withGenre album ;
|
albums_by_genre = withGenre album ;
|
||||||
|
|
||||||
albums_by_artist_genre = withGenreBy album ;
|
albums_by_artist_genre = withGenreBy album ;
|
||||||
@@ -227,6 +228,7 @@ lin
|
|||||||
|
|
||||||
songs_all =
|
songs_all =
|
||||||
mkSet song ;
|
mkSet song ;
|
||||||
|
|
||||||
songs_by_artist artist =
|
songs_by_artist artist =
|
||||||
mkSet (mkCN song (mkAdv artist_Prep artist)) ;
|
mkSet (mkCN song (mkAdv artist_Prep artist)) ;
|
||||||
songs_by_genre =
|
songs_by_genre =
|
||||||
|
|||||||
@@ -11,27 +11,29 @@ import System.Random
|
|||||||
|
|
||||||
-- generate all fillings of metavariables in an expr
|
-- generate all fillings of metavariables in an expr
|
||||||
generateAllFrom :: Maybe Expr -> PGF -> Type -> Maybe Int -> [Expr]
|
generateAllFrom :: Maybe Expr -> PGF -> Type -> Maybe Int -> [Expr]
|
||||||
generateAllFrom mex pgf ty mi = maybe (gen ty) (generateForMetas pgf gen) mex where
|
generateAllFrom mex pgf ty mi =
|
||||||
gen ty = generate pgf ty mi
|
maybe (gen ty) (generateForMetas False pgf gen) mex where
|
||||||
|
gen ty = generate pgf ty mi
|
||||||
|
|
||||||
-- generate random fillings of metavariables in an expr
|
-- generate random fillings of metavariables in an expr
|
||||||
generateRandomFrom :: Maybe Expr ->
|
generateRandomFrom :: Maybe Expr ->
|
||||||
Maybe Probabilities -> StdGen -> PGF -> Type -> [Expr]
|
Maybe Probabilities -> StdGen -> PGF -> Type -> [Expr]
|
||||||
generateRandomFrom mex ps rg pgf ty =
|
generateRandomFrom mex ps rg pgf ty =
|
||||||
maybe (gen ty) (generateForMetas pgf gen) mex where
|
maybe (gen ty) (generateForMetas True pgf gen) mex where
|
||||||
gen ty = genRandomProb ps rg pgf ty
|
gen ty = genRandomProb ps rg pgf ty
|
||||||
|
|
||||||
|
|
||||||
-- generic algorithm for filling holes in a generator
|
-- generic algorithm for filling holes in a generator
|
||||||
---- for random, should be breadth-first, since now the first metas always get the same
|
-- for random, should be breadth-first, since otherwise first metas always get the same
|
||||||
---- value when a list is generated
|
-- value when a list is generated
|
||||||
generateForMetas :: PGF -> (Type -> [Expr]) -> Expr -> [Expr]
|
generateForMetas :: Bool -> PGF -> (Type -> [Expr]) -> Expr -> [Expr]
|
||||||
generateForMetas pgf gen exp = case exp of
|
generateForMetas breadth pgf gen exp = case exp of
|
||||||
EApp f (EMeta _) -> [EApp g a | g <- gener f, a <- genArg g]
|
EApp f (EMeta _) -> [EApp g a | g <- gener f, a <- genArg g]
|
||||||
EApp f x -> [EApp g a | g <- gener f, a <- gener x]
|
EApp f x | breadth -> [EApp g a | (g,a) <- zip (gener f) (gener x)]
|
||||||
_ -> [exp]
|
EApp f x -> [EApp g a | (g,a) <- zip (gener f) (gener x)]
|
||||||
|
_ -> if breadth then repeat exp else [exp]
|
||||||
where
|
where
|
||||||
gener = generateForMetas pgf gen
|
gener = generateForMetas breadth pgf gen
|
||||||
genArg f = case inferExpr pgf f of
|
genArg f = case inferExpr pgf f of
|
||||||
Right (_,DTyp ((_,_,ty):_) _ _) -> gen ty
|
Right (_,DTyp ((_,_,ty):_) _ _) -> gen ty
|
||||||
_ -> []
|
_ -> []
|
||||||
|
|||||||
Reference in New Issue
Block a user