diff options
| author | bringert <bringert@cs.chalmers.se> | 2007-01-21 16:33:44 +0000 |
|---|---|---|
| committer | bringert <bringert@cs.chalmers.se> | 2007-01-21 16:33:44 +0000 |
| commit | 169659c096a38f8fc0cf48e3054efbdf30a96c8c (patch) | |
| tree | baf3f08f571514fe113055ce7dfd321e746b1f44 /src/GF/Speech/SRG.hs | |
| parent | b974ab06cdd64ba1db9278516fbd5803f236d5ee (diff) | |
Get speechLanguage flag from both command-line and grammar. Reformat it to RFC3066 format (- instead of _) and use it in SRGS, VoiceXML and JSGF.
Diffstat (limited to 'src/GF/Speech/SRG.hs')
| -rw-r--r-- | src/GF/Speech/SRG.hs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/GF/Speech/SRG.hs b/src/GF/Speech/SRG.hs index e0a347480..20bdd4a41 100644 --- a/src/GF/Speech/SRG.hs +++ b/src/GF/Speech/SRG.hs @@ -42,7 +42,7 @@ import GF.Speech.FiniteState import GF.Speech.RegExp import GF.Infra.Option import GF.Probabilistic.Probabilistic (Probs) -import GF.Compile.ShellState (StateGrammar, stateProbs, cncId) +import GF.Compile.ShellState (StateGrammar, stateProbs, stateOptions, cncId) import Data.List import Data.Maybe (fromMaybe, maybeToList) @@ -54,8 +54,8 @@ import qualified Data.Set as Set data SRG = SRG { grammarName :: String -- ^ grammar name , startCat :: String -- ^ start category name , origStartCat :: String -- ^ original start category name - , grammarLanguage :: String -- ^ The language for which the grammar - -- is intended, e.g. en_UK + , grammarLanguage :: Maybe String -- ^ The language for which the grammar + -- is intended, e.g. en-UK , rules :: [SRGRule] } deriving (Eq,Show) @@ -100,17 +100,18 @@ makeSRG_ :: (CFRules -> CFRules) -> Options -- ^ Grammar options -> StateGrammar -> SRG -makeSRG_ preprocess opts s = +makeSRG_ preprocess opt s = SRG { grammarName = name, startCat = lookupFM_ names origStart, origStartCat = origStart, grammarLanguage = l, rules = rs } where + opts = addOptions opt (stateOptions s) name = prIdent (cncId s) origStart = getStartCatCF opts s probs = stateProbs s - l = fromMaybe "en_UK" (getOptVal opts speechLanguage) + l = fmap (replace '_' '-') $ getOptVal opts speechLanguage (cats,cfgRules) = unzip $ preprocess $ cfgToCFRules s names = mkCatNames name cats rs = map (cfgRulesToSRGRule names probs) cfgRules |
