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

Added program argument --ts to specify back actions

parent 157585cf
No related branches found
No related tags found
No related merge requests found
......@@ -4,12 +4,11 @@ from Util import isEmpty
################################################################################
class Transition :
available = set({"RIGHT", "LEFT", "SHIFT", "REDUCE", "EOS", "BACK 2"})
available = lambda self,x: x in {"RIGHT", "LEFT", "SHIFT", "REDUCE", "EOS"} or ("BACK" in x and len(x.split()) == 2)
def __init__(self, name) :
if name not in self.available :
print("'%s' is not a valid transition type."%name, file=sys.stdout)
exit(1)
if not self.available(name) :
raise(Exception("'%s' is not a valid transition type."%name))
self.name = name
def __lt__(self, other) :
......
......@@ -36,6 +36,8 @@ if __name__ == "__main__" :
help="Print debug infos on stderr.")
parser.add_argument("--silent", "-s", default=False, action="store_true",
help="Don't print advancement infos.")
parser.add_argument("--ts", default="",
help="Comma sepaarated list of supplementary transitions. Example \"BACK 1,BACK 2\"")
args = parser.parse_args()
if args.debug :
......@@ -51,7 +53,7 @@ if __name__ == "__main__" :
if args.bootstrap is not None :
args.bootstrap = int(args.bootstrap)
transitionSet = [Transition(elem) for elem in ["RIGHT", "LEFT", "SHIFT", "REDUCE", "BACK 2"]]
transitionSet = [Transition(elem) for elem in (["SHIFT","REDUCE","LEFT","RIGHT"]+args.ts.split(',')) if len(elem) > 0]
strategy = {"RIGHT" : 1, "SHIFT" : 1, "LEFT" : 0, "REDUCE" : 0}
if args.mode == "train" :
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment