|
Baby Language Lab Scripts
A collection of data processing tools.
|
This OutputCalc searches for a regex match in a segment/chain phrase and counts the number of matches. More...

Public Member Functions | |
| def | __init__ |
| Constructor. More... | |
| def | reset |
| See superclass description. More... | |
| def | get_db_args |
| See superclass description. More... | |
| def | get_calc_type_str |
| See superclass description. More... | |
| def | add_seg |
| See superclass description. More... | |
| def | add_chain |
| See superclass description. More... | |
| def | write_csv_rows |
| See superclass description. More... | |
Public Member Functions inherited from data_structs.output_calcs.OutputCalc | |
| def | __init__ |
| Constructor. More... | |
| def | get_db_args |
| Retreives an ordered list of args needed to instantiate this object these will be inserted into the DB. More... | |
| def | get_calc_type_str |
| Retreives a short description string that indicates what type of calculation this object is performing (eg. More... | |
| def | add_seg |
| Adds an unlinked segment to be considered in the calculations that this object is performing. More... | |
| def | add_chain |
| Adds a linked segment (i.e. More... | |
| def | write_csv_rows |
| Writes a short description of the calculation, along with the calculation results, to a csv file. More... | |
| def | reset |
| This method clears any cached data from previous run (anything added by add_seg() or add_chain()), in preparation for new run. 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... | |
Public Attributes | |
| logger | |
| search_term | |
| count_type | |
| max_count | |
| utter_dict | |
| chain_dict | |
Static Public Attributes | |
| COUNT_TYPES = None | |
Private Member Functions | |
| def | _init_data_structs |
| Initializes internal data structures used to record items added to this OutputCalc. More... | |
| def | _write_per_seg |
| Writes out the count results for a 'per item' count. More... | |
| def | _write_avg_across_segs |
| Writes out the count results for an 'average across items' count. More... | |
| def | _write_sum_across_segs |
| Writes out the count results for a 'sum across items' count. More... | |
This OutputCalc searches for a regex match in a segment/chain phrase and counts the number of matches.
The counting can be done on a per-item basis, as an average across items, or as a sum across items.
Definition at line 60 of file output_calcs.py.
| def data_structs.output_calcs.CountOutputCalc.__init__ | ( | self, | |
| search_term, | |||
| count_type, | |||
max_count = -1 |
|||
| ) |
Constructor.
| self | |
| search_term | (string) a Python regular expression to search for in the phrase |
| count_type | (int) one of the values from the CountOutputCalc.COUNT_TYPES enum - specifies how it count (per item, avg across items, or sum across items) |
| max_count | (int=-1) a maximum threshold for the matches (-1 means no threshold) that an individual item can have. |
Definition at line 69 of file output_calcs.py.
|
private |
Initializes internal data structures used to record items added to this OutputCalc.
| self |
Definition at line 78 of file output_calcs.py.
|
private |
Writes out the count results for an 'average across items' count.
This consists of a single row with the average count. The average calculation is computed as (sum of counts from all items) / number of items containing a match< >)
| self | |
| chained | (boolean) True if we are considering linked segments, False if unlinked. |
| csv_writer | (CSVWriter) Python csv library writer object, set to write to the appropriate csv file. |
Definition at line 190 of file output_calcs.py.
|
private |
Writes out the count results for a 'per item' count.
This consists of a single line for each item, followed by its count. The total count is displayed in a row at the bottom of the section.
| self | |
| chained | (boolean) True if we are considering linked segments, False if unlinked. |
| csv_writer | (CSVWriter) Python csv library writer object, set to write to the appropriate csv file. |
Definition at line 142 of file output_calcs.py.
|
private |
Writes out the count results for a 'sum across items' count.
This consists of single row with the total sum.
| self | |
| chained | (boolean) True if we are considering linked segments, False if unlinked. |
| csv_writer | (CSVWriter) Python csv library writer object, set to write to the appropriate csv file. |
Definition at line 205 of file output_calcs.py.
| def data_structs.output_calcs.CountOutputCalc.add_chain | ( | self, | |
| head | |||
| ) |
See superclass description.
Definition at line 115 of file output_calcs.py.
| def data_structs.output_calcs.CountOutputCalc.add_seg | ( | self, | |
| seg | |||
| ) |
See superclass description.
Definition at line 96 of file output_calcs.py.
| def data_structs.output_calcs.CountOutputCalc.get_calc_type_str | ( | self | ) |
See superclass description.
Definition at line 92 of file output_calcs.py.
| def data_structs.output_calcs.CountOutputCalc.get_db_args | ( | self | ) |
See superclass description.
Definition at line 88 of file output_calcs.py.
| def data_structs.output_calcs.CountOutputCalc.reset | ( | self | ) |
See superclass description.
Definition at line 83 of file output_calcs.py.
| def data_structs.output_calcs.CountOutputCalc.write_csv_rows | ( | self, | |
| chained, | |||
| csv_writer | |||
| ) |
See superclass description.
Definition at line 212 of file output_calcs.py.
| data_structs.output_calcs.CountOutputCalc.chain_dict |
Definition at line 80 of file output_calcs.py.
| data_structs.output_calcs.CountOutputCalc.count_type |
Definition at line 72 of file output_calcs.py.
|
static |
Definition at line 62 of file output_calcs.py.
| data_structs.output_calcs.CountOutputCalc.logger |
Definition at line 70 of file output_calcs.py.
| data_structs.output_calcs.CountOutputCalc.max_count |
Definition at line 73 of file output_calcs.py.
| data_structs.output_calcs.CountOutputCalc.search_term |
Definition at line 71 of file output_calcs.py.
| data_structs.output_calcs.CountOutputCalc.utter_dict |
Definition at line 79 of file output_calcs.py.