diff options
| author | aarne <unknown> | 2005-10-31 18:02:34 +0000 |
|---|---|---|
| committer | aarne <unknown> | 2005-10-31 18:02:34 +0000 |
| commit | f06638cc7d90eb8298180d36e79fc292a9f898dc (patch) | |
| tree | b33a7459a5e777a319c3d85dbf21da62b8a34358 /src/GF/API | |
| parent | 94f87d85023fc9b0e759600435e3c85cf31e3bc4 (diff) | |
probabilities in ShellState
Diffstat (limited to 'src/GF/API')
| -rw-r--r-- | src/GF/API/IOGrammar.hs | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/GF/API/IOGrammar.hs b/src/GF/API/IOGrammar.hs index 987800e16..f06799da1 100644 --- a/src/GF/API/IOGrammar.hs +++ b/src/GF/API/IOGrammar.hs @@ -5,9 +5,9 @@ -- Stability : (stable) -- Portability : (portable) -- --- > CVS $Date: 2005/04/21 16:45:58 $ --- > CVS $Author: bringert $ --- > CVS $Revision: 1.18 $ +-- > CVS $Date: 2005/10/31 19:02:35 $ +-- > CVS $Author: aarne $ +-- > CVS $Revision: 1.19 $ -- -- for reading grammars and terms from strings and files ----------------------------------------------------------------------------- @@ -21,6 +21,7 @@ import GF.Compile.PGrammar import GF.Grammar.TypeCheck import GF.Compile.Compile import GF.Compile.ShellState +import GF.Probabilistic.Probabilistic import GF.Infra.Modules import GF.Infra.ReadFiles (isOldFile) @@ -50,7 +51,9 @@ string2annotTree gr m = annotate gr . string2absTerm (prt m) ---- prt ---string2paramList st = map (renameTrm (lookupConcrete st) . patt2term) . pPattList shellStateFromFiles :: Options -> ShellState -> FilePath -> IOE ShellState -shellStateFromFiles opts st file = case fileSuffix file of +shellStateFromFiles opts st file = do + let top = identC $ justModuleName file + sh <- case fileSuffix file of "gfcm" -> do cenv <- compileOne opts (compileEnvShSt st []) file ioeErr $ updateShellState opts Nothing st cenv @@ -66,10 +69,14 @@ shellStateFromFiles opts st file = case fileSuffix file of then addOptions (options []) opts' -- for old no emit else addOptions (options [emitCode]) opts' grts <- compileModule osb st file - let top = identC $ justModuleName file - mtop = if oElem showOld opts' then Nothing else Just top + let mtop = if oElem showOld opts' then Nothing else Just top ioeErr $ updateShellState opts' mtop st grts - --- liftM (changeModTimes rts) $ grammar2shellState opts gr + if (isSetFlag opts probFile || oElem (iOpt "prob") opts) + then do + probs <- ioeIO $ getProbsFromFile opts file + let lang = maybe top id $ concrete sh --- to work with cf, too + ioeErr $ addProbs (lang,probs) sh + else return sh getShellStateFromFiles :: Options -> FilePath -> IO ShellState getShellStateFromFiles os = |
