From 67f64cb233edb899b2b1ad550ae8c832960fb7a2 Mon Sep 17 00:00:00 2001 From: "kr.angelov" Date: Sat, 24 May 2014 07:47:06 +0000 Subject: now we compile context-free grammars directly to PGF without going via GF source code. This makes it quick and lightweight to compile big grammars such as the Berkley grammar --- src/compiler/GF/Command/Importing.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/compiler/GF/Command') diff --git a/src/compiler/GF/Command/Importing.hs b/src/compiler/GF/Command/Importing.hs index 78c019bd4..3cf7674a0 100644 --- a/src/compiler/GF/Command/Importing.hs +++ b/src/compiler/GF/Command/Importing.hs @@ -2,11 +2,12 @@ module GF.Command.Importing (importGrammar, importSource) where import PGF import PGF.Data +import PGF.Optimize import GF.Compile import GF.Compile.Multi (readMulti) import GF.Compile.GetGrammar (getCFRules, getEBNFRules) -import GF.Grammar (identS, SourceGrammar) -- for cc command +import GF.Grammar (SourceGrammar) -- for cc command import GF.Grammar.CFG import GF.Grammar.EBNF import GF.Compile.CFGtoPGF @@ -65,6 +66,7 @@ importCF opts files get convert = do startCat <- case rules of (CFRule cat _ _ : _) -> return cat _ -> fail "empty CFG" - let gf = cf2gf (last files) (uniqueFuns (mkCFG startCat Set.empty rules)) - gr <- compileSourceGrammar opts gf - link opts (identS (justModuleName (last files) ++ "Abs"), (), gr) + let pgf = cf2pgf (last files) (uniqueFuns (mkCFG startCat Set.empty rules)) + probs <- liftIO (maybe (return . defaultProbabilities) readProbabilitiesFromFile (flag optProbsFile opts) pgf) + return $ setProbabilities probs + $ if flag optOptimizePGF opts then optimizePGF pgf else pgf -- cgit v1.2.3