conll

A collection of CoNLL annotated sentences. This collection should rarely be created by API callers, that is what the pyconll.load module is for which allows for easy APIs to load CoNLL files from a string or file (no network yet). The Conll object can be thought of as a simple list of sentences. There is very little more of a wrapper around this.

API

class pyconll.unit.conll.Conll(it)[source]

The abstraction for a CoNLL-U file. A CoNLL-U file is more or less just a collection of sentences in order. These sentences can be accessed by sentence id or by numeric index. Note that sentences must be separated by whitespace. CoNLL-U also specifies that the file must end in a new line but that requirement is relaxed here in parsing.

append(sent)[source]

Add the given sentence to the end of this Conll object.

Args: sent: The Sentence object to add.

conll()[source]

Output the Conll object to a CoNLL-U formatted string.

Returns: The CoNLL-U object as a string. This string will end in a newline.

insert(index, sent)[source]

Insert the given sentence into the given location.

This function behaves in the same way as python lists insert.

Args: index: The numeric index to insert the sentence into. sent: The sentence to insert.

write(writable)[source]

Write the Conll object to something that is writable.

For simply writing, this method is more efficient than calling conll then writing since no string of the entire Conll object is created. The final output will include a final newline.

Args: writable: The writable object such as a file. Must have a write method.