def network_init(save_dir, **kwargs): kwargs['config_file'] = os.path.join(save_dir, 'config.cfg') short = kwargs.pop('short', False) if short: kwargs['config_file'] = os.path.join(save_dir, 'config_short.cfg') kwargs['is_evaluation'] = True network = Network(**kwargs) return network
def __init__(self, parserpath, savedir): self.savedir = savedir self.parserpath = parserpath self.kwargs = {} # Parser configuration file configfilepath = self.parserpath + '/' + self.savedir + '/config.cfg' self.kwargs['config_file'] = configfilepath # Pre-trained parser model self.kwargs['default'] = {'save_dir': self.parserpath + '/' + self.savedir} self.kwargs['is_evaluation'] = True self.network = Network(**self.kwargs)
def parse(save_dir, **kwargs): """""" kwargs['config_file'] = os.path.join(save_dir, 'config.cfg') files = kwargs.pop('files') output_file = kwargs.pop('output_file', None) output_dir = kwargs.pop('output_dir', None) if len(files) > 1 and output_file is not None: raise ValueError('Cannot provide a value for --output_file when parsing multiple files') kwargs['is_evaluation'] = True network = Network(**kwargs) network.parse(files, output_file=output_file, output_dir=output_dir) return
def train(save_dir, **kwargs): """""" kwargs['config_file'] = kwargs.pop('config_file', '') load = kwargs.pop('load') try: if not load and os.path.isdir(save_dir): raw_input('Save directory already exists. Press <Enter> to continue or <Ctrl-c> to abort.') if os.path.isfile(os.path.join(save_dir, 'config.cfg')): os.remove(os.path.join(save_dir, 'config.cfg')) except KeyboardInterrupt: print() sys.exit(0) network = Network(**kwargs) network.train(load=load) return
def train(save_dir, **kwargs): """""" load = kwargs.pop('load') try: if not load and os.path.isdir(save_dir): raw_input( 'Save directory already exists. Press <Enter> to continue or <Ctrl-c> to abort.' ) if os.path.isfile(os.path.join(save_dir, 'config.cfg')): os.remove(os.path.join(save_dir, 'config.cfg')) except KeyboardInterrupt: sys.exit(0) #print (kwargs) #print ("train files:",kwargs['train_files']) print("initializing") network = Network(**kwargs) print("initialized") network.train(load=load) return