langtest.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])Converts a custom type to a CoNLL string.
to_csv
(sample[, delimiter, temp_id])Converts a NERSample to a CSV string.
- static to_conll(sample: NERSample, temp_id: int | None = None) str | Tuple[str, str] #
Converts a custom type to a CoNLL string.
- Parameters:
sample (NERSample) – The input sample containing the NEROutput object to convert.
writing_mode (str) –
what to do with the expected results if present: - ignore: simply ignores the expected_results - append: the formatted expected_results to the original ones - separate: returns a formatted string for the original sentence and one for
the perturbed sentence
- Returns:
The CoNLL string representation of the custom type.
- static to_csv(sample: NERSample, delimiter: str = ',', temp_id: int | None = None) Tuple[List[str], List[str], List[str], List[str]] #
Converts a NERSample to a CSV string.
- Parameters:
sample (NERSample) – 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[List[str], List[str], List[str], List[str]]