def __init__(self, saved_model_name, threshold_value=85): pass self._instance = POSContextSequenceModeler() coll = saved_model_name.split("/") saved_model_name = coll[-1:][0] self._instance.load_model(name=saved_model_name) self.threshold = threshold_value
def model(self): self.arg_obj.parse(sys.argv) if not self.check_params(): self.show_help() _feature_set_location = self.arg_obj.args["feature_set_location"] if os.path.isfile(_feature_set_location): # if given a file path and not provided the model name to save as if not self.arg_obj.args.has_key("model_name"): self.show_help() _model_name = self.arg_obj.args["model_name"] _instance = POSContextSequenceModeler( feature_set_location=_feature_set_location) _instance.train() _instance.save_model(name=_model_name, location="trained_models") print "ModelingStub: modeling done for given feature set file." if os.path.isdir(_feature_set_location): print "ModelingStub: looking into feature set directory..." # filter only feature set files with .txt extension file_list = [ fn for fn in os.listdir(_feature_set_location) if fn.endswith(('.txt')) ] for _file in file_list: _path = _feature_set_location + "/" + _file _coll = _file.split(".") _model_name = _coll[0] + ".model" _instance = POSContextSequenceModeler( feature_set_location=_path) _instance.train() print "ModelingStub: trained the model.about to save." _instance.save_model(name=_model_name, location="trained_models") print "ModelingStub: modeling done for:", _file print "ModelingStub: modeling done for all files in directory provided."
def __init__(self, saved_model_name): pass self._instance = POSContextSequenceModeler() coll = saved_model_name.split("/") saved_model_name = coll[-1:][0] self._instance.load_model(name=saved_model_name)