summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2008-12-15 15:45:36 +0000
committeraarne <aarne@cs.chalmers.se>2008-12-15 15:45:36 +0000
commite478228cb5738d67c7fa10e39e32013f8e99d955 (patch)
tree306e7677fbb707f9730c8f20c6eee01f6677f05e
parent10675e29cac9149c18fbf61903e52468426a0ea1 (diff)
better treatment of syncategorematic words in alignment
-rw-r--r--src/PGF/VisualizeTree.hs16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/PGF/VisualizeTree.hs b/src/PGF/VisualizeTree.hs
index a15e380d6..ae91fd9de 100644
--- a/src/PGF/VisualizeTree.hs
+++ b/src/PGF/VisualizeTree.hs
@@ -65,7 +65,10 @@ lin2graph ss = prelude ++ nodes ++ links
prelude = ["rankdir=LR ;", "node [shape = record] ;"]
- -- find all words
+ -- the plain string, with syncategorematic words included
+ strings = filter (flip notElem "{[()]}" . head) . words
+
+ -- find all lexicalized words
lins :: String -> [(String,String)]
lins [] = []
lins s = let (s1, s2) = if null s then ([],[]) else span (/='{') s in
@@ -75,11 +78,18 @@ lin2graph ss = prelude ++ nodes ++ links
-- separate a word to the link (1,2,3) and the word itself
wlink :: String -> (String,String)
wlink s = let (s1, s2) = span (/=']') s in
- (tail s1, init (drop 1 s2))
+ (tail s1, unwords (words (init (drop 1 s2))))
+
+ -- to merge in syncat words
+ slins i s = merge (strings s) (lins s) where
+ merge ws cs = case (ws,cs) of
+ (w:ws2,(m,c):cs2) | w==c -> (m,c) : merge ws2 cs2
+ (w:ws2,_ ) -> ("w" ++ show i,w) : merge ws2 cs
+ _ -> []
-- make all marks unique to deal with discontinuities
nlins :: [(Int,[((Int,String),String)])]
- nlins = [(i, [((j,m),w) | (j,(m,w)) <- zip [0..] (lins s)]) | (i,s) <- zip [0..] ss]
+ nlins = [(i, [((j,m),w) | (j,(m,w)) <- zip [0..] (slins i s)]) | (i,s) <- zip [0..] ss]
nodes = map mkStruct nlins