diff options
| author | aarne <aarne@chalmers.se> | 2010-03-22 19:03:06 +0000 |
|---|---|---|
| committer | aarne <aarne@chalmers.se> | 2010-03-22 19:03:06 +0000 |
| commit | 716a209f65a2dc10cdaec7e5b12af09267694b3a (patch) | |
| tree | 865181fa69479ba20c85129b01f3e63b778e3bce /src/runtime/haskell | |
| parent | 2ac96a76437733456a3c2cdcbc2d38e2749ff046 (diff) | |
PGF.groupResults and the option l -groups, to show ambiguities grouped by laguage
Diffstat (limited to 'src/runtime/haskell')
| -rw-r--r-- | src/runtime/haskell/PGF.hs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/runtime/haskell/PGF.hs b/src/runtime/haskell/PGF.hs index 9cb23bf50..d27abd76c 100644 --- a/src/runtime/haskell/PGF.hs +++ b/src/runtime/haskell/PGF.hs @@ -51,6 +51,7 @@ module PGF( -- * Operations -- ** Linearization linearize, linearizeAllLang, linearizeAll, + groupResults, -- lins of trees by language, removing duplicates showPrintName, -- ** Parsing @@ -239,6 +240,13 @@ linearizeAll mgr = map snd . linearizeAllLang mgr linearizeAllLang mgr t = [(lang,PGF.linearize mgr lang t) | lang <- languages mgr] +groupResults :: [[(Language,String)]] -> [(Language,[String])] +groupResults = Map.toList . foldr more Map.empty . start . concat + where + start ls = [(l,[s]) | (l,s) <- ls] + more (l,s) = + Map.insertWith (\ [x] xs -> if elem x xs then xs else (x : xs)) l s + parseAll mgr typ = map snd . parseAllLang mgr typ parseAllLang mgr typ s = |
