Module utilities |
[hide private]
[frames] | no frames]

# Module utilities

source code

Functions | [hide private]
string |
get_classifier(depth, pos_symbol, neg_symbol) Find the symbol for the classifier at given depth. | source code
dict |
dict_difference(dict1, dict2) Difference of two dictionaries. | source code
dict |
dict_sum(dict1, dict2) Sum of two dictionaries. | source code
file handle |
open_file(file) Open a file for reading. | source code
dict |
get_data(file, pos_symbol, neg_symbol) Read data from a file. | source code
list |
get_features(file) Read features from a file. | source code
list |
gen_substrings(data, min_len, max_len) Generate all substrings of given lengths found in data. | source code
number |
log2(x) Logarithm base 2. | source code
number |
signum(x) Signum. | source code
9-`tuple` |
parse_arguments(argv, mdl=True) Parse commant line arguments. | source code
usage(mdl) Print program usage information. | source code
parse_error(err, mdl) Print given parsing error, usage of program and exit. | source code

Function Details | [hide private]

### get_classifier(depth, pos_symbol, neg_symbol) | source code
Find the symbol for the classifier at given depth. Parameters: `depth` (integer) - Depth of rules to classify. `pos_symbol` (string) - Symbol signifying positive example in data. `neg_symbol` (string) - Symbol signifying negative example in data. Returns: string Correct symbol for rule at given depth.

### dict_difference(dict1, dict2) | source code
Difference of two dictionaries. Parameters: `dict1` (dict) `dict2` (dict) Returns: dict data points with their classifications that are contained in dict1, but not in dict2 .

### dict_sum(dict1, dict2) | source code
Sum of two dictionaries. Parameters: `dict1` (dict) `dict2` (dict) Returns: dict data points with their classifications that are contained in at least one of the dictionaries.

### open_file(file) | source code
Open a file for reading. Parameters: `file` (string) - Name of file to open. Returns: file handle Raises: `IOError` - if file cannot be opened.

### get_data(file, pos_symbol, neg_symbol) | source code
Read data from a file. Parameters: `file` (string) - Name of file to read data from. `pos_symbol` (string) - Symbol signifying positive example in data. `neg_symbol` (string) - Symbol signifying negative example in data. Returns: dict data points with their classifications.

### get_features(file) | source code
Read features from a file. Parameters: `file` (string) - Name of file to read features from. Returns: list features.

### gen_substrings(data, min_len, max_len) | source code
Generate all substrings of given lengths found in data. Parameters: `data` (dictionary) - Examples with their classifications. `min_len` (integer) - Minimum length for substrings to be generated. `max_len` (integer) - Maximum length for substrings to be generated. Returns: list substrings of given lengths.

### parse_arguments(argv, mdl=True) | source code
Parse commant line arguments. Parameters: `argv` (`list`) - Command line arguments. `mdl` (boolean) - True, if the arguments are for the MDL-using program. Returns: 9-`tuple` parameters' values

### usage(mdl) | source code
Print program usage information. Parameters: `mdl` (boolean) - True, if the info is about the MDL-using program.

### parse_error(err, mdl) | source code
Print given parsing error, usage of program and exit. Parameters: `mdl` (boolean) - True, if the error is generated by the MDL-using program.