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
class UnstableParser: """ Perform parsing using the UnstableParser (universal dependency parser """ 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(self, outputdir, files): """ Parse the files using a pre-trained UnstableParser model """ self.network.parse(files, output_dir=outputdir)