def __init__(self, model): """Create the UDPipe tool object.""" self.model = model path = require_file(model) self.tool = Model.load(path) if not self.tool: raise IOError("Cannot load model from file '%s'" % path) self.error = ProcessingError() self.conllu_reader = ConlluReader() self.tokenizer = self.tool.newTokenizer(Model.DEFAULT)
def setUpClass(cls): cls.doc = Document() cls.data = os.path.join(os.path.dirname(tb2ud.__file__), "../test/data/artificials.conllu") cls._reader = ConlluReader(files=cls.data) cls._reader.apply_on_document(cls.doc) # cls.tree = cls.doc.bundles[0].get_tree() # cls.nodes = cls.tree.descendants cls.writer = ConlluWriter() cls._subtreeconverted = False
def from_conllu_string(self, string): """Load a document from a conllu-formatted string.""" reader = ConlluReader(filehandle=io.StringIO(string)) reader.apply_on_document(self)
def load_conllu(self, filename=None, **kwargs): """Load a document from a conllu-formatted file.""" ConlluReader(files=filename, **kwargs).process_document(self)
def load_conllu(self, filename): """Load a document from a conllu-formatted file.""" reader = ConlluReader(files=filename) reader.process_document(self)
def load_conllu(self, filename=None): """Load a document from a conllu-formatted file.""" reader = ConlluReader(files=filename) reader.apply_on_document(self)