diff options
| author | bringert <bringert@cs.chalmers.se> | 2006-03-20 12:49:31 +0000 |
|---|---|---|
| committer | bringert <bringert@cs.chalmers.se> | 2006-03-20 12:49:31 +0000 |
| commit | 19af3254dc583dbb21723f07c7afb3da5ceefe67 (patch) | |
| tree | f3366bfe1bc13aabc2bcc4d4857f01ec0d104d2f /src/GF/Speech | |
| parent | 076c390b73cdb9d30277655d92c2213a55005d80 (diff) | |
Replaced all used of Data.FiniteMap with Data.Map.
Diffstat (limited to 'src/GF/Speech')
| -rw-r--r-- | src/GF/Speech/SRG.hs | 15 | ||||
| -rw-r--r-- | src/GF/Speech/TransformCFG.hs | 5 |
2 files changed, 11 insertions, 9 deletions
diff --git a/src/GF/Speech/SRG.hs b/src/GF/Speech/SRG.hs index ce4d89da0..e81ae4781 100644 --- a/src/GF/Speech/SRG.hs +++ b/src/GF/Speech/SRG.hs @@ -36,7 +36,8 @@ import GF.Probabilistic.Probabilistic (Probs) import Data.List import Data.Maybe (fromMaybe) -import Data.FiniteMap +import Data.Map (Map) +import qualified Data.Map as Map data SRG = SRG { grammarName :: String -- ^ grammar name , startCat :: String -- ^ start category name @@ -58,7 +59,7 @@ data SRGAlt = SRGAlt (Maybe Double) Name [Symbol String Token] -- | SRG category name and original name type CatName = (String,String) -type CatNames = FiniteMap String String +type CatNames = Map String String -- | Create a non-left-recursive SRG. -- FIXME: the probabilities, names and profiles in the returned @@ -103,7 +104,7 @@ makeSRG_ f i opts probs gr rs = map (cfgRulesToSRGRule names probs) cfgRules -- FIXME: merge alternatives with same rhs and profile but different probabilities -cfgRulesToSRGRule :: FiniteMap String String -> Maybe Probs -> [CFRule_] -> SRGRule +cfgRulesToSRGRule :: Map String String -> Maybe Probs -> [CFRule_] -> SRGRule cfgRulesToSRGRule names probs rs@(r:_) = SRGRule cat origCat rhs where origCat = lhsCat r cat = lookupFM_ names origCat @@ -122,16 +123,16 @@ lookupProb probs i = lookupTree prIdent i probs mkCatNames :: String -- ^ Category name prefix -> [String] -- ^ Original category names - -> FiniteMap String String -- ^ Maps original names to SRG names -mkCatNames prefix origNames = listToFM (zip origNames names) + -> Map String String -- ^ Maps original names to SRG names +mkCatNames prefix origNames = Map.fromList (zip origNames names) where names = [prefix ++ "_" ++ show x | x <- [0..]] -- -- * Utilities for building and printing SRGs -- -lookupFM_ :: (Ord key, Show key) => FiniteMap key elt -> key -> elt -lookupFM_ fm k = lookupWithDefaultFM fm (error $ "Key not found: " ++ show k) k +lookupFM_ :: (Ord key, Show key) => Map key elt -> key -> elt +lookupFM_ fm k = Map.findWithDefault (error $ "Key not found: " ++ show k) k fm prtS :: Print a => a -> ShowS prtS = showString . prt
\ No newline at end of file diff --git a/src/GF/Speech/TransformCFG.hs b/src/GF/Speech/TransformCFG.hs index 38148418c..44ecd1bb0 100644 --- a/src/GF/Speech/TransformCFG.hs +++ b/src/GF/Speech/TransformCFG.hs @@ -34,7 +34,8 @@ import GF.Infra.Print import GF.Speech.FiniteState import Control.Monad -import Data.FiniteMap +import Data.Map (Map) +import qualified Data.Map as Map import Data.List import Data.Maybe (fromMaybe) import Data.Monoid (mconcat) @@ -60,7 +61,7 @@ getStartCat opts = fromMaybe "S" (getOptVal opts gStartCat) ++ "{}.s" -- | Group productions by their lhs categories groupProds :: [CFRule_] -> CFRules -groupProds = fmToList . addListToFM_C (++) emptyFM . map (\r -> (lhsCat r,[r])) +groupProds = Map.toList . Map.fromListWith (++) . map (\r -> (lhsCat r,[r])) ungroupProds :: CFRules -> [CFRule_] ungroupProds = concat . map snd |
