flatten
This module provides a method for flattening JSON files from emtelliPro, in a
similar method to emtellipro-flatten-json.
Examples:
Simple usage involves reading a JSON file, and saving the documents contained within to a TSV file.
However, if you prefer to work with Pandas DataFrames, you can iterate over the tables and convert them to dataframes.
Module Contents
Classes
API
emtellipro.flatten.Flattener
Bases: object
Flattens annotated documents from emtelliPro into a set of tables.
Initialization
Parameters:
- include: A list of extra columns to include when generating the flattened tables. document_id The ID of the document containg each item. spans The character spans for each item. spans_in_sentences The character spans for each item, adjusted to be relative to the containing sentence.
Flattener.add
Add documents to the flattener.
Parameters:
Annotated documents.
Flattener.flatten
Flatten the documents into tables.
Returns:
The flattened tables.
Return type: Tables
emtellipro.flatten.Tables
Bases: object
The flattened tables, produced by Flattener.flatten.
This class should not be instantiated by user code.
Examples:
This table can be iterated over, which is helpful for storing to custom file paths, or for converting the table to a pandas DataFrame.
Initialization
Parameters:
- tables: The tables (internal data structure).
Tables.names
A list of all the table names.
Tables.__iter__
Iterate over tuples containing the table name, and Table
instance.
Tables.write
Write the tables to the given output directory.
Parameters:
Path to directory where to store the flattened files.
The format for the flattened files. May be tsv, json,
and jsonl.
Separator for values in multi-valued attribute or argument fields in output formats that flatten field values to text.
Replace whitespace in text fields with visual marker characters.
emtellipro.flatten.Table
Bases: object
A single table in a Tables collection.
Initialization
Parameters:
- items: The items in the table (private data structure).
Table.write
Write the table to the given output file.
Parameters:
The path of the file in which to save the data.
The format for the flattened files. May be tsv, json,
and jsonl.
Separator for values in multi-valued attribute or argument fields in output formats that flatten field values to text.
Replace whitespace in text fields with visual marker characters.
Table.to_df
Return a pandas DataFrame containing the data.
Parameters:
Separator for values in multi-valued attribute or argument fields in output formats that flatten field values to text.
Replace whitespace in text fields with visual marker characters.

