Ejemplo n.º 1
0
def main():
    usage = "%prog [options] <old_name> <new_name>"
    description = "Changes the name of a trained Raphsto model"
    parser = OptionParser(usage=usage, description=description)
    options, arguments = parser.parse_args()

    if len(arguments) < 2:
        print "You must specify a model name and a new name"
        sys.exit(1)
    model_name = arguments[0]
    new_name = arguments[1]

    # Check the model exists
    try:
        model = RaphstoHmm.load_model(model_name)
    except RaphstoModelLoadError:
        print "Could not load model %s" % model_name
        sys.exit(1)
    # Change the name of this model and resave it
    model.model_name = new_name
    model.save()
    # Load up the old model again and delete it
    model = RaphstoHmm.load_model(model_name)
    model.delete()
    print "Renamed model %s to %s" % (model_name, new_name)
Ejemplo n.º 2
0
def main():
    usage = "%prog [options] <old_name> <new_name>"
    description = "Changes the name of a trained Raphsto model"
    parser = OptionParser(usage=usage, description=description)
    options, arguments = parser.parse_args()
    
    if len(arguments) < 2:
        print "You must specify a model name and a new name"
        sys.exit(1)
    model_name = arguments[0]
    new_name = arguments[1]
    
    # Check the model exists
    try:
        model = RaphstoHmm.load_model(model_name)
    except RaphstoModelLoadError:
        print "Could not load model %s" % model_name
        sys.exit(1)
    # Change the name of this model and resave it
    model.model_name = new_name
    model.save()
    # Load up the old model again and delete it
    model = RaphstoHmm.load_model(model_name)
    model.delete()
    print "Renamed model %s to %s" % (model_name, new_name)
Ejemplo n.º 3
0
def main():
    usage = "%prog [options] <model-name>"
    description = "Outputs or stores custom description for a trained Raphsto model"
    parser = OptionParser(usage=usage, description=description)
    parser.add_option('-s', '--store', dest="store", action="store_true", help="store a new description from stdin")
    parser.add_option('--silent', dest="silent", action="store_true", help="don't output anything (overridden by --store)")
    options, arguments = parser.parse_args()
    
    if len(arguments) < 1:
        print >>sys.stderr, "You must specify a model name as the first argument"
        sys.exit(1)
    model_name = arguments[0]
    
    # Load the model
    model = RaphstoHmm.load_model(model_name)
    
    if options.store:
        if not options.silent:
            print >>sys.stderr, "Reading new description from stderr"
        # Read from stdin
        desc = "".join(ln for ln in sys.stdin)
        # Use this as the model description
        model.description = desc
        model.save()
    else:
        # Output the description
        if len(model.description):
            print model.description,
Ejemplo n.º 4
0
def main():
    usage = "%prog [options] <model_name>"
    description = "Deletes all the files associated with a trained Raphsto model"
    parser = OptionParser(usage=usage, description=description)
    options, arguments = parser.parse_args()

    if len(arguments) < 1:
        print "You must specify a model name"
        sys.exit(1)
    model_name = arguments[0]

    # Check the model exists
    try:
        model = RaphstoHmm.load_model(model_name)
    except RaphstoModelLoadError:
        print "Could not load model %s" % model_name
        sys.exit(1)
    model.delete()
    print "Deleted model %s" % model_name
Ejemplo n.º 5
0
def main():
    usage = "%prog [options] <model_name>"
    description = "Deletes all the files associated with a trained Raphsto model"
    parser = OptionParser(usage=usage, description=description)
    options, arguments = parser.parse_args()
    
    if len(arguments) < 1:
        print "You must specify a model name"
        sys.exit(1)
    model_name = arguments[0]
    
    # Check the model exists
    try:
        model = RaphstoHmm.load_model(model_name)
    except RaphstoModelLoadError:
        print "Could not load model %s" % model_name
        sys.exit(1)
    model.delete()
    print "Deleted model %s" % model_name