nlptest.datahandler.format.NEROutputFormatter#
- class NEROutputFormatter#
Bases:
BaseFormatter
Formatter class for converting NEROutput objects to CSV and CoNLL.
The to_csv method returns a CSV string representing the NEROutput object in the sample argument. The to_conll method returns a CoNLL string representing the NEROutput object.
- __init__()#
Methods
__init__
()to_conll
(sample[, temp_id])- param sample:
The input sample containing the NEROutput object to convert.
to_csv
(sample[, delimiter, temp_id])- param sample:
The input sample containing the NEROutput object to convert.
- static to_conll(sample: Sample, temp_id: int | None = None) Tuple[str, int] #
- Parameters:
sample (Sample) – The input sample containing the NEROutput object to convert.
temp_id (int) – A temporary ID to use for grouping entities by document.
- Returns:
The CoNLL string representation of the custom type.
- static to_csv(sample: Sample, delimiter: str = ',', temp_id: int | None = None) Tuple[str, int] #
- Parameters:
sample (Sample) – The input sample containing the NEROutput object to convert.
delimiter (str) – The delimiter character to use in the CSV string.
temp_id (int) – A temporary ID to use for grouping entities by document.
- Returns:
The CSV or CoNLL string representation of the NEROutput object along with the document id
- Return type:
Tuple[str, int]