constraints.append( deptree.HasIncomingRel(tokenId, rel, conf)) return domains, constraints def main(options, args): dirOutput, relsOutput, pairsOutput = args[:3] dirStream = open(dirOutput) relsStream = open(relsOutput) pairsStream = open(pairsOutput) dirIterator = instanceIterator(dirStream) relsIterator = instanceIterator(relsStream) pairsIterator = instanceIterator(pairsStream) for sentence in sentenceIterator(fileinput.input(args[3:])): csp = formulateWCSP(sentence, dirIterator, relsIterator, pairsIterator, options) dirStream.close() relsStream.close() pairsStream.close() if __name__ == "__main__": import cmdline main(*cmdline.parse())
# Copyright (c) 2018 Graphcore Ltd. All rights reserved. # see model0.py for a more detailed # description of what's going on. import sys import os import c10driver import popart import cmdline from popart.torch import torchwriter #we require torch in this file to create the torch Module import torch args = cmdline.parse() nInChans = 3 nOutChans = 10 batchSize = 2 batchesPerStep = 4 anchors = { "loss": popart.AnchorReturnType("EveryN", 2), "image0": popart.AnchorReturnType("All") } dataFlow = popart.DataFlow(batchesPerStep, anchors) inputShapeInfo = popart.InputShapeInfo() inputShapeInfo.add("image0", popart.TensorInfo("FLOAT", [batchSize, nInChans, 32, 32])) inputShapeInfo.add("image1", popart.TensorInfo("FLOAT", [batchSize, nInChans, 32, 32])) inputShapeInfo.add("label", popart.TensorInfo("INT32", [batchSize]))
def main(args): import cmdline main_(*cmdline.parse(__doc__, args))
for constraint in constraints: parser.addConstraint(constraint) chart = parser.parse() #item = chart[0, self.numTokens - 1, "r", True] #for token in sentence: # token[DEPREL] = "__" # token[HEAD] = "__" for token in sentence: if len(token) <= DEPREL: token.extend([None, None]) #print chart[0, len(sentence) - 1, "r", True].r + 1 rightComplete(chart, 0, len(sentence) - 1 + 1, sentence) if options.non_projective: approxNonProjective(sentence, parser) for token in sentence: outfile.write( " ".join(map(str, token)) ) outfile.write("\n") # sys.stderr.write(".") if __name__ == "__main__": import cmdline main(*cmdline.parse())
def parse_argv(argv): '''Parse command line arguments. Return dictionary with switch as key.''' try: argdict = cmdline.parse(argv) except cmdline.unknown, option: raise CmdlineException, "Unknown option: %s" % option
def parse_argv(argv): """Parse command line arguments. Return dictionary with switch as key.""" try: argdict = cmdline.parse(argv) except cmdline.unknown, option: raise CmdlineException, "Unknown option: %s" % option