mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 11:42:49 -06:00
Merge pull request #22 from pkolachi/master
fix conll output in gf2ud and allow comments in dependency configs
This commit is contained in:
@@ -236,10 +236,18 @@ graphvizDependencyTree format debug mlab mclab pgf lang t =
|
|||||||
root_lbl = "ROOT"
|
root_lbl = "ROOT"
|
||||||
unspec = text "_"
|
unspec = text "_"
|
||||||
|
|
||||||
|
-- auxiliaries for UD conversion PK 15/12/2018
|
||||||
|
rmcomments :: String -> String
|
||||||
|
rmcomments [] = []
|
||||||
|
rmcomments ('-':'-':xs) = []
|
||||||
|
rmcomments ('-':x :xs) = '-':rmcomments (x:xs)
|
||||||
|
rmcomments (x:xs) = x:rmcomments xs
|
||||||
|
|
||||||
-- | Prepare lines obtained from a configuration file for labels for
|
-- | Prepare lines obtained from a configuration file for labels for
|
||||||
-- use with 'graphvizDependencyTree'. Format per line /fun/ /label/@*@.
|
-- use with 'graphvizDependencyTree'. Format per line /fun/ /label/@*@.
|
||||||
getDepLabels :: String -> Labels
|
getDepLabels :: String -> Labels
|
||||||
getDepLabels s = Map.fromList [(mkCId f,ls) | f:ls <- map words (lines s)]
|
-- getDepLabels s = Map.fromList [(mkCId f,ls) | f:ls <- map words (lines s)]
|
||||||
|
getDepLabels s = Map.fromList [(mkCId f,ls) | f:ls <- map (words . rmcomments) (lines s)]
|
||||||
|
|
||||||
-- the old function, without dependencies
|
-- the old function, without dependencies
|
||||||
graphvizParseTree :: PGF -> Language -> GraphvizOptions -> Tree -> String
|
graphvizParseTree :: PGF -> Language -> GraphvizOptions -> Tree -> String
|
||||||
@@ -800,12 +808,14 @@ getCncDepLabels s = wlabels s ++ flabels s
|
|||||||
sortBy (comparing fst) .
|
sortBy (comparing fst) .
|
||||||
concatMap analyse .
|
concatMap analyse .
|
||||||
filter chooseW .
|
filter chooseW .
|
||||||
|
-- map rmcomments .
|
||||||
lines
|
lines
|
||||||
flabels =
|
flabels =
|
||||||
map Right .
|
map Right .
|
||||||
map collectTags .
|
map collectTags .
|
||||||
map words .
|
map words .
|
||||||
filter chooseF .
|
filter chooseF .
|
||||||
|
-- map rmcomments .
|
||||||
lines
|
lines
|
||||||
|
|
||||||
--- choose is for compatibility with the general notation
|
--- choose is for compatibility with the general notation
|
||||||
@@ -836,6 +846,7 @@ getCncDepLabels s = wlabels s ++ flabels s
|
|||||||
|
|
||||||
collectTags (w:ws) = (tail w,ws)
|
collectTags (w:ws) = (tail w,ws)
|
||||||
|
|
||||||
|
-- added init to remove the last \n. otherwise, two empty lines are in between each sentence PK 17/12/2018
|
||||||
printCoNLL :: CoNLL -> String
|
printCoNLL :: CoNLL -> String
|
||||||
printCoNLL = unlines . map (concat . intersperse "\t")
|
printCoNLL = init . unlines . map (concat . intersperse "\t")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user