示例#1
0
 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
示例#3
0
 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)
示例#4
0
 def load_conllu(self, filename=None, **kwargs):
     """Load a document from a conllu-formatted file."""
     ConlluReader(files=filename, **kwargs).process_document(self)
示例#5
0
 def load_conllu(self, filename):
     """Load a document from a conllu-formatted file."""
     reader = ConlluReader(files=filename)
     reader.process_document(self)
示例#6
0
 def load_conllu(self, filename=None):
     """Load a document from a conllu-formatted file."""
     reader = ConlluReader(files=filename)
     reader.apply_on_document(self)