forked from GitHub/gf-core
Get speechLanguage flag from both command-line and grammar. Reformat it to RFC3066 format (- instead of _) and use it in SRGS, VoiceXML and JSGF.
This commit is contained in:
@@ -34,6 +34,7 @@ import GF.Compile.ShellState (StateGrammar)
|
||||
|
||||
import Data.Char
|
||||
import Data.List
|
||||
import Data.Maybe
|
||||
import Text.PrettyPrint.HughesPJ
|
||||
import Debug.Trace
|
||||
|
||||
@@ -44,13 +45,15 @@ jsgfPrinter :: Maybe SISRFormat
|
||||
jsgfPrinter sisr opts s = show $ prJSGF sisr $ makeSimpleSRG opts s
|
||||
|
||||
prJSGF :: Maybe SISRFormat -> SRG -> Doc
|
||||
prJSGF sisr srg@(SRG{grammarName=name,startCat=start,origStartCat=origStart,rules=rs})
|
||||
prJSGF sisr srg@(SRG{grammarName=name,grammarLanguage=ml,
|
||||
startCat=start,origStartCat=origStart,rules=rs})
|
||||
= header $++$ mainCat $++$ vcat topCatRules $++$ foldr ($++$) empty (map prRule rs)
|
||||
where
|
||||
header = text "#JSGF V1.0 UTF-8;" $$
|
||||
header = text "#JSGF" <+> text "V1.0" <+> text "UTF-8" <+> lang <> char ';' $$
|
||||
comment ("JSGF speech recognition grammar for " ++ name) $$
|
||||
comment "Generated by GF" $$
|
||||
text ("grammar " ++ name ++ ";")
|
||||
lang = maybe empty text ml
|
||||
mainCat = comment ("Start category: " ++ origStart) $$
|
||||
rule True "MAIN" [prCat start]
|
||||
prRule (SRGRule cat origCat rhs) =
|
||||
|
||||
Reference in New Issue
Block a user