diff options
| author | bjorn <bjorn@bringert.net> | 2008-09-26 09:06:52 +0000 |
|---|---|---|
| committer | bjorn <bjorn@bringert.net> | 2008-09-26 09:06:52 +0000 |
| commit | 8fa99886b3a47cf58a2777ffb6d98220ee122643 (patch) | |
| tree | 286a83f4eae16c3cd97a0971fc2c8beaa0950197 /src | |
| parent | b114cfda7736394a5a38f2c1bf731f08f1501eca (diff) | |
In CFG generation: don't add linrow number if the lincat has only a single constituent.
Diffstat (limited to 'src')
| -rw-r--r-- | src/GF/Speech/PGFToCFG.hs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/GF/Speech/PGFToCFG.hs b/src/GF/Speech/PGFToCFG.hs index 6b834d1a4..c11f647d6 100644 --- a/src/GF/Speech/PGFToCFG.hs +++ b/src/GF/Speech/PGFToCFG.hs @@ -10,6 +10,8 @@ module GF.Speech.PGFToCFG (bnfPrinter, nonLeftRecursivePrinter, regularPrinter, import PGF.CId import PGF.Data as PGF import PGF.Macros +import GF.Data.MultiMap (MultiMap) +import qualified GF.Data.MultiMap as MultiMap import GF.Infra.Ident import GF.Speech.CFG @@ -66,7 +68,15 @@ pgfToCFG pgf lang = mkCFG (lookStartCat pgf) extCats (startRules ++ concatMap fr fcatGFCat c = fromMaybe (mkCId "Unknown") (Map.lookup c fcatGFCats) fcatToCat :: FCat -> FIndex -> Cat - fcatToCat c l = prCId (fcatGFCat c) ++ "_" ++ show c ++ "_" ++ show l + fcatToCat c l = prCId (fcatGFCat c) ++ "_" ++ show c ++ row + where row = if catLinArity c == 1 then "" else "_" ++ show l + + -- gets the number of fields in the lincat for the given category + catLinArity :: FCat -> Int + catLinArity c = maximum (1:[rangeSize (bounds rhs) | FRule _ _ _ _ rhs <- Map.findWithDefault [] c rulesByFCat]) + + rulesByFCat :: Map FCat [FRule] + rulesByFCat = Map.fromListWith (++) [(c,[r]) | r@(FRule _ _ _ c _) <- rules] extCats :: Set Cat extCats = Set.fromList $ map lhsCat startRules |
