diff options
| author | Aarne Ranta <aarne@chalmers.se> | 2018-12-18 18:30:40 +0100 |
|---|---|---|
| committer | Aarne Ranta <aarne@chalmers.se> | 2018-12-18 18:30:40 +0100 |
| commit | 9834b89a305d01fa74749e6413d23a61b7330c52 (patch) | |
| tree | 4ff1c55e8da99b5ded4bc84280082585624076d5 /src/runtime/haskell | |
| parent | b3a2b53df2ec75add72447d7aa2032736c4f725c (diff) | |
refactored cnc configfile parsing a bit
Diffstat (limited to 'src/runtime/haskell')
| -rw-r--r-- | src/runtime/haskell/PGF/VisualizeTree.hs | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/runtime/haskell/PGF/VisualizeTree.hs b/src/runtime/haskell/PGF/VisualizeTree.hs index 53cf96a04..b1709e88d 100644 --- a/src/runtime/haskell/PGF/VisualizeTree.hs +++ b/src/runtime/haskell/PGF/VisualizeTree.hs @@ -35,7 +35,7 @@ import PGF.Macros (lookValCat, BracketedString(..)) import qualified Data.Map as Map --import qualified Data.IntMap as IntMap -import Data.List (intersperse,nub,mapAccumL,find,groupBy,sortBy) +import Data.List (intersperse,nub,mapAccumL,find,groupBy,sortBy,partition) import Data.Ord (comparing) import Data.Char (isDigit) import Data.Maybe (fromMaybe) @@ -799,7 +799,7 @@ fixCoNLL cncLabels conll = map fixc conll where _ -> cat ++ "-" ++ x getCncDepLabels :: String -> CncLabels -getCncDepLabels s = wlabels s ++ flabels s +getCncDepLabels s = wlabels ws ++ flabels fs where wlabels = map Left . @@ -807,26 +807,25 @@ getCncDepLabels s = wlabels s ++ flabels s groupBy (\ (x,_) (a,_) -> x == a) . sortBy (comparing fst) . concatMap analyse . - filter chooseW . --- map rmcomments . - lines + filter chooseW + flabels = map Right . map collectTags . - map words . - filter chooseF . --- map rmcomments . - lines + map words + + (fs,ws) = partition chooseF $ lines s --- choose is for compatibility with the general notation chooseW line = notElem '(' line && - elem '{' line && + elem '{' line --- ignoring non-local (with "(") and abstract (without "{") rules ---- TODO: this means that "(" cannot be a token - not (chooseF line) chooseF line = take 1 line == "@" --- feature assignments have the form e.g. @N SgNom SgGen ; no spaces inside tags - + + isComment line = take 2 line == "--" + analyse line = case break (=='{') line of (beg,_:ws) -> case break (=='}') ws of (toks,_:target) -> case (getToks beg, words target) of |
