Skip to content
Snippets Groups Projects
Commit e46f5930 authored by Franck Dary's avatar Franck Dary
Browse files

Corrected bug where NOBACK was impossible after a BACK

parent 9d39440a
Branches erased
No related tags found
No related merge requests found
...@@ -15,7 +15,7 @@ class Transition : ...@@ -15,7 +15,7 @@ class Transition :
if len(splited) == 3 : if len(splited) == 3 :
self.colName = splited[1] self.colName = splited[1]
self.argument = splited[2] self.argument = splited[2]
if not self.name in ["SHIFT","REDUCE","LEFT","RIGHT","BACK","NOBACK","NOBACKAB","EOS","TAG"] : if not self.name in ["SHIFT","REDUCE","LEFT","RIGHT","BACK","NOBACK","NOBACKAB","NOBACKBB","EOS","TAG"] :
raise(Exception("'%s' is not a valid transition type."%name)) raise(Exception("'%s' is not a valid transition type."%name))
def __str__(self) : def __str__(self) :
...@@ -81,6 +81,8 @@ class Transition : ...@@ -81,6 +81,8 @@ class Transition :
if self.name == "TAG" : if self.name == "TAG" :
return isEmpty(config.getAsFeature(config.wordIndex, self.colName)) or config.getAsFeature(config.wordIndex, self.colName) == Dicts.Dicts.erased return isEmpty(config.getAsFeature(config.wordIndex, self.colName)) or config.getAsFeature(config.wordIndex, self.colName) == Dicts.Dicts.erased
if self.name == "NOBACK" : if self.name == "NOBACK" :
return True
if self.name == "NOBACKBB" :
return config.nbUndone == 0 return config.nbUndone == 0
if self.name == "NOBACKAB" : if self.name == "NOBACKAB" :
return config.nbUndone != 0 return config.nbUndone != 0
......
...@@ -134,10 +134,10 @@ if __name__ == "__main__" : ...@@ -134,10 +134,10 @@ if __name__ == "__main__" :
tmpDicts = Dicts() tmpDicts = Dicts()
tmpDicts.readConllu(args.corpus, ["UPOS"], 0) tmpDicts.readConllu(args.corpus, ["UPOS"], 0)
tagActions = ["TAG UPOS %s"%p for p in tmpDicts.getElementsOf("UPOS") if "__" not in p and not isEmpty(p)] tagActions = ["TAG UPOS %s"%p for p in tmpDicts.getElementsOf("UPOS") if "__" not in p and not isEmpty(p)]
transitionSets = [[Transition(elem) for elem in tagActions if len(elem) > 0], [Transition(elem) for elem in ["SHIFT","REDUCE","LEFT","RIGHT"] if len(elem) > 0], [Transition("NOBACK"),Transition("NOBACKAB"),Transition("BACK 2")], [Transition(elem) for elem in tagActions if len(elem) > 0], [Transition(elem) for elem in ["SHIFT","REDUCE","LEFT","RIGHT"] if len(elem) > 0]] transitionSets = [[Transition(elem) for elem in tagActions if len(elem) > 0], [Transition(elem) for elem in ["SHIFT","REDUCE","LEFT","RIGHT"] if len(elem) > 0], [Transition("NOBACKBB"),Transition("NOBACKAB"),Transition("BACK 2")], [Transition(elem) for elem in tagActions if len(elem) > 0], [Transition(elem) for elem in ["SHIFT","REDUCE","LEFT","RIGHT"] if len(elem) > 0]]
args.predictedStr = "HEAD,UPOS" args.predictedStr = "HEAD,UPOS"
args.states = ["tagger", "parser", "backer", "taggerReco", "parserReco"] args.states = ["tagger", "parser", "backer", "taggerReco", "parserReco"]
strategy = [{"TAG" : (0,1)}, {"RIGHT" : (1,2), "SHIFT" : (1,2), "LEFT" : (0,1), "REDUCE" : (0,1)}, {"NOBACK" : (0,0), "NOBACKAB" : (0,3)}, {"TAG" : (0,4)}, {"RIGHT" : (1,2), "SHIFT" : (1,2), "LEFT" : (0,4), "REDUCE" : (0,4)}] strategy = [{"TAG" : (0,1)}, {"RIGHT" : (1,2), "SHIFT" : (1,2), "LEFT" : (0,1), "REDUCE" : (0,1)}, {"NOBACKBB" : (0,0), "NOBACKAB" : (0,3)}, {"TAG" : (0,4)}, {"RIGHT" : (1,2), "SHIFT" : (1,2), "LEFT" : (0,4), "REDUCE" : (0,4)}]
probas = [[list(map(float, args.probaRandom.split(','))), list(map(float, args.probaOracle.split(',')))], probas = [[list(map(float, args.probaRandom.split(','))), list(map(float, args.probaOracle.split(',')))],
[list(map(float, args.probaRandom.split(','))), list(map(float, args.probaOracle.split(',')))], [list(map(float, args.probaRandom.split(','))), list(map(float, args.probaOracle.split(',')))],
[list(map(float, args.probaStateBack.split('-')[0].split(','))), list(map(float, args.probaStateBack.split('-')[1].split(',')))], [list(map(float, args.probaStateBack.split('-')[0].split(','))), list(map(float, args.probaStateBack.split('-')[1].split(',')))],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment