summaryrefslogtreecommitdiff
path: root/src/runtime/haskell-bind
diff options
context:
space:
mode:
authoraarne <aarne@chalmers.se>2015-04-21 14:13:13 +0000
committeraarne <aarne@chalmers.se>2015-04-21 14:13:13 +0000
commit2804160f07529d5e3dd3f307025479aa2733b0da (patch)
treebe100d922c250972c3cefc4dafc30b70282e427a /src/runtime/haskell-bind
parent27bd12ce67c110f1722be7c991fd340ac2e4a353 (diff)
some translate.probs decreased ; fine-tuning in pgf-hsbind-trans
Diffstat (limited to 'src/runtime/haskell-bind')
-rw-r--r--src/runtime/haskell-bind/examples/pgf-hsbind-trans.hs12
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