Skip to content

Commit 6b25630

Browse files
authored
Merge pull request #25 from anka-213/no-backups
Add option for disabling backups
2 parents 7463066 + 79b1bf6 commit 6b25630

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

UD2GF.hs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ getExprs opts env string = map getExpr sentences
4747
devtree1 = analyseWords env devtree0
4848
devtree = combineTrees env devtree1
4949
besttree0 = head (splitDevTree devtree)
50-
besttree = addBackups besttree0
50+
besttree = addBackups opts besttree0
5151
ts0 = devtree2abstrees besttree
5252
ts1 = map (expandMacro env) ts0
5353
crs = map (checkAbsTreeResult env) ts1
@@ -84,7 +84,7 @@ showUD2GF opts env sentence = do
8484
let besttree0 = head (splitDevTree devtree)
8585
ifOpt opts "bt0" $ prLinesRTree (prDevNode 1) besttree0
8686

87-
let besttree = addBackups besttree0
87+
let besttree = addBackups opts besttree0
8888
ifOpt opts "bt" $ prLinesRTree (prDevNode 1) besttree
8989

9090
let ts0 = devtree2abstrees besttree
@@ -230,15 +230,16 @@ devtree2abstrees :: DevTree -> [AbsTree]
230230
devtree2abstrees = map atiAbsTree . devAbsTrees . root
231231

232232
-- to be applied to a DevTree with just one tree at each node
233-
addBackups :: DevTree -> DevTree
234-
addBackups = addBackups0 ---- TODO: this must be improved
233+
addBackups :: Opts -> DevTree -> DevTree
234+
addBackups opts | isOpt opts "no-backups" = id
235+
| otherwise = addBackups0 ---- TODO: this must be improved
235236

236237
addBackups0 :: DevTree -> DevTree
237238
addBackups0 tr@(RTree dn trs) = case map collectBackup (tr:trs) of -- backups from the tree itself and every subtree
238239
btrs -> RTree
239240
(dn {devAbsTrees = [
240-
replaceInfo [(t,ai) | (_,(t,Just ai)) <- btrs] --
241-
(theAbsTreeInfo tr)] -- the only abstree that there is
241+
replaceInfo [(t,ai) | (_,(t,Just ai)) <- btrs] --
242+
(theAbsTreeInfo tr)] -- the only abstree that there is
242243
}
243244
)
244245
(map fst (tail btrs))
@@ -355,7 +356,7 @@ combineTrees env =
355356
where
356357
-- The head only contains new trees that were created in the previous iteration
357358
onlyNewTree = tr {root = nd { devAbsTrees = map funInfoToAbsTreeInfo fis}}
358-
-- Add the new trees to the old ones. There shouldn't really be any duplicates now, so there's
359+
-- Add the new trees to the old ones. There shouldn't really be any duplicates now, so there's
359360
-- a bit of redundant checking going on here.
360361
nextTr = combineUnduplicated fis tr
361362

@@ -479,7 +480,7 @@ analyseWords env = mapRTree lemma2fun
479480

480481
auxWords = [(lemma,cat) | ((fun_,lemma),(cat,labels_)) <- M.assocs (lemmaLabels (cncLabels env))]
481482

482-
-- auxiliaries
483+
-- auxiliaries
483484
newWordTree w c = RTree (mkCId (w ++ "_" ++ showCId c)) [] ---
484485
isNewWordFun f = isInfixOf "__x__" (showCId f)
485486
unknownCat = mkCId "Adv" --- treat unknown words as adverbs ---- TODO: from config

UDOptions.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ fullOpts = [
3939
("at0","resulting GF tree, with macros in place"),
4040
("at", "final GF tree, macros expanded"),
4141
("tc", "type checking the final GF tree"),
42+
("no-backups", "don't add backups to incomplete trees"),
4243
("sum","summary: GF tree built from the interpreted nodes"),
4344
("gf", "(gf2ud) original GF tree"),
4445
("an0","(gf2ud) initial annotated tree"),

0 commit comments

Comments
 (0)