summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbringert <bringert@cs.chalmers.se>2007-06-27 16:27:08 +0000
committerbringert <bringert@cs.chalmers.se>2007-06-27 16:27:08 +0000
commit92b1b85a1ff0971c35242ee665717fcfb3dbead6 (patch)
tree29fe3188a3478592fdd36ffff01246029fd6e36b /src
parentc3c84f65744d1a1860d527d3f52c897953f6f8c0 (diff)
Print SRG stats when preprocessing grammar.
Diffstat (limited to 'src')
-rw-r--r--src/GF/Speech/SRG.hs20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/GF/Speech/SRG.hs b/src/GF/Speech/SRG.hs
index 49fa67f27..293cee34c 100644
--- a/src/GF/Speech/SRG.hs
+++ b/src/GF/Speech/SRG.hs
@@ -50,6 +50,8 @@ import qualified Data.Map as Map
import Data.Set (Set)
import qualified Data.Set as Set
+import Debug.Trace
+
data SRG = SRG { grammarName :: String -- ^ grammar name
, startCat :: SRGCat -- ^ start category name
, origStartCat :: String -- ^ original start category name
@@ -87,10 +89,22 @@ makeSimpleSRG :: Options -- ^ Grammar options
-> SRG
makeSimpleSRG opt s = makeSRG preprocess opt s
where
- preprocess origStart = mergeIdentical
+ preprocess origStart = traceStats "After mergeIdentical"
+ . mergeIdentical
+ . traceStats "After removeLeftRecursion"
. removeLeftRecursion origStart
- . fix (topDownFilter origStart . bottomUpFilter)
- . removeCycles
+ . fix (traceStats "After topDownFilter"
+ . topDownFilter origStart
+ . traceStats "After bottomUpFilter"
+ . bottomUpFilter)
+ . traceStats "After removeCycles"
+ . removeCycles
+ . traceStats "Inital CFG"
+
+traceStats s g = trace (s ++ ": " ++ stats g) g
+
+stats g = "Categories: " ++ show (length (filter (not . null . snd) g))
+ ++ " Rules: " ++ show (length (concatMap snd g))
makeNonRecursiveSRG :: Options
-> StateGrammar