diff options
| author | peb <unknown> | 2005-04-18 13:55:32 +0000 |
|---|---|---|
| committer | peb <unknown> | 2005-04-18 13:55:32 +0000 |
| commit | c1592825c71867711a63293b588fcbc97e52bfc4 (patch) | |
| tree | 5b042471de94431e15f8fda2c6ff9a85bce99cef /src/GF/Parsing | |
| parent | 1323b7406376c72f40b1e561e079f8824f79aabf (diff) | |
"Committed_by_peb"
Diffstat (limited to 'src/GF/Parsing')
| -rw-r--r-- | src/GF/Parsing/CF.hs | 15 | ||||
| -rw-r--r-- | src/GF/Parsing/CFG/General.hs | 11 | ||||
| -rw-r--r-- | src/GF/Parsing/CFG/Incremental.hs | 15 | ||||
| -rw-r--r-- | src/GF/Parsing/CFG/PInfo.hs | 22 | ||||
| -rw-r--r-- | src/GF/Parsing/GFC.hs | 22 |
5 files changed, 43 insertions, 42 deletions
diff --git a/src/GF/Parsing/CF.hs b/src/GF/Parsing/CF.hs index 3079a47ec..2be4db52e 100644 --- a/src/GF/Parsing/CF.hs +++ b/src/GF/Parsing/CF.hs @@ -4,9 +4,9 @@ -- Stability : (stable) -- Portability : (portable) -- --- > CVS $Date: 2005/04/14 18:41:22 $ +-- > CVS $Date: 2005/04/18 14:55:33 $ -- > CVS $Author: peb $ --- > CVS $Revision: 1.1 $ +-- > CVS $Revision: 1.2 $ -- -- Chart parsing of grammars in CF format ----------------------------------------------------------------------------- @@ -32,19 +32,18 @@ parse :: String -> CF.CF -> Category -> CF.CFParser parse = buildParser . P.parseCF buildParser :: P.CFParser Category Name Token -> CF.CF -> Category -> CF.CFParser -buildParser parser cf start tokens = trace "ParseCF" $ - (parseResults, parseInformation) +buildParser parser cf start tokens = (parseResults, parseInformation) where parseInformation = prtSep "\n" trees parseResults = [ (tree2cfTree t, []) | t <- trees ] theInput = input tokens - edges = tracePrt "#edges" (prt.length) $ + edges = tracePrt "Parsing.CF - nr. edges" (prt.length) $ parser pInf [start] theInput - chart = tracePrt "#chart" (prt . map (length.snd) . aAssocs) $ + chart = tracePrt "Parsing.CF - size of chart" (prt . map (length.snd) . aAssocs) $ grammar2chart $ map addCategory edges - forests = tracePrt "#forests" (prt.length) $ + forests = tracePrt "Parsing.CF - nr. forests" (prt.length) $ chart2forests chart (const False) [ uncurry Edge (inputBounds theInput) start ] - trees = tracePrt "#trees" (prt.length) $ + trees = tracePrt "Parsing.CF - nr. trees" (prt.length) $ concatMap forest2trees forests pInf = P.buildCFPInfo $ cf2grammar cf (nubsort tokens) diff --git a/src/GF/Parsing/CFG/General.hs b/src/GF/Parsing/CFG/General.hs index 33e0b9232..52b3c5665 100644 --- a/src/GF/Parsing/CFG/General.hs +++ b/src/GF/Parsing/CFG/General.hs @@ -4,9 +4,9 @@ -- Stability : (stable) -- Portability : (portable) -- --- > CVS $Date: 2005/04/16 05:40:49 $ +-- > CVS $Date: 2005/04/18 14:55:33 $ -- > CVS $Author: peb $ --- > CVS $Revision: 1.2 $ +-- > CVS $Revision: 1.3 $ -- -- CFG parsing with a general chart ----------------------------------------------------------------------------- @@ -26,7 +26,8 @@ import Monad parse :: (Ord n, Ord c, Ord t) => Strategy -> CFParser c n t parse strategy grammar start = extract . - tracePrt "#internal chart" (prt . length . chartList) . + tracePrt "Parsing.CFG.General - size internal of chart" + (prt . length . chartList) . process strategy grammar start -- | parsing strategy: (isBottomup, isTopdown) @@ -54,8 +55,8 @@ process :: (Ord n, Ord c, Ord t) => -> Input t -- ^ input string -> IChart n (Symbol c t) process (isBottomup, isTopdown) grammar start - = trace2 "CFParserGeneral" ((if isBottomup then " BU" else "") ++ - (if isTopdown then " TD" else "")) $ + = trace2 "Parsing.CFG.General - strategy" ((if isBottomup then " BU" else "") ++ + (if isTopdown then " TD" else "")) $ buildChart keyof [predict, combine] . axioms where axioms input = initial ++ scan input diff --git a/src/GF/Parsing/CFG/Incremental.hs b/src/GF/Parsing/CFG/Incremental.hs index e934b48c5..54aaf3b6d 100644 --- a/src/GF/Parsing/CFG/Incremental.hs +++ b/src/GF/Parsing/CFG/Incremental.hs @@ -4,9 +4,9 @@ -- Stability : (stable) -- Portability : (portable) -- --- > CVS $Date: 2005/04/16 05:40:49 $ +-- > CVS $Date: 2005/04/18 14:55:33 $ -- > CVS $Author: peb $ --- > CVS $Revision: 1.2 $ +-- > CVS $Revision: 1.3 $ -- -- Incremental chart parsing for CFG ----------------------------------------------------------------------------- @@ -34,7 +34,8 @@ type Strategy = ((Bool, Bool), (Bool, Bool)) parse :: (Ord n, Ord c, Ord t) => Strategy -> CFParser c n t parse strategy grammar start = extract . - tracePrt "#internal chart" (prt . length . flip chartList const) . + tracePrt "Parsing.CFG.Incremental - size of internal chart" + (prt . length . flip chartList const) . process strategy grammar start extract :: (Ord n, Ord c, Ord t) => @@ -54,10 +55,10 @@ extract finalChart = [ CFRule (Edge j k cat) daughters name | process :: (Ord n, Ord c, Ord t) => Strategy -> CFPInfo c n t -> [c] -> Input t -> IChart c n t process ((isPredictBU, isPredictTD), (isFilterBU, isFilterTD)) grammar start input - = trace2 "CFParserIncremental" ((if isPredictBU then "BU-predict " else "") ++ - (if isPredictTD then "TD-predict " else "") ++ - (if isFilterBU then "BU-filter " else "") ++ - (if isFilterTD then "TD-filter " else "")) $ + = trace2 "Parsing.CFG.Incremental - strategy" ((if isPredictBU then "BU-predict " else "") ++ + (if isPredictTD then "TD-predict " else "") ++ + (if isFilterBU then "BU-filter " else "") ++ + (if isFilterTD then "TD-filter " else "")) $ finalChart where finalChart = buildChart keyof rules axioms $ inputBounds input diff --git a/src/GF/Parsing/CFG/PInfo.hs b/src/GF/Parsing/CFG/PInfo.hs index 63c506e19..c8bb9af29 100644 --- a/src/GF/Parsing/CFG/PInfo.hs +++ b/src/GF/Parsing/CFG/PInfo.hs @@ -4,9 +4,9 @@ -- Stability : (stable) -- Portability : (portable) -- --- > CVS $Date: 2005/04/16 05:40:49 $ +-- > CVS $Date: 2005/04/18 14:55:33 $ -- > CVS $Author: peb $ --- > CVS $Revision: 1.2 $ +-- > CVS $Revision: 1.3 $ -- -- CFG parsing, parser information ----------------------------------------------------------------------------- @@ -51,7 +51,7 @@ buildCFPInfo :: (Ord n, Ord c, Ord t) => CFGrammar c n t -> CFPInfo c n t -- this is not permanent... buildCFPInfo grammar = traceCalcFirst grammar $ - tracePrt "cf parser info" (prt) $ + tracePrt "CFG.PInfo - parser info" (prt) $ pInfo' (filter (not . isCyclic) grammar) pInfo' grammar = CFPInfo grToks nmRules tdRules buRules elcRules emptyCats cyclicCats leftToks @@ -84,14 +84,14 @@ isCyclic _ = False ---------------------------------------------------------------------- instance (Ord n, Ord c, Ord t) => Print (CFPInfo n c t) where - prt pI = "[ tokens=" ++ sl grammarTokens ++ - "; names=" ++ sla nameRules ++ - "; tdCats=" ++ sla topdownRules ++ - "; buCats=" ++ sla bottomupRules ++ - "; elcCats=" ++ sla emptyLeftcornerRules ++ - "; eCats=" ++ sla emptyCategories ++ - "; cCats=" ++ sl cyclicCategories ++ - "; lctokCats=" ++ sla leftcornerTokens ++ + prt pI = "[ nr. tokens=" ++ sl grammarTokens ++ + "; nr. names=" ++ sla nameRules ++ + "; nr. tdCats=" ++ sla topdownRules ++ + "; nr. buCats=" ++ sla bottomupRules ++ + "; nr. elcCats=" ++ sla emptyLeftcornerRules ++ + "; nr. eCats=" ++ sla emptyCategories ++ + "; nr. cCats=" ++ sl cyclicCategories ++ + "; nr. lctokCats=" ++ sla leftcornerTokens ++ " ]" where sla f = show $ length $ aElems $ f pI sl f = show $ length $ f pI diff --git a/src/GF/Parsing/GFC.hs b/src/GF/Parsing/GFC.hs index 5ca6edcd1..56cbcf1db 100644 --- a/src/GF/Parsing/GFC.hs +++ b/src/GF/Parsing/GFC.hs @@ -4,9 +4,9 @@ -- Stability : (stable) -- Portability : (portable) -- --- > CVS $Date: 2005/04/12 10:49:45 $ +-- > CVS $Date: 2005/04/18 14:55:33 $ -- > CVS $Author: peb $ --- > CVS $Revision: 1.2 $ +-- > CVS $Revision: 1.3 $ -- -- The main parsing module, parsing GFC grammars -- by translating to simpler formats, such as PMCFG and CFG @@ -67,9 +67,9 @@ parse (c:strategy) pinfo abs startCat | c=='c' || c=='C' = map (tree2term abs) . parseCFG strategy pinfo startCats . map prCFTok - where startCats = tracePrt "startCats" prt $ + where startCats = tracePrt "Parsing.GFC - starting categories" prt $ filter isStartCat $ map fst $ aAssocs $ PC.topdownRules $ cfPInfo pinfo - isStartCat (CCat (MCat cat _) _) = cat == cfCat2Ident startCat + isStartCat (CCat (ECat cat _) _) = cat == cfCat2Ident startCat -- default parser parse strategy pinfo abs start = parse ('c':strategy) pinfo abs start @@ -78,9 +78,9 @@ parse strategy pinfo abs start = parse ('c':strategy) pinfo abs start ---------------------------------------------------------------------- parseCFG :: String -> PInfo -> [CCat] -> [Token] -> [SyntaxTree Fun] -parseCFG strategy pInfo startCats inString = trace2 "Parser" "CFG" $ +parseCFG strategy pInfo startCats inString = trace2 "Parsing.GFC - selected algorithm" "CFG" $ trees - where trees = tracePrt "#trees" (prt . length) $ + where trees = tracePrt "Parsing.GFC - nr. trees" (prt . length) $ nubsort $ forests >>= forest2trees -- compactFs >>= forest2trees @@ -88,19 +88,19 @@ parseCFG strategy pInfo startCats inString = trace2 "Parser" "CFG" $ -- tracePrt "compactForests" (prtBefore "\n") $ -- compactForests forests - forests = tracePrt "#forests" (prt . length) $ + forests = tracePrt "Parsing.GFC - nr. forests" (prt . length) $ cfForests >>= convertFromCFForest - cfForests= tracePrt "#cfForests" (prt . length) $ + cfForests= tracePrt "Parsing.GFC - nr. context-free forests" (prt . length) $ chart2forests chart (const False) finalEdges - finalEdges = tracePrt "finalChartEdges" prt $ + finalEdges = tracePrt "Parsing.GFC - final chart edges" prt $ map (uncurry Edge (inputBounds inTokens)) startCats chart = --tracePrt "finalChartEdges" (prt . (? finalEdge)) $ - tracePrt "#chart" (prt . map (length.snd) . aAssocs) $ + tracePrt "Parsing.GFC - size of chart" (prt . map (length.snd) . aAssocs) $ C.grammar2chart cfChart cfChart = --tracePrt "finalEdges" --(prt . filter (\(Edge i j _) -> (i,j)==inputBounds inTokens)) $ - tracePrt "#cfChart" (prt . length) $ + tracePrt "Parsing.GFC - size of context-free chart" (prt . length) $ PC.parseCF strategy (cfPInfo pInfo) startCats inTokens inTokens = input inString |
