diff options
| author | aarne <aarne@chalmers.se> | 2015-04-21 14:13:13 +0000 |
|---|---|---|
| committer | aarne <aarne@chalmers.se> | 2015-04-21 14:13:13 +0000 |
| commit | 2804160f07529d5e3dd3f307025479aa2733b0da (patch) | |
| tree | be100d922c250972c3cefc4dafc30b70282e427a /src/runtime | |
| parent | 27bd12ce67c110f1722be7c991fd340ac2e4a353 (diff) | |
some translate.probs decreased ; fine-tuning in pgf-hsbind-trans
Diffstat (limited to 'src/runtime')
| -rw-r--r-- | src/runtime/haskell-bind/examples/pgf-hsbind-trans.hs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/runtime/haskell-bind/examples/pgf-hsbind-trans.hs b/src/runtime/haskell-bind/examples/pgf-hsbind-trans.hs index d04a96e08..7487c04df 100644 --- a/src/runtime/haskell-bind/examples/pgf-hsbind-trans.hs +++ b/src/runtime/haskell-bind/examples/pgf-hsbind-trans.hs @@ -7,6 +7,7 @@ import PGF2 import PGF.Lexing (lexText') import Data.Char(isSpace,toLower) +import Data.List (nub) import System.Environment import qualified Data.Map as Map @@ -33,14 +34,19 @@ getConcr' pgf lang = maybe (fail $ "Concrete syntax not found: "++show lang) return $ Map.lookup lang (languages pgf) -linearizeAndShow gr mxv (t,p) = [show t]++take mxv (linearizeAll gr t)++[show p] +linearizeAndShow gr mxv (t,p) = [show t]++take mxv (nub (map unstar (linearizeAll gr t)))++[show p] + where + unstar s = case s of + '*':' ':cs -> cs + _ -> s translates pgf cfrom cto cat (mxt,mxv) s0 = - let s = lextext cfrom s0 + let s1 = lextext cfrom s0 + (s,p) = case reverse s1 of c:_ | elem c ".?!" -> (init s1,[c]) ; _ -> (s1,[]) -- separate final punctuation in case cparse pgf cfrom cat s of Left tok -> unlines [s,"Parse error: "++tok] - Right ts -> unlines $ take mxt $ map (unlines . linearizeAndShow cto mxv) ts + Right ts -> unlines $ (("> "++ s):) $ take mxt $ map ((++p) . unlines . linearizeAndShow cto mxv) ts -- append punctuation cparse pgf concr cat input = parseWithHeuristics concr cat input (-1) callbacks where callbacks = maybe [] cb $ lookup "App" literalCallbacks |
