mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-06 01:32:50 -06:00
Change input to the different SRG printers to be StateGrammar instead of CGrammar. This to allow looking at the types in SISR, and to reduce the number of argument passed from Custom.
This commit is contained in:
@@ -27,18 +27,19 @@ import GF.Conversion.Types
|
||||
import GF.Infra.Print
|
||||
import GF.Infra.Option
|
||||
import GF.Probabilistic.Probabilistic (Probs)
|
||||
import GF.Compile.ShellState (StateGrammar)
|
||||
|
||||
import Data.Char (toUpper,toLower)
|
||||
|
||||
gslPrinter :: Ident -- ^ Grammar name
|
||||
-> String -- ^ Start category
|
||||
-> Options -> Maybe Probs -> CGrammar -> String
|
||||
gslPrinter name start opts probs cfg = prGSL srg ""
|
||||
where srg = topDownFilter $ makeSimpleSRG name start opts probs $ rmPunctCFG cfg
|
||||
gslPrinter :: Ident -- ^ Grammar name
|
||||
-> String -- ^ Start category
|
||||
-> Options -> StateGrammar -> String
|
||||
gslPrinter name start opts =
|
||||
prGSL . topDownFilter . makeSimpleSRG name start opts
|
||||
|
||||
prGSL :: SRG -> ShowS
|
||||
prGSL :: SRG -> String
|
||||
prGSL (SRG{grammarName=name,startCat=start,origStartCat=origStart,rules=rs})
|
||||
= header . mainCat . unlinesS (map prRule rs)
|
||||
= (header . mainCat . unlinesS (map prRule rs)) ""
|
||||
where
|
||||
header = showString ";GSL2.0" . nl
|
||||
. comments ["Nuance speech recognition grammar for " ++ name,
|
||||
@@ -59,12 +60,14 @@ firstToUpper :: String -> String
|
||||
firstToUpper [] = []
|
||||
firstToUpper (x:xs) = toUpper x : xs
|
||||
|
||||
{-
|
||||
rmPunctCFG :: CGrammar -> CGrammar
|
||||
rmPunctCFG g = [CFRule c (filter keepSymbol ss) n | CFRule c ss n <- g]
|
||||
|
||||
keepSymbol :: Symbol c Token -> Bool
|
||||
keepSymbol (Tok t) = not (all isPunct (prt t))
|
||||
keepSymbol _ = True
|
||||
-}
|
||||
|
||||
-- Nuance does not like upper case characters in tokens
|
||||
showToken :: Token -> String
|
||||
|
||||
Reference in New Issue
Block a user