summaryrefslogtreecommitdiff
path: root/src/GF/Speech/SRG.hs
diff options
context:
space:
mode:
authorbringert <bringert@cs.chalmers.se>2007-06-21 13:40:13 +0000
committerbringert <bringert@cs.chalmers.se>2007-06-21 13:40:13 +0000
commit16bfb1250b0bc97d3b1786585c80bcb3d969e874 (patch)
tree5839d1c2143b86f34cd31577cccd8c367ac350d9 /src/GF/Speech/SRG.hs
parent336273c5344a22f225e54d36b874c6307127b281 (diff)
Added makeSRG.
Diffstat (limited to 'src/GF/Speech/SRG.hs')
-rw-r--r--src/GF/Speech/SRG.hs24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/GF/Speech/SRG.hs b/src/GF/Speech/SRG.hs
index 7ec96232e..8370f130a 100644
--- a/src/GF/Speech/SRG.hs
+++ b/src/GF/Speech/SRG.hs
@@ -17,8 +17,9 @@
-----------------------------------------------------------------------------
module GF.Speech.SRG (SRG(..), SRGRule(..), SRGAlt(..), SRGItem,
- SRGCat, SRGNT, CFTerm,
- makeSimpleSRG
+ SRGCat, SRGNT, CFTerm
+ , makeSRG
+ , makeSimpleSRG
, lookupFM_, prtS
, cfgCatToGFCat, srgTopCats
) where
@@ -82,7 +83,18 @@ type CatNames = Map String String
makeSimpleSRG :: Options -- ^ Grammar options
-> StateGrammar
-> SRG
-makeSimpleSRG opt s =
+makeSimpleSRG opt s = makeSRG preprocess opt s
+ where
+ preprocess origStart = mergeIdentical
+ . removeLeftRecursion origStart
+ . fix (topDownFilter origStart . bottomUpFilter)
+ . removeCycles
+
+makeSRG :: (Cat_ -> CFRules -> CFRules)
+ -> Options -- ^ Grammar options
+ -> StateGrammar
+ -> SRG
+makeSRG preprocess opt s =
SRG { grammarName = name,
startCat = lookupFM_ names origStart,
origStartCat = origStart,
@@ -94,11 +106,7 @@ makeSimpleSRG opt s =
origStart = getStartCatCF opts s
probs = stateProbs s
l = fmap (replace '_' '-') $ getOptVal opts speechLanguage
- (cats,cfgRules) = unzip $ preprocess $ cfgToCFRules s
- preprocess = mergeIdentical
- . removeLeftRecursion origStart
- . fix (topDownFilter origStart . bottomUpFilter)
- . removeCycles
+ (cats,cfgRules) = unzip $ preprocess origStart $ cfgToCFRules s
names = mkCatNames name cats
rs = map (cfgRulesToSRGRule names probs) cfgRules