langtest.datahandler.format.Formatter#

class Formatter#

Bases: object

Formatter class for converting between custom types and different output formats.

This class uses the to_csv and to_conll methods of subclasses of BaseFormatter to perform the conversions. The appropriate subclass is selected based on the type of the expected results in the sample argument.

__init__()#

Methods

__init__()

process(sample, output_format, *args, **kwargs)

Method to format the sample into the desired format

static process(sample: Sample, output_format: str, *args, **kwargs)#

Method to format the sample into the desired format

Parameters:
  • sample (Sample) – The input sample to convert.

  • output_format (str) – The output format to convert to, either “csv” or “conll”.

  • *args – Optional positional arguments to pass to the to_csv or to_conll methods.

  • **kwargs – Optional keyword arguments to pass to the to_csv or to_conll methods.

Returns:

The output string in the specified format.

Raises:

NameError – If no formatter subclass is defined for the type of the expected results in the sample.