class int, token_indexers: typing.Dict[str,] = None) → None[source]


Reads a single CoNLL-formatted file. This is the same file format as used in the SrlReader, but is preprocessed to dump all documents into a single file per train, dev and test split. See scripts/ for more details of how to pre-process the Ontonotes 5.0 data into the correct format.

Returns a Dataset where the Instances have four fields: text, a TextField containing the full document text, span_starts, a ListField[IndexField] of inclusive start indices for span candidates, span_ends, a ListField[IndexField] of inclusive end indices for span candidates, and metadata, a MetadataField that stores the instance’s original text. For data with gold cluster labels, we also include the original clusters (a list of list of index pairs) and a SequenceLabelField of cluster ids for every span candidate.


max_span_width: ``int``, required.

The maximum width of candidate spans to consider.

token_indexers : Dict[str, TokenIndexer], optional

This is used to index the words in the document. See TokenIndexer. Default is {"tokens": SingleIdTokenIndexer()}.

classmethod from_params(params: allennlp.common.params.Params) →[source]
read(file_path: str)[source]

Actually reads some data from the file_path and returns a Dataset.

text_to_instance(sentences: typing.List[typing.List[str]], gold_clusters: typing.Union[typing.List[typing.List[typing.Tuple[int, int]]], NoneType] = None) →[source]

sentences : List[List[str]], required.

A list of lists representing the tokenised words and sentences in the document.

gold_clusters : Optional[List[List[Tuple[int, int]]]], optional (default = None)

A list of all clusters in the document, represented as word spans. Each cluster contains some number of spans, which can be nested and overlap, but will never exactly match between clusters.


An Instance containing the following Fields:

text : TextField

The text of the full document.

span_starts : ListField[IndexField]

A ListField containing the span starts represented as IndexFields with respect to the document text.

span_ends : ListField[IndexField]

A ListField containing the span ends represented as IndexFields with respect to the document text.

span_labels : SequenceLabelField, optional
The id of the cluster which each possible span belongs to, or -1 if it does

not belong to a cluster. As these labels have variable length (it depends on how many spans we are considering), we represent this a as a SequenceLabelField with respect to the span_starts ListField.