From cb8795c222ae86e4561e1009c382fe0b87e22b62 Mon Sep 17 00:00:00 2001 From: krasimir Date: Sat, 2 Oct 2010 13:03:57 +0000 Subject: refactor the API for random generation again. Now PGF contains probabilities in the abstract syntax --- src/compiler/GF/Compile.hs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/compiler/GF/Compile.hs') diff --git a/src/compiler/GF/Compile.hs b/src/compiler/GF/Compile.hs index ecb533c3f..7c1290d7e 100644 --- a/src/compiler/GF/Compile.hs +++ b/src/compiler/GF/Compile.hs @@ -42,6 +42,7 @@ import PGF.CId import PGF.Data import PGF.Macros import PGF.Optimize +import PGF.Probabilistic -- | Compiles a number of source files and builds a 'PGF' structure for them. @@ -55,9 +56,13 @@ link :: Options -> Ident -> SourceGrammar -> IOE PGF link opts cnc gr = do let isv = (verbAtLeast opts Normal) putPointE Normal opts "linking ... " $ do - gc <- ioeIO (mkCanon2pgf opts cnc gr) - ioeIO $ putStrLn "OK" - return $ if flag optOptimizePGF opts then optimizePGF gc else gc + pgf <- ioeIO (mkCanon2pgf opts cnc gr) + probs <- ioeIO (maybe (return . defaultProbabilities) readProbabilitiesFromFile (flag optProbsFile opts) pgf) + ioeIO $ putStrLn "OK" + pgf <- return $ setProbabilities probs + $ if flag optOptimizePGF opts then optimizePGF pgf else pgf + ioeIO $ putStrLn (showProbabilities (getProbabilities pgf)) + return pgf batchCompile :: Options -> [FilePath] -> IOE SourceGrammar batchCompile opts files = do -- cgit v1.2.3