Baby Language Lab Scripts
A collection of data processing tools.
 All Classes Namespaces Files Functions Variables Pages
data_structs.output.Output Class Reference

An Output represents particular statistic that the user is trying to calculate from a TRS file. More...

Inheritance diagram for data_structs.output.Output:

Public Member Functions

def __init__
 Constructor. More...
 
def reset
 Clears any cached utterances in preparation for a new run. More...
 
def add_item
 Accepts a segment/chain, filters it, and (if it passes through the filters) factors it into this output's calculations. More...
 
def get_filtered_items
 Grabs a list of all items that have been added to this Output that have passed through the filters. More...
 
def db_insert
 See superclass description. More...
 
def db_delete
 
def write_csv_rows
 Writes a description of this output, and the calculated information from this output, to a CSV file. More...
 
- Public Member Functions inherited from data_structs.base_objects.DBObject
def __init__
 Constructor. More...
 
def db_insert
 Performs operations needed to insert this object into the database. More...
 
def db_delete
 Performs operations needed to delete this object from the database. More...
 
- Public Member Functions inherited from data_structs.base_objects.BLLObject
def __str__
 Builds a nicely formatted string containing all attributes of this object (except those in omit_attr_names), for debugging purposes. More...
 

Static Public Member Functions

def db_select
 See superclass description. More...
 
def db_select_by_ref
 Selects Outputs via a relationship table (a table linking output ids to some other type of id). More...
 
- Static Public Member Functions inherited from data_structs.base_objects.DBObject
def db_select
 Selects objects of this type from the database. More...
 

Public Attributes

 name
 
 desc
 
 filters
 
 output_calc
 
 chained
 
 db_id
 
 segs
 
 chains
 
- Public Attributes inherited from data_structs.base_objects.DBObject
 db_id
 

Private Member Functions

def _add_seg
 Adds an unlinked segment to this Output, if it passes through the filters. More...
 
def _add_chain
 Adds chain (an Utterance) to this Output, if it passes through the filters. More...
 

Detailed Description

An Output represents particular statistic that the user is trying to calculate from a TRS file.

It is used in the Statistics Application. Each Output corresponds to a single Configuration object. Configurations can have multiple Outputs. The exported spreadsheet constains a single section for each Output in the selected Configuration. Calling code should instantiate this object, then use it's add_item() method to pass in segments/chains that it want's included in this output's calculations.

Definition at line 11 of file output.py.

Constructor & Destructor Documentation

def data_structs.output.Output.__init__ (   self,
  name,
  desc,
  filters,
  output_calc,
  chained,
  db_id = None 
)

Constructor.

Parameters
self
name(string) the user-specified name for this output
desc(string) the user-specified description for this output
filters(list) list of SegFilter objects to apply to data that is inserted into this Output
output_calc(OutputCalc) an object used to perform any arithmetic/processing needed to generate this output's section in the spreadsheet file
chained(boolean) True if we're using linked segments, False if we're using unlinked segments
db_id(int=None) database primary key value for this object - code should not set, it's set via db_insert() and db_select(). A value of None indicates that this Output is not in the database.

Definition at line 20 of file output.py.

Member Function Documentation

def data_structs.output.Output._add_chain (   self,
  head 
)
private

Adds chain (an Utterance) to this Output, if it passes through the filters.

Parameters
self
head(Utterance) the Utterance (head of the chain) to add

Definition at line 72 of file output.py.

def data_structs.output.Output._add_seg (   self,
  seg,
  filter_utters = False 
)
private

Adds an unlinked segment to this Output, if it passes through the filters.

Parameters
self
seg(Segment) the Segment object to add
filter_utters(boolean=False) see description for add_item()

Definition at line 56 of file output.py.

def data_structs.output.Output.add_item (   self,
  item,
  filter_utters = False 
)

Accepts a segment/chain, filters it, and (if it passes through the filters) factors it into this output's calculations.

Parameters
self
item(Segment / Utterance) the data object to add to this output. If chained is set to True, this should be an Utterance object (potentially linked to other Utterance objects via its 'next'/'prev' pointers). If chained is False, this should be a Segment object.
filter_utters(boolean=False) If True, and chained == False, then any utterances that don't pass the filter will be stripped out of the segments passed in (but the segment itself will still be included if it has other utterances. If False, and chained == False, then it the segment that's passed in has any utterance that fails to pass the filter, the whole segment will be excluded. If chained == True, the setting of this parameter has no effect (in all cases, if one node in the chain fails to pass the filter, the whole chain is excluded - conceptually, chains are treated as a single, long Utterance).

Definition at line 44 of file output.py.

def data_structs.output.Output.db_delete (   self,
  db 
)

Definition at line 117 of file output.py.

def data_structs.output.Output.db_insert (   self,
  db 
)

See superclass description.

Definition at line 92 of file output.py.

def data_structs.output.Output.db_select (   db,
  ids = [] 
)
static

See superclass description.

Definition at line 163 of file output.py.

def data_structs.output.Output.db_select_by_ref (   db,
  ref_table,
  id_col,
  ref_col,
  ref_val 
)
static

Selects Outputs via a relationship table (a table linking output ids to some other type of id).

Parameters
db(BLLDatabase) a database handle object to use for the select operation
ref_table(string) the name of the relationship table to use
id_col(string) name of the column (in ref_table) containing output
ref_col(string) name of the column (in ref table) containing the value you want to look up outputs by
ref_val(int) value to search for in ref_col. For each matching row, the id_col value is obtained (this is the output id), and used to do a lookup in the outputs table.
Returns
(list) list of Output objects, or empty list if no matches were found for ref_val in ref_col of ref_table

Definition at line 211 of file output.py.

def data_structs.output.Output.get_filtered_items (   self)

Grabs a list of all items that have been added to this Output that have passed through the filters.

Parameters
self
Returns
(list) list of Utterances, if chained. Otherwise list of Segments.

Definition at line 88 of file output.py.

def data_structs.output.Output.reset (   self)

Clears any cached utterances in preparation for a new run.

Parameters
self

Definition at line 34 of file output.py.

def data_structs.output.Output.write_csv_rows (   self,
  csv_writer 
)

Writes a description of this output, and the calculated information from this output, to a CSV file.

Parameters
self
csv_writer(CSVWriter) this is a Python csv library writer objects, configured to write to the appropriate csv file.

Definition at line 140 of file output.py.

Member Data Documentation

data_structs.output.Output.chained

Definition at line 25 of file output.py.

data_structs.output.Output.chains

Definition at line 30 of file output.py.

data_structs.output.Output.db_id

Definition at line 26 of file output.py.

data_structs.output.Output.desc

Definition at line 22 of file output.py.

data_structs.output.Output.filters

Definition at line 23 of file output.py.

data_structs.output.Output.name

Definition at line 21 of file output.py.

data_structs.output.Output.output_calc

Definition at line 24 of file output.py.

data_structs.output.Output.segs

Definition at line 29 of file output.py.


The documentation for this class was generated from the following file: