diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/documentations/api.pdf b/documentations/api.pdf new file mode 100644 index 0000000000000000000000000000000000000000..84da5bcbe62db795c75da469bb83c323575dfaed Binary files /dev/null and b/documentations/api.pdf differ diff --git a/documentations/manual.pdf b/documentations/manual.pdf new file mode 100644 index 0000000000000000000000000000000000000000..6a6761c97fdc8c89d79fd06283f12897cf34fafa Binary files /dev/null and b/documentations/manual.pdf differ diff --git a/documentations/papers/ideal2005probabilistic.pdf b/documentations/papers/ideal2005probabilistic.pdf new file mode 100644 index 0000000000000000000000000000000000000000..4bcc14e8e9ec344665bd18e5a4ee58d3f71b4c36 Binary files /dev/null and b/documentations/papers/ideal2005probabilistic.pdf differ diff --git a/documentations/papers/padm2006privacy.pdf b/documentations/papers/padm2006privacy.pdf new file mode 100644 index 0000000000000000000000000000000000000000..11936753018eded899d5218005d41f9f6ac41e90 Binary files /dev/null and b/documentations/papers/padm2006privacy.pdf differ diff --git a/documentations/papers/pakdd2009accurate.pdf b/documentations/papers/pakdd2009accurate.pdf new file mode 100644 index 0000000000000000000000000000000000000000..f81320121816dfe72bdf95ee75958f26636248f0 Binary files /dev/null and b/documentations/papers/pakdd2009accurate.pdf differ diff --git a/documentations/papers/sigkddexp2009febrl.pdf b/documentations/papers/sigkddexp2009febrl.pdf new file mode 100644 index 0000000000000000000000000000000000000000..5ed2da3cf09ecf8868c7d1666da245df5bfa6f30 Binary files /dev/null and b/documentations/papers/sigkddexp2009febrl.pdf differ diff --git a/examples/generate-data-english.py b/examples/generate-data-english.py new file mode 100644 index 0000000000000000000000000000000000000000..dc9cec4c4f02de06f4cba45e8691cfe89955a0be --- /dev/null +++ b/examples/generate-data-english.py @@ -0,0 +1,330 @@ +from geco_data_generator import (attrgenfunct, basefunctions, contdepfunct, generator, corruptor) +import random +random.seed(42) + +# Set the Unicode encoding for this data generation project. This needs to be +# changed to another encoding for different Unicode character sets. +# Valid encoding strings are listed here: +# http://docs.python.org/library/codecs.html#standard-encodings +# +unicode_encoding_used = 'ascii' + +# The name of the record identifier attribute (unique value for each record). +# This name cannot be given as name to any other attribute that is generated. +# +rec_id_attr_name = 'rec-id' + +# Set the file name of the data set to be generated (this will be a comma +# separated values, CSV, file). +# +out_file_name = 'example-data-english.csv' + +# Set how many original and how many duplicate records are to be generated. +# +num_org_rec = 5_000_000 +num_dup_rec = 100_000 + +# Set the maximum number of duplicate records can be generated per original +# record. +# +max_duplicate_per_record = 3 + +# Set the probability distribution used to create the duplicate records for one +# original record (possible values are: 'uniform', 'poisson', 'zipf'). +# +num_duplicates_distribution = 'zipf' + +# Set the maximum number of modification that can be applied to a single +# attribute (field). +# +max_modification_per_attr = 1 + +# Set the number of modification that are to be applied to a record. +# +num_modification_per_record = 5 + +# Check if the given the unicode encoding selected is valid. +# +basefunctions.check_unicode_encoding_exists(unicode_encoding_used) + +# ----------------------------------------------------------------------------- +# Define the attributes to be generated (using methods from the generator.py +# module). +# +gname_attr = generator.GenerateFreqAttribute( + attribute_name='given-name', + freq_file_name='givenname_f_freq.csv', + has_header_line=False, + unicode_encoding=unicode_encoding_used, +) + +sname_attr = generator.GenerateFreqAttribute( + attribute_name='surname', + freq_file_name='surname-freq.csv', + has_header_line=False, + unicode_encoding=unicode_encoding_used, +) + +postcode_attr = generator.GenerateFreqAttribute( + attribute_name='postcode', + freq_file_name='postcode_act_freq.csv', + has_header_line=False, + unicode_encoding=unicode_encoding_used, +) + +phone_num_attr = generator.GenerateFuncAttribute( + attribute_name='telephone-number', + function=attrgenfunct.generate_phone_number_australia, +) + +credit_card_attr = generator.GenerateFuncAttribute( + attribute_name='credit-card-number', function=attrgenfunct.generate_credit_card_number +) + +age_uniform_attr = generator.GenerateFuncAttribute( + attribute_name='age-uniform', + function=attrgenfunct.generate_uniform_age, + parameters=[0, 120], +) + +income_normal_attr = generator.GenerateFuncAttribute( + attribute_name='income-normal', + function=attrgenfunct.generate_normal_value, + parameters=[50000, 20000, 0, 1000000, 'float2'], +) + +rating_normal_attr = generator.GenerateFuncAttribute( + attribute_name='rating-normal', + function=attrgenfunct.generate_normal_value, + parameters=[0.0, 1.0, None, None, 'float9'], +) + +gender_city_comp_attr = generator.GenerateCateCateCompoundAttribute( + categorical1_attribute_name='gender', + categorical2_attribute_name='city', + lookup_file_name='gender-city.csv', + has_header_line=True, + unicode_encoding='ascii', +) + +sex_income_comp_attr = generator.GenerateCateContCompoundAttribute( + categorical_attribute_name='sex', + continuous_attribute_name='income', + continuous_value_type='float1', + lookup_file_name='gender-income.csv', + has_header_line=False, + unicode_encoding='ascii', +) + +gender_town_salary_comp_attr = generator.GenerateCateCateContCompoundAttribute( + categorical1_attribute_name='alternative-gender', + categorical2_attribute_name='town', + continuous_attribute_name='salary', + continuous_value_type='float4', + lookup_file_name='gender-city-income.csv', + has_header_line=False, + unicode_encoding='ascii', +) + +age_blood_pressure_comp_attr = generator.GenerateContContCompoundAttribute( + continuous1_attribute_name='age', + continuous2_attribute_name='blood-pressure', + continuous1_funct_name='uniform', + continuous1_funct_param=[10, 110], + continuous2_function=contdepfunct.blood_pressure_depending_on_age, + continuous1_value_type='int', + continuous2_value_type='float3', +) + +age_salary_comp_attr = generator.GenerateContContCompoundAttribute( + continuous1_attribute_name='age2', + continuous2_attribute_name='salary2', + continuous1_funct_name='normal', + continuous1_funct_param=[45, 20, 15, 130], + continuous2_function=contdepfunct.salary_depending_on_age, + continuous1_value_type='int', + continuous2_value_type='float1', +) + +# ----------------------------------------------------------------------------- +# Define how the generated records are to be corrupted (using methods from +# the corruptor.py module). + +# For a value edit corruptor, the sum or the four probabilities given must +# be 1.0. +# +edit_corruptor = corruptor.CorruptValueEdit( + position_function=corruptor.position_mod_normal, + char_set_funct=basefunctions.char_set_ascii, + insert_prob=0.5, + delete_prob=0.5, + substitute_prob=0.0, + transpose_prob=0.0, +) + +edit_corruptor2 = corruptor.CorruptValueEdit( + position_function=corruptor.position_mod_uniform, + char_set_funct=basefunctions.char_set_ascii, + insert_prob=0.25, + delete_prob=0.25, + substitute_prob=0.25, + transpose_prob=0.25, +) + +surname_misspell_corruptor = corruptor.CorruptCategoricalValue( + lookup_file_name='surname-misspell.csv', + has_header_line=False, + unicode_encoding=unicode_encoding_used, +) + +ocr_corruptor = corruptor.CorruptValueOCR( + position_function=corruptor.position_mod_normal, + lookup_file_name='ocr-variations.csv', + has_header_line=False, + unicode_encoding=unicode_encoding_used, +) + +keyboard_corruptor = corruptor.CorruptValueKeyboard( + position_function=corruptor.position_mod_normal, row_prob=0.5, col_prob=0.5 +) + +phonetic_corruptor = corruptor.CorruptValuePhonetic( + lookup_file_name='phonetic-variations.csv', + has_header_line=False, + unicode_encoding=unicode_encoding_used, +) + +missing_val_corruptor = corruptor.CorruptMissingValue() + +postcode_missing_val_corruptor = corruptor.CorruptMissingValue(missing_val='missing') + +given_name_missing_val_corruptor = corruptor.CorruptMissingValue(missing_value='unknown') + +# ----------------------------------------------------------------------------- +# Define the attributes to be generated for this data set, and the data set +# itself. +# +attr_name_list = [ + 'gender', + 'given-name', + 'surname', + 'postcode', + 'city', + 'telephone-number', + 'credit-card-number', + 'income-normal', + 'age-uniform', + 'income', + 'age', + 'sex', + 'blood-pressure', +] + +attr_data_list = [ + gname_attr, + sname_attr, + postcode_attr, + phone_num_attr, + credit_card_attr, + age_uniform_attr, + income_normal_attr, + gender_city_comp_attr, + sex_income_comp_attr, + gender_town_salary_comp_attr, + age_blood_pressure_comp_attr, + age_salary_comp_attr, +] + +# Nothing to change here - set-up the data set generation object. +# +test_data_generator = generator.GenerateDataSet( + output_file_name=out_file_name, + write_header_line=True, + rec_id_attr_name=rec_id_attr_name, + number_of_records=num_org_rec, + attribute_name_list=attr_name_list, + attribute_data_list=attr_data_list, + unicode_encoding=unicode_encoding_used, +) + +# Define the probability distribution of how likely an attribute will be +# selected for a modification. +# Each of the given probability values must be between 0 and 1, and the sum of +# them must be 1.0. +# If a probability is set to 0 for a certain attribute, then no modification +# will be applied on this attribute. +# +attr_mod_prob_dictionary = { + 'gender': 0.1, + 'given-name': 0.2, + 'surname': 0.2, + 'postcode': 0.1, + 'city': 0.1, + 'telephone-number': 0.15, + 'credit-card-number': 0.1, + 'age': 0.05, +} + +# Define the actual corruption (modification) methods that will be applied on +# the different attributes. +# For each attribute, the sum of probabilities given must sum to 1.0. +# +attr_mod_data_dictionary = { + 'gender': [(1.0, missing_val_corruptor)], + 'surname': [ + (0.1, surname_misspell_corruptor), + (0.1, ocr_corruptor), + (0.1, keyboard_corruptor), + (0.7, phonetic_corruptor), + ], + 'given-name': [ + (0.1, edit_corruptor2), + (0.1, ocr_corruptor), + (0.1, keyboard_corruptor), + (0.7, phonetic_corruptor), + ], + 'postcode': [(0.8, keyboard_corruptor), (0.2, postcode_missing_val_corruptor)], + 'city': [ + (0.1, edit_corruptor), + (0.1, missing_val_corruptor), + (0.4, keyboard_corruptor), + (0.4, phonetic_corruptor), + ], + 'age': [(1.0, edit_corruptor2)], + 'telephone-number': [(1.0, missing_val_corruptor)], + 'credit-card-number': [(1.0, edit_corruptor)], +} + +# Nothing to change here - set-up the data set corruption object +# +test_data_corruptor = corruptor.CorruptDataSet( + number_of_org_records=num_org_rec, + number_of_mod_records=num_dup_rec, + attribute_name_list=attr_name_list, + max_num_dup_per_rec=max_duplicate_per_record, + num_dup_dist=num_duplicates_distribution, + max_num_mod_per_attr=max_modification_per_attr, + num_mod_per_rec=num_modification_per_record, + attr_mod_prob_dict=attr_mod_prob_dictionary, + attr_mod_data_dict=attr_mod_data_dictionary, +) + +# ============================================================================= +# No need to change anything below here + +# Start the data generation process +# +rec_dict = test_data_generator.generate() + +assert len(rec_dict) == num_org_rec # Check the number of generated records + +# Corrupt (modify) the original records into duplicate records +# +rec_dict = test_data_corruptor.corrupt_records(rec_dict) + +assert len(rec_dict) == num_org_rec + num_dup_rec # Check total number of records + +# Write generate data into a file +# +test_data_generator.write() + diff --git a/examples/generate-data-japanese.py b/examples/generate-data-japanese.py new file mode 100644 index 0000000000000000000000000000000000000000..db059278a95954d138fc3af3b337d2d2dc406e15 --- /dev/null +++ b/examples/generate-data-japanese.py @@ -0,0 +1,185 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +from geco_data_generator import basefunctions, attrgenfunct, contdepfunct, generator, corruptor +import random +random.seed(42) + + +# Set the Unicode encoding for this data generation project. This needs to be +# changed to another encoding for different Unicode character sets. +# Valid encoding strings are listed here: +# http://docs.python.org/library/codecs.html#standard-encodings +# +unicode_encoding_used = 'cp932' + +# The name of the record identifier attribute (unique value for each record). +# This name cannot be given as name to any other attribute that is generated. +# +rec_id_attr_name = 'rec-id' + +# Set the file name of the data set to be generated (this will be a comma +# separated values, CSV, file). +# +out_file_name = 'example-data-japanese.csv' + +# Set how many original and how many duplicate records are to be generated. +# +num_org_rec = 10000 +num_dup_rec = 10000 + +# Set the maximum number of duplicate records can be generated per original +# record. +# +max_duplicate_per_record = 3 + +# Set the probability distribution used to create the duplicate records for one +# original record (possible values are: 'uniform', 'poisson', 'zipf'). +# +num_duplicates_distribution = 'zipf' + +# Set the maximum number of modification that can be applied to a single +# attribute (field). +# +max_modification_per_attr = 1 + +# Set the number of modification that are to be applied to a record. +# +num_modification_per_record = 5 + +# Check if the given the unicode encoding selected is valid. +# +basefunctions.check_unicode_encoding_exists(unicode_encoding_used) + +# ----------------------------------------------------------------------------- +# Define the attributes to be generated (using methods from the generator.py +# module). +# +surname_attr = generator.GenerateFreqAttribute( + attribute_name='surname', + freq_file_name='surname-freq-japanese.csv', + has_header_line=False, + unicode_encoding=unicode_encoding_used, +) + +credit_card_attr = generator.GenerateFuncAttribute( + attribute_name='credit-card-number', function=attrgenfunct.generate_credit_card_number +) + +age_normal_attr = generator.GenerateFuncAttribute( + attribute_name='age', + function=attrgenfunct.generate_normal_age, + parameters=[45, 30, 0, 130], +) + +gender_city_comp_attr = generator.GenerateCateCateCompoundAttribute( + categorical1_attribute_name='gender', + categorical2_attribute_name='city', + lookup_file_name='gender-city-japanese.csv', + has_header_line=False, + unicode_encoding=unicode_encoding_used, +) + +# ----------------------------------------------------------------------------- +# Define how the generated records are to be corrupted (using methods from +# the corruptor.py module). + +# For a value edit corruptor, the sum or the four probabilities given must +# be 1.0. +# +surname_misspell_corruptor = corruptor.CorruptCategoricalValue( + lookup_file_name='surname-misspell-japanese.csv', + has_header_line=False, + unicode_encoding=unicode_encoding_used, +) + +edit_corruptor = corruptor.CorruptValueEdit( + position_function=corruptor.position_mod_normal, + char_set_funct=basefunctions.char_set_ascii, + insert_prob=0.0, + delete_prob=0.0, + substitute_prob=0.6, + transpose_prob=0.4, +) + +missing_val_corruptor = corruptor.CorruptMissingValue() + +# ----------------------------------------------------------------------------- +# Define the attributes to be generated for this data set, and the data set +# itself. +# +attr_name_list = ['surname', 'age', 'gender', 'city', 'credit-card-number'] + +attr_data_list = [surname_attr, credit_card_attr, age_normal_attr, gender_city_comp_attr] + +# Nothing to change here - set-up the data set generation object. +# +test_data_generator = generator.GenerateDataSet( + output_file_name=out_file_name, + write_header_line=True, + rec_id_attr_name=rec_id_attr_name, + number_of_records=num_org_rec, + attribute_name_list=attr_name_list, + attribute_data_list=attr_data_list, + unicode_encoding=unicode_encoding_used, +) + +# Define the probability distribution of how likely an attribute will be +# selected for a modification. +# Each of the given probability values must be between 0 and 1, and the sum of +# them must be 1.0. +# If a probability is set to 0 for a certain attribute, then no modification +# will be applied on this attribute. +# +attr_mod_prob_dictionary = { + 'surname': 0.5, + 'age': 0.2, + 'gender': 0.05, + 'city': 0.05, + 'credit-card-number': 0.2, +} + +# Define the actual corruption (modification) methods that will be applied on +# the different attributes. +# For each attribute, the sum of probabilities given must sum to 1.0. +# +attr_mod_data_dictionary = { + 'surname': [(0.9, surname_misspell_corruptor), (0.1, missing_val_corruptor)], + 'age': [(0.1, missing_val_corruptor), (0.9, edit_corruptor)], + 'gender': [(1.0, missing_val_corruptor)], + 'city': [(1.0, missing_val_corruptor)], + 'credit-card-number': [(0.1, missing_val_corruptor), (0.9, edit_corruptor)], +} + +# Nothing to change here - set-up the data set corruption object +# +test_data_corruptor = corruptor.CorruptDataSet( + number_of_org_records=num_org_rec, + number_of_mod_records=num_dup_rec, + attribute_name_list=attr_name_list, + max_num_dup_per_rec=max_duplicate_per_record, + num_dup_dist=num_duplicates_distribution, + max_num_mod_per_attr=max_modification_per_attr, + num_mod_per_rec=num_modification_per_record, + attr_mod_prob_dict=attr_mod_prob_dictionary, + attr_mod_data_dict=attr_mod_data_dictionary, +) + +# ============================================================================= +# No need to change anything below here + +# Start the generation process +# +rec_dict = test_data_generator.generate() + +assert len(rec_dict) == num_org_rec # Check the number of generated records + +# Corrupt (modify) the original records into duplicate records +# +rec_dict = test_data_corruptor.corrupt_records(rec_dict) + +assert len(rec_dict) == num_org_rec + num_dup_rec # Check total number of records + +# Write generate data into a file +# +test_data_generator.write() + diff --git a/geco_data_generator/__init__.py b/geco_data_generator/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..56fafa58b3f43decb7699b93048b8b87e0f695aa --- /dev/null +++ b/geco_data_generator/__init__.py @@ -0,0 +1,2 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- diff --git a/geco_data_generator/attrgenfunct.py b/geco_data_generator/attrgenfunct.py new file mode 100644 index 0000000000000000000000000000000000000000..532cd7b4b8d83acc0ef73dbb49bdae20cdcee036 --- /dev/null +++ b/geco_data_generator/attrgenfunct.py @@ -0,0 +1,316 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Functions to generate independent attribute values +import random + +from geco_data_generator import basefunctions + + + + +def generate_phone_number_australia(): + """ + Randomly generate an Australian telephone number made of a two-digit area + code and an eight-digit number made of two blocks of four digits (with a + space between). For example: `02 1234 5678' + + For details see: http://en.wikipedia.org/wiki/ \ + Telephone_numbers_in_Australia#Personal_numbers_.2805.29 + """ + + area_code = random.choice(['02', '03', '04', '07', '08']) + + number1 = random.randint(1, 9999) + number2 = random.randint(1, 9999) + + oz_phone_str = ( + str(area_code) + ' ' + str(number1).zfill(4) + ' ' + str(number2).zfill(4) + ) + assert len(oz_phone_str) == 12 + assert oz_phone_str[0] == '0' + + return oz_phone_str + + +def generate_credit_card_number(): + """Randomly generate a credit card made of four four-digit numbers (with a + space between each number group). For example: '1234 5678 9012 3456' + + For details see: http://en.wikipedia.org/wiki/Bank_card_number + """ + + number1 = random.randint(1, 9999) + assert number1 > 0 + + number2 = random.randint(1, 9999) + assert number2 > 0 + + number3 = random.randint(1, 9999) + assert number3 > 0 + + number4 = random.randint(1, 9999) + assert number4 > 0 + + cc_str = ( + str(number1).zfill(4) + + ' ' + + str(number2).zfill(4) + + ' ' + + str(number3).zfill(4) + + ' ' + + str(number4).zfill(4) + ) + + assert len(cc_str) == 19 + + return cc_str + + +# +def generate_uniform_value(min_val, max_val, val_type): + """Randomly generate a numerical value according to a uniform distribution + between the minimum and maximum values given. + + The value type can be set as 'int', so a string formatted as an integer + value is returned; or as 'float1' to 'float9', in which case a string + formatted as floating-point value with the specified number of digits + behind the comma is returned. + + Note that for certain situations and string formats a value outside the + set range might be returned. For example, if min_val=100.25 and + val_type='float1' the rounding can result in a string value '100.2' to + be returned. + + Suitable minimum and maximum values need to be selected to prevent such a + situation. + """ + + basefunctions.check_is_number('min_val', min_val) + basefunctions.check_is_number('max_val', max_val) + assert min_val < max_val + + r = random.uniform(min_val, max_val) + + return basefunctions.float_to_str(r, val_type) + + +# +def generate_uniform_age(min_val, max_val): + """Randomly generate an age value (returned as integer) according to a + uniform distribution between the minimum and maximum values given. + + This function is simple a shorthand for: + + generate_uniform_value(min_val, max_val, 'int') + """ + + assert min_val >= 0 + assert max_val <= 130 + + return generate_uniform_value(min_val, max_val, 'int') + + +def generate_normal_value(mu, sigma, min_val, max_val, val_type): + """Randomly generate a numerical value according to a normal distribution + with the mean (mu) and standard deviation (sigma) given. + + A minimum and maximum allowed value can given as additional parameters, + if set to None then no minimum and/or maximum limit is set. + + The value type can be set as 'int', so a string formatted as an integer + value is returned; or as 'float1' to 'float9', in which case a string + formatted as floating-point value with the specified number of digits + behind the comma is returned. + """ + + basefunctions.check_is_number('mu', mu) + basefunctions.check_is_number('sigma', sigma) + assert sigma > 0.0 + + if min_val != None: + basefunctions.check_is_number('min_val', min_val) + assert min_val <= mu + + if max_val != None: + basefunctions.check_is_number('max_val', max_val) + assert max_val >= mu + + if (min_val != None) and (max_val != None): + assert min_val < max_val + + if (min_val != None) or (max_val != None): + in_range = False # For testing if the random value is with the range + else: + in_range = True + + r = random.normalvariate(mu, sigma) + + while in_range == False: + if (min_val == None) or ((min_val != None) and (r >= min_val)): + in_range = True + + if (max_val != None) and (r > max_val): + in_range = False + + if in_range == True: + r_str = basefunctions.float_to_str(r, val_type) + r_test = float(r_str) + if (min_val != None) and (r_test < min_val): + in_range = False + if (max_val != None) and (r_test > max_val): + in_range = False + + if in_range == False: + r = random.normalvariate(mu, sigma) + + if min_val != None: + assert r >= min_val + if max_val != None: + assert r <= max_val + + return basefunctions.float_to_str(r, val_type) + + +# +def generate_normal_age(mu, sigma, min_val, max_val): + """Randomly generate an age value (returned as integer) according to a + normal distribution following the mean and standard deviation values + given, and limited to age values between (including) the minimum and + maximum values given. + + This function is simple a shorthand for: + + generate_normal_value(mu, sigma, min_val, max_val, 'int') + """ + + assert min_val >= 0 + assert max_val <= 130 + + age = generate_normal_value(mu, sigma, min_val, max_val, 'int') + + while (int(age) < min_val) or (int(age) > max_val): + age = generate_normal_value(mu, sigma, min_val, max_val, 'int') + + return age + + +# ============================================================================= + +# If called from command line perform some examples: Generate values +# +if __name__ == '__main__': + + num_test = 20 + + print('Generate %d Australian telephone numbers:' % (num_test)) + for i in range(num_test): + print(' ', generate_phone_number_australia()) + print() + + print('Generate %d credit card numbers:' % (num_test)) + for i in range(num_test): + print(' ', generate_credit_card_number()) + print() + + print( + 'Generate %d uniformly distributed integer numbers between -100' % (num_test) + + ' and -5:' + ) + for i in range(num_test): + print( + ' ', + generate_uniform_value(-100, -5, 'int'), + ) + print() + + print( + 'Generate %d uniformly distributed floating-point numbers with ' % (num_test) + + '3 digits between -55 and 55:' + ) + for i in range(num_test): + print(' ', generate_uniform_value(-55, 55, 'float3')) + print() + + print( + 'Generate %d uniformly distributed floating-point numbers with ' % (num_test) + + '7 digits between 147 and 9843:' + ) + for i in range(num_test): + print(' ', generate_uniform_value(147, 9843, 'float7')) + print() + + print('Generate %d uniformly distributed age values between 0 and 120:' % (num_test)) + for i in range(num_test): + print(' ', generate_uniform_age(0, 120)) + print() + + print('Generate %d uniformly distributed age values between 18 and 65:' % (num_test)) + for i in range(num_test): + print(' ', generate_uniform_age(18, 65)) + print() + + print( + 'Generate %d normally distributed integer numbers between -200' % (num_test) + + ' and -3 with mean -50 and standard deviation 44:' + ) + for i in range(num_test): + print(' ', generate_normal_value(-50, 44, -200, -3, 'int')) + print() + + print( + 'Generate %d normally distributed floating-point numbers with ' % (num_test) + + '5 digits between -100 and 100 and with mean 22 and ' + + 'standard deviation 74:' + ) + for i in range(num_test): + print(' ', generate_normal_value(22, 74, -100, 100, 'float5')) + print() + + print( + 'Generate %d normally distributed floating-point numbers with ' % (num_test) + + '9 digits with mean 22 and standard deviation 74:' + ) + for i in range(num_test): + print( + ' ', + generate_normal_value(22, 74, min_val=None, max_val=None, val_type='float9'), + ) + print() + + print( + 'Generate %d normally distributed floating-point numbers with ' % (num_test) + + '2 digits with mean 22 and standard deviation 24 that' + + ' are larger than 10:' + ) + for i in range(num_test): + print( + ' ', generate_normal_value(22, 74, min_val=10, max_val=None, val_type='float2') + ) + print() + + print( + 'Generate %d normally distributed floating-point numbers with ' % (num_test) + + '4 digits with mean 22 and standard deviation 24 that' + + ' are smaller than 30:' + ) + for i in range(num_test): + print( + ' ', generate_normal_value(22, 74, min_val=None, max_val=40, val_type='float4') + ) + print() + + print( + 'Generate %d normally distributed age values between 0 and 120' % (num_test) + + ' with mean 45 and standard deviation 22:' + ) + for i in range(num_test): + print(' ', generate_normal_age(45, 22, 0, 120)) + print() + + print( + 'Generate %d normally distributed age values between 18 and 65' % (num_test) + + ' with mean 30 and standard deviation 10:' + ) + for i in range(num_test): + print(' ', generate_normal_age(30, 10, 18, 65)) + print() diff --git a/geco_data_generator/basefunctions.py b/geco_data_generator/basefunctions.py new file mode 100644 index 0000000000000000000000000000000000000000..7274fca27395473e2c5d5d03154ed11c4a00831e --- /dev/null +++ b/geco_data_generator/basefunctions.py @@ -0,0 +1,614 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Helper functions +import codecs # Used to read and write Unicode files +import os +import types + +HERE = os.path.abspath(os.path.dirname(__file__)) +DATA = os.path.join(HERE, 'data') + +def check_is_not_none(variable, value): + """Check if the value given is not None. + + The argument 'variable' needs to be set to the name (as a string) of the + value which is checked. + """ + + check_is_non_empty_string('variable', variable) + + if value == None: + raise Exception('Value of "%s" is None' % (variable)) + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +def check_is_string(variable, value): + """Check if the value given is of type string. + + The argument 'variable' needs to be set to the name (as a string) of the + value which is checked. + """ + + check_is_non_empty_string('variable', variable) + + if not isinstance(value, str): + raise Exception( + 'Value of "%s" is not a string: %s (%s)' % (variable, str(value), type(value)) + ) + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +def check_is_unicode_string(variable, value): + """Check if the value given is of type unicode string. + + The argument 'variable' needs to be set to the name (as a string) of the + value which is checked. + """ + + check_is_non_empty_string('variable', variable) + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +def check_is_string_or_unicode_string(variable, value): + """Check if the value given is of type string or unicode string. + + The argument 'variable' needs to be set to the name (as a string) of the + value which is checked. + """ + + check_is_non_empty_string('variable', variable) + + if not isinstance(value, str): + raise Exception( + 'Value of "%s" is neither a string nor a Unicode ' % (variable) + + 'string: %s (%s)' % (str(value), type(value)) + ) + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +def check_is_non_empty_string(variable, value): + """Check if the value given is of type string and is not an empty string. + + The argument 'variable' needs to be set to the name (as a string) of the + value which is checked. + """ + + if (not isinstance(variable, str)) or (variable == ''): + raise Exception( + 'Value of "variable" is not a non-empty string: %s (%s)' + % (str(variable), type(variable)) + ) + + if (not isinstance(value, str)) or (value == ''): + raise Exception( + 'Value of "%s" is not a non-empty string: %s (%s)' + % (variable, str(value), type(value)) + ) + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +def check_is_number(variable, value): + """Check if the value given is a number, i.e. of type integer or float. + + The argument 'variable' needs to be set to the name (as a string) of the + value which is checked. + """ + + check_is_non_empty_string('variable', variable) + + if (not isinstance(value, int)) and (not isinstance(value, float)): + raise Exception( + 'Value of "%s" is not a number: %s (%s)' % (variable, str(value), type(value)) + ) + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +def check_is_positive(variable, value): + """Check if the value given is a positive number, i.e. of type integer or + float, and larger than zero. + + The argument 'variable' needs to be set to the name (as a string) of the + value which is checked. + """ + + check_is_non_empty_string('variable', variable) + + if (not isinstance(value, int)) and (not isinstance(value, float)) or (value <= 0.0): + raise Exception( + 'Value of "%s" is not a positive number: ' % (variable) + + '%s (%s)' % (str(value), type(value)) + ) + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +def check_is_not_negative(variable, value): + """Check if the value given is a non-negative number, i.e. of type integer or + float, and larger than or equal to zero. + + The argument 'variable' needs to be set to the name (as a string) of the + value which is checked. + """ + + check_is_non_empty_string('variable', variable) + + if (not isinstance(value, int)) and (not isinstance(value, float)) or (value < 0.0): + raise Exception( + 'Value of "%s" is not a number or it is a ' % (variable) + + 'negative number: %s (%s)' % (str(value), type(value)) + ) + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +def check_is_normalised(variable, value): + """Check if the value given is a number, i.e. of type integer or float, and + between (including) 0.0 and 1.0. + + The argument 'variable' needs to be set to the name (as a string) of the + value which is checked. + """ + + check_is_non_empty_string('variable', variable) + + if ( + (not isinstance(value, int)) + and (not isinstance(value, float)) + or (value < 0.0) + or (value > 1.0) + ): + raise Exception( + 'Value of "%s" is not a normalised number ' % (variable) + + '(between 0.0 and 1.0): %s (%s)' % (str(value), type(value)) + ) + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +def check_is_percentage(variable, value): + """Check if the value given is a number, i.e. of type integer or float, and + between (including) 0 and 100. + + The argument 'variable' needs to be set to the name (as a string) of the + value which is checked. + """ + + check_is_non_empty_string('variable', variable) + + if ( + (not isinstance(value, int)) + and (not isinstance(value, float)) + or (value < 0.0) + or (value > 100.0) + ): + raise Exception( + 'Value of "%s" is not a percentage number ' % (variable) + + '(between 0.0 and 100.0): %s (%s)' % (str(value), type(value)) + ) + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +def check_is_integer(variable, value): + """Check if the value given is an integer number. + + The argument 'variable' needs to be set to the name (as a string) of the + value which is checked. + """ + + check_is_non_empty_string('variable', variable) + + if not isinstance(value, int): + raise Exception( + 'Value of "%s" is not an integer: %s (%s)' + % (variable, str(value), type(value)) + ) + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +def check_is_float(variable, value): + """Check if the value given is a floating-point number. + + The argument 'variable' needs to be set to the name (as a string) of the + value which is checked. + """ + + check_is_non_empty_string('variable', variable) + + if not isinstance(value, float): + raise Exception( + 'Value of "%s" is not a floating point ' % (variable) + + 'number: %s (%s)' % (str(value), type(value)) + ) + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +def check_is_dictionary(variable, value): + """Check if the value given is of type dictionary. + + The argument 'variable' needs to be set to the name (as a string) of the + value which is checked. + """ + + check_is_non_empty_string('variable', variable) + + if not isinstance(value, dict): + raise Exception('Value of "%s" is not a dictionary: %s' % (variable, type(value))) + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +def check_is_list(variable, value): + """Check if the value given is of type dictionary. + + The argument 'variable' needs to be set to the name (as a string) of the + value which is checked. + """ + + check_is_non_empty_string('variable', variable) + + if not isinstance(value, list): + raise Exception('Value of "%s" is not a list: %s' % (variable, type(value))) + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +def check_is_set(variable, value): + """Check if the value given is of type set. + + The argument 'variable' needs to be set to the name (as a string) of the + value which is checked. + """ + + check_is_non_empty_string('variable', variable) + + if not isinstance(value, set): + raise Exception('Value of "%s" is not a set: %s' % (variable, type(value))) + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +def check_is_tuple(variable, value): + """Check if the value given is of type tuple. + + The argument 'variable' needs to be set to the name (as a string) of the + value which is checked. + """ + + check_is_non_empty_string('variable', variable) + + if not isinstance(value, tuple): + raise Exception('Value of "%s" is not a tuple: %s' % (variable, type(value))) + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +def check_is_flag(variable, value): + """Check if the value given is either True or False. + + The argument 'variable' needs to be set to the name (as a string) of the + value which is checked. + """ + + check_is_non_empty_string('variable', variable) + + if value not in [True, False]: + raise Exception('Value of "%s" is not True or False: %s' % (variable, str(value))) + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +def check_is_function_or_method(variable, value): + """Check if the value given is a function or method. + + The argument 'variable' needs to be set to the name (as a string) of the + value which is checked. + """ + + check_is_non_empty_string('variable', variable) + + if type(value) not in [types.FunctionType, types.MethodType]: + raise Exception( + '%s is not a function or method: %s' % (str(variable), type(value)) + ) + + +def check_unicode_encoding_exists(unicode_encoding_str): + """A function which checks if the given Unicode encoding string is known to + the Python codec registry. + + If the string is unknown this functions ends with an exception. + """ + + check_is_string_or_unicode_string('unicode_encoding_str', unicode_encoding_str) + + try: + codecs.lookup(unicode_encoding_str) + except: + raise Exception('Unknown Unicode encoding string: "%s"' % (unicode_encoding_str)) + + +def char_set_ascii(s): + """Determine if the input string contains digits, letters, or both, as well + as whitespaces or not. + + Returns a string containing the set of corresponding characters. + """ + + check_is_string_or_unicode_string('s', s) + + if len(s) == 0: + return '' + + if ' ' in s: + includes_spaces = True + else: + includes_spaces = False + + # Remove whitespaces + # + check_str = s.replace(' ', '') + + # Check if string contains characters other than alpha-numeric characters + # + if check_str.isalnum() == False: + return '' + + # Return an empty string rather than stopping program + # + # raise Exception, 'The string "%s" contains characters other than ' % \ + # (check_str) + 'alpha numeric and whitespace' + + # Check if string contains letters only, digits only, or both + # + if check_str.isdigit() == True: + char_set = '0123456789' + elif check_str.isalpha() == True: + char_set = 'abcdefghijklmnopqrstuvwxyz' + else: + char_set = 'abcdefghijklmnopqrstuvwxyz0123456789' + + if includes_spaces == True: + char_set += ' ' + + return char_set + + +def check_is_valid_format_str(variable, value): + """Check if the value given is a valid formatting string for numbers. + Possible formatting values are: + + int, float1, float2, float3, float4, float5, float6, float7, float8, or + float9 + + The argument 'variable' needs to be set to the name (as a string) of the + value which is checked. + """ + + check_is_non_empty_string('variable', variable) + + if value not in [ + 'int', + 'float1', + 'float2', + 'float3', + 'float4', + 'float5', + 'float6', + 'float7', + 'float8', + 'float9', + ]: + raise Exception( + '%s is not a validformat string: %s' % (str(variable), type(value)) + ) + + +def float_to_str(f, format_str): + """Convert the given floating-point (or integer) number into a string + according to the format string given. + + The format string can be one of 'int' (return a string that corresponds to + an integer value), or 'float1', 'float2', ..., 'float9' which returns a + string of the number with the specified number of digits behind the comma. + """ + + check_is_number('f', f) + + check_is_string('format_str', format_str) + check_is_valid_format_str('format_str', format_str) + + if format_str == 'int': + f_str = '%.0f' % (f) + elif format_str == 'float1': + f_str = '%.1f' % (f) + elif format_str == 'float2': + f_str = '%.2f' % (f) + elif format_str == 'float3': + f_str = '%.3f' % (f) + elif format_str == 'float4': + f_str = '%.4f' % (f) + elif format_str == 'float5': + f_str = '%.5f' % (f) + elif format_str == 'float6': + f_str = '%.6f' % (f) + elif format_str == 'float7': + f_str = '%.7f' % (f) + elif format_str == 'float8': + f_str = '%.8f' % (f) + elif format_str == 'float9': + f_str = '%.9f' % (f) + else: + raise Exception('Illegal string format given: "%s"' % (format_str)) + + return f_str + + +def str2comma_separated_list(s): + """A function which splits the values in a list at commas, and checks all + values if they are quoted (double or single) at both ends or not. Quotes + are removed. + + Note that this function will split values that are quoted but contain one + or more commas into several values. + """ + + check_is_unicode_string('s', s) + + in_list = s.split(',') + out_list = [] + + for e in in_list: + e = e.strip() + if (e.startswith('"') and e.endswith('"')) or ( + e.startswith("'") and e.endswith("'") + ): + e = e[1:-1] # Remove quotes + out_list.append(e) + + return out_list + + +def read_csv_file(file_name, encoding, header_line): + """Read a comma separated values (CSV) file from disk using the given Unicode + encoding. + + Arguments: + file_name Name of the file to read. + + encoding The name of a Unicode encoding to be used when reading the + file. + If set to None then the standard 'ascii' encoding will be + used. + + header_line A flag, set to True or False, that has to be set according + to if the frequency file starts with a header line or not. + + This function returns two items: + - If given, a list that contains the values in the header line of the + file. If no header line was given, this item will be set to None. + + - A list containing the records in the CSV file, each as a list. + + Notes: + - Lines starting with # are assumed to contain comments and will be + skipped. Lines that are empty will also be skipped. + - The CSV files must not contain commas in the values, while values + in quotes (double or single) can be handled. + """ + + check_is_string('file_name', file_name) + check_is_flag('header_line', header_line) + + # if encoding == None: # Use default ASCII encoding + # encoding = 'ascii' + # check_is_string('encoding', encoding) + # check_unicode_encoding_exists(encoding) + if not os.path.exists(file_name): + file_name = os.path.join(DATA, file_name) + try: + in_file = open(os.path.join(DATA, file_name), encoding="utf-8") + except: + raise IOError('Cannot read CSV file "%s"' % (file_name)) + + if header_line == True: + header_line = in_file.readline() + # print 'Header line:', header_line + + header_list = str2comma_separated_list(header_line) + + else: + # print 'No header line' + header_list = None + + file_data = [] + + for line_str in in_file: + line_str = line_str.strip() + if (line_str.startswith('#') == False) and (line_str != ''): + line_list = str2comma_separated_list(line_str) + + file_data.append(line_list) + + in_file.close() + + return header_list, file_data + + +def write_csv_file(file_name, encoding, header_list, file_data): + """Write a comma separated values (CSV) file to disk using the given Unicode + encoding. + + Arguments: + file_name Name of the file to write. + + encoding The name of a Unicode encoding to be used when reading the + file. + If set to None then the standard 'ascii' encoding will be + used. + + header_list A list containing the attribute (field) names to be written + at the beginning of the file. + If no header line is to be written then this argument needs + to be set to None. + + file_data A list containing the records to be written into the CSV + file. Each record must be a list of values, and these values + will be concatenated with commas and written into the file. + It is assumed the values given do not contain comas. + """ + + check_is_string('file_name', file_name) + check_is_list('file_data', file_data) + + if encoding == None: # Use default ASCII encoding + encoding = 'ascii' + check_is_string('encoding', encoding) + check_unicode_encoding_exists(encoding) + + try: + out_file = codecs.open(file_name, 'w', encoding=encoding) + except: + raise IOError('Cannot write CSV file "%s"' % (file_name)) + + if header_list != None: + check_is_list('header_list', header_list) + header_str = ','.join(header_list) + # print 'Header line:', header_str + out_file.write(header_str + os.linesep) + + i = 0 + for rec_list in file_data: + check_is_list('rec_list %d' % (i), rec_list) + + line_str = ','.join(rec_list) + out_file.write(line_str + os.linesep) + + i += 1 + + out_file.close() diff --git a/geco_data_generator/contdepfunct.py b/geco_data_generator/contdepfunct.py new file mode 100644 index 0000000000000000000000000000000000000000..3d771ab01203a4ade8420a3e3dba25ff25b7df82 --- /dev/null +++ b/geco_data_generator/contdepfunct.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Functions to generate dependent continuous attribute +import random + + +def blood_pressure_depending_on_age(age): + """Randomly generate a blood pressure value depending upon the given age + value. + + It is assumed that for a given age value the blood pressure is normally + distributed with an average blood pressure of 75 at birth (age 0) and of + 90 at age 100, and standard deviation in blood pressure of 4. + """ + + if (not isinstance(age, int)) and (not isinstance(age, float)): + raise Exception('Age value given is not a number: %s' % (str(age))) + + if (age < 0) or (age > 130): + raise Exception('Age value below 0 or above 130 given') + + avrg_bp = 75.0 + age / 100.0 + + std_dev_bp = 4.0 + + bp = random.normalvariate(avrg_bp, std_dev_bp) + + if bp < 0.0: + bp = 0.0 + print('Warning, blood pressure value of 0.0 returned!') + + return bp + + +# ----------------------------------------------------------------------------- + + +def salary_depending_on_age(age): + """Randomly generate a salary value depending upon the given age value. + + It is assumed that for a given age value the salary is uniformly + distributed with an average salary of between 20,000 at age 18 (salary + will be set to 0 if an age is below 18) and 80,000 at age 60. + + The minimum salary will stay at 10,000 while the maximum salary will + increase from 30,000 at age 18 to 150,000 at age 60. + """ + + if (not isinstance(age, int)) and (not isinstance(age, float)): + raise Exception('Age value given is not a number: %s' % (str(age))) + + if (age < 0) or (age > 130): + raise Exception('Age value below 0 or above 130 given') + + if age < 18.0: + sal = 0.0 + + else: + min_sal = 10000.0 + max_sal = 10000.0 + (age - 18.0) * (140000.0 / 42) + + sal = random.uniform(min_sal, max_sal) + + return sal diff --git a/geco_data_generator/corruptor.py b/geco_data_generator/corruptor.py new file mode 100644 index 0000000000000000000000000000000000000000..e0b9dcc3a351efee413a4c3626b9682688182fc5 --- /dev/null +++ b/geco_data_generator/corruptor.py @@ -0,0 +1,2035 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Main classes to corrupt attribute values and records +import math +import random + +from geco_data_generator import basefunctions + + +# ============================================================================= +# Helper functions to randomly select a position for where to apply a +# modification + + +def position_mod_uniform(in_str): + """Select any position in the given input string with uniform likelihood. + + Return 0 is the string is empty. + """ + + if in_str == '': # Empty input string + return 0 + + max_pos = len(in_str) - 1 + + pos = random.randint(0, max_pos) # String positions start at 0 + + return pos + + +# ----------------------------------------------------------------------------- + + +def position_mod_normal(in_str): + """Select any position in the given input string with normally distributed + likelihood where the average of the normal distribution is set to one + character behind the middle of the string, and the standard deviation is + set to 1/4 of the string length. + + This is based on studies on the distribution of errors in real text which + showed that errors such as typographical mistakes are more likely to + appear towards the middle and end of a string but not at the beginning. + + Return 0 is the string is empty. + """ + + if in_str == '': # Empty input string + return 0 + + str_len = len(in_str) + + mid_pos = str_len / 2.0 + 1 + std_dev = str_len / 4.0 + max_pos = str_len - 1 + + pos = int(round(random.gauss(mid_pos, std_dev))) + while (pos < 0) or (pos > max_pos): + pos = int(round(random.gauss(mid_pos, std_dev))) + + return pos + + +# ============================================================================= +# Classes for corrupting a value in a single attribute (field) of the data set +# ============================================================================= + + +class CorruptValue: + """Base class for the definition of corruptor that is applied on a single + attribute (field) in the data set. + + This class and all of its derived classes provide methods that allow the + definition of how values in a single attribute are corrupted (modified) + and the parameters necessary for the corruption process. + + The following variables need to be set when a CorruptValue instance is + initialised (with further parameters listed in the derived classes): + + position_function A function that (somehow) determines the location + within a string value of where a modification + (corruption) is to be applied. The input of this + function is assumed to be a string and its return value + an integer number in the range of the length of the + given input string. + """ + + # --------------------------------------------------------------------------- + + def __init__(self, base_kwargs): + """Constructor, set general attributes.""" + + # General attributes for all attribute corruptors. + # + self.position_function = None + + # Process the keyword argument (all keywords specific to a certain data + # generator type were processed in the derived class constructor) + # + for (keyword, value) in base_kwargs.items(): + + if keyword.startswith('position'): + basefunctions.check_is_function_or_method('position_function', value) + self.position_function = value + + else: + raise Exception( + 'Illegal constructor argument keyword: "%s"' % (str(keyword)) + ) + + basefunctions.check_is_function_or_method( + 'position_function', self.position_function + ) + + # Check if the position function does return an integer value + # + pos = self.position_function('test') + if (not isinstance(pos, int)) or (pos < 0) or (pos > 3): + raise Exception( + 'Position function returns an illegal value (either' + + 'not an integer or and integer out of range: %s' % (str(pos)) + ) + + # --------------------------------------------------------------------------- + + def corrupt_value(self, str): + """Method which corrupts the given input string and returns the modified + string. + See implementations in derived classes for details. + """ + + raise Exception('Override abstract method in derived class') + + +# ============================================================================= + + +class CorruptMissingValue(CorruptValue): + """A corruptor method which simply sets an attribute value to a missing + value. + + The additional argument (besides the base class argument + 'position_function') that has to be set when this attribute type is + initialised are: + + missing_val The string which designates a missing value. Default value + is the empty string ''. + + Note that the 'position_function' is not required by this corruptor + method. + """ + + # --------------------------------------------------------------------------- + + def __init__(self, **kwargs): + """Constructor. Process the derived keywords first, then call the base + class constructor. + """ + + self.missing_val = '' + self.name = 'Missing value' + + def dummy_position(s): # Define a dummy position function + return 0 + + # Process all keyword arguments + # + base_kwargs = {} # Dictionary, will contain unprocessed arguments + + for (keyword, value) in kwargs.items(): + + if keyword.startswith('miss'): + basefunctions.check_is_string('missing_val', value) + self.missing_val = value + + else: + base_kwargs[keyword] = value + + base_kwargs['position_function'] = dummy_position + + CorruptValue.__init__(self, base_kwargs) # Process base arguments + + # --------------------------------------------------------------------------- + + def corrupt_value(self, in_str): + """Simply return the missing value string.""" + + return self.missing_val + + +# ============================================================================= + + +class CorruptValueEdit(CorruptValue): + """A simple corruptor which applies one edit operation on the given value. + + Depending upon the content of the value (letters, digits or mixed), if the + edit operation is an insert or substitution a character from the same set + (letters, digits or both) is selected. + + The additional arguments (besides the base class argument + 'position_function') that has to be set when this attribute type is + initialised are: + + char_set_funct A function which determines the set of characters that + can be inserted or used of substitution + insert_prob These for values set the likelihood of which edit + delete_prob operation will be selected. + substitute_prob All four probability values must be between 0 and 1, and + transpose_prob the sum of these four values must be 1.0 + """ + + # --------------------------------------------------------------------------- + + def __init__(self, **kwargs): + """Constructor. Process the derived keywords first, then call the base + class constructor. + """ + + self.char_set_funct = None + self.insert_prob = None + self.delete_prob = None + self.substitute_prob = None + self.transpose_prob = None + self.name = 'Edit operation' + + # Process all keyword arguments + # + base_kwargs = {} # Dictionary, will contain unprocessed arguments + + for (keyword, value) in kwargs.items(): + + if keyword.startswith('char'): + basefunctions.check_is_function_or_method('char_set_funct', value) + self.char_set_funct = value + + elif keyword.startswith('ins'): + basefunctions.check_is_normalised('insert_prob', value) + self.insert_prob = value + + elif keyword.startswith('del'): + basefunctions.check_is_normalised('delete_prob', value) + self.delete_prob = value + + elif keyword.startswith('sub'): + basefunctions.check_is_normalised('substitute_prob', value) + self.substitute_prob = value + + elif keyword.startswith('tran'): + basefunctions.check_is_normalised('transpose_prob', value) + self.transpose_prob = value + + else: + base_kwargs[keyword] = value + + CorruptValue.__init__(self, base_kwargs) # Process base arguments + + # Check if the necessary variables have been set + # + basefunctions.check_is_function_or_method('char_set_funct', self.char_set_funct) + basefunctions.check_is_normalised('insert_prob', self.insert_prob) + basefunctions.check_is_normalised('delete_prob', self.delete_prob) + basefunctions.check_is_normalised('substitute_prob', self.substitute_prob) + basefunctions.check_is_normalised('transpose_prob', self.transpose_prob) + + # Check if the character set function returns a string + # + test_str = self.char_set_funct('test') # This might become a problem + basefunctions.check_is_string_or_unicode_string('test_str', test_str) + + if ( + abs( + ( + self.insert_prob + + self.delete_prob + + self.substitute_prob + + self.transpose_prob + ) + - 1.0 + ) + > 0.0000001 + ): + raise Exception('The four edit probabilities do not sum to 1.0') + + # Calculate the probability ranges for the four edit operations + # + self.insert_range = [0.0, self.insert_prob] + self.delete_range = [self.insert_range[1], self.insert_range[1] + self.delete_prob] + self.substitute_range = [ + self.delete_range[1], + self.delete_range[1] + self.substitute_prob, + ] + self.transpose_range = [ + self.substitute_range[1], + self.substitute_range[1] + self.transpose_prob, + ] + assert self.transpose_range[1] == 1.0 + + # --------------------------------------------------------------------------- + + def corrupt_value(self, in_str): + """Method which corrupts the given input string and returns the modified + string by randomly selecting an edit operation and position in the + string where to apply this edit. + """ + + if len(in_str) == 0: # Empty string, no modification possible + return in_str + + # Randomly select an edit operation + # + r = random.random() + + if r < self.insert_range[1]: + edit_op = 'ins' + elif (r >= self.delete_range[0]) and (r < self.delete_range[1]): + edit_op = 'del' + elif (r >= self.substitute_range[0]) and (r < self.substitute_range[1]): + edit_op = 'sub' + else: + edit_op = 'tra' + + # Do some checks if only a valid edit operations was selected + # + if edit_op == 'ins': + assert self.insert_prob > 0.0 + elif edit_op == 'del': + assert self.delete_prob > 0.0 + elif edit_op == 'sub': + assert self.substitute_prob > 0.0 + else: + assert self.transpose_prob > 0.0 + + # If the input string is empty only insert is possible + # + if (len(in_str) == 0) and (edit_op != 'ins'): + return in_str # Return input string without modification + + # If the input string only has one character then transposition is not + # possible + # + if (len(in_str) == 1) and (edit_op == 'tra'): + return in_str # Return input string without modification + + # Position in string where to apply the modification + # + # For a transposition we cannot select the last position in the string + # while for an insert we can specify the position after the last + if edit_op == 'tra': + len_in_str = in_str[:-1] + elif edit_op == 'ins': + len_in_str = in_str + 'x' + else: + len_in_str = in_str + mod_pos = self.position_function(len_in_str) + + # Get the set of possible characters that can be inserted or substituted + # + char_set = self.char_set_funct(in_str) + + if char_set == '': # No possible value change + return in_str + + if edit_op == 'ins': # Insert a character + ins_char = random.choice(char_set) + new_str = in_str[:mod_pos] + ins_char + in_str[mod_pos:] + + elif edit_op == 'del': # Delete a character + new_str = in_str[:mod_pos] + in_str[mod_pos + 1 :] + + elif edit_op == 'sub': # Substitute a character + sub_char = random.choice(char_set) + new_str = in_str[:mod_pos] + sub_char + in_str[mod_pos + 1 :] + + else: # Transpose two characters + char1 = in_str[mod_pos] + char2 = in_str[mod_pos + 1] + new_str = in_str[:mod_pos] + char2 + char1 + in_str[mod_pos + 2 :] + + return new_str + + +# ============================================================================= + + +class CorruptValueKeyboard(CorruptValue): + """Use a keyboard layout to simulate typing errors. They keyboard is + hard-coded into this method, but can be changed easily for different + keyboard layout. + + A character from the original input string will be randomly chosen using + the position function, and then a character from either the same row or + column in the keyboard will be selected. + + The additional arguments (besides the base class argument + 'position_function') that have to be set when this attribute type is + initialised are: + + row_prob The probability that a neighbouring character in the same row + is selected. + + col_prob The probability that a neighbouring character in the same + column is selected. + + The sum of row_prob and col_prob must be 1.0. + """ + + # --------------------------------------------------------------------------- + + def __init__(self, **kwargs): + """Constructor. Process the derived keywords first, then call the base + class constructor. + """ + + self.row_prob = None + self.col_prob = None + self.name = 'Keybord value' + + # Process all keyword arguments + # + base_kwargs = {} # Dictionary, will contain unprocessed arguments + + for (keyword, value) in kwargs.items(): + + if keyword.startswith('row'): + basefunctions.check_is_normalised('row_prob', value) + self.row_prob = value + + elif keyword.startswith('col'): + basefunctions.check_is_normalised('col_prob', value) + self.col_prob = value + + else: + base_kwargs[keyword] = value + + CorruptValue.__init__(self, base_kwargs) # Process base arguments + + # Check if the necessary variables have been set + # + basefunctions.check_is_normalised('row_prob', self.row_prob) + basefunctions.check_is_normalised('col_prob', self.col_prob) + + if abs((self.row_prob + self.col_prob) - 1.0) > 0.0000001: + raise Exception('Sum of row and column probablities does not sum ' + 'to 1.0') + + # Keyboard substitutions gives two dictionaries with the neigbouring keys + # for all leters both for rows and columns (based on ideas implemented by + # Mauricio A. Hernandez in his dbgen). + # This following data structures assume a QWERTY keyboard layout + # + self.rows = { + 'a': 's', + 'b': 'vn', + 'c': 'xv', + 'd': 'sf', + 'e': 'wr', + 'f': 'dg', + 'g': 'fh', + 'h': 'gj', + 'i': 'uo', + 'j': 'hk', + 'k': 'jl', + 'l': 'k', + 'm': 'n', + 'n': 'bm', + 'o': 'ip', + 'p': 'o', + 'q': 'w', + 'r': 'et', + 's': 'ad', + 't': 'ry', + 'u': 'yi', + 'v': 'cb', + 'w': 'qe', + 'x': 'zc', + 'y': 'tu', + 'z': 'x', + '1': '2', + '2': '13', + '3': '24', + '4': '35', + '5': '46', + '6': '57', + '7': '68', + '8': '79', + '9': '80', + '0': '9', + } + + self.cols = { + 'a': 'qzw', + 'b': 'gh', + 'c': 'df', + 'd': 'erc', + 'e': 'ds34', + 'f': 'rvc', + 'g': 'tbv', + 'h': 'ybn', + 'i': 'k89', + 'j': 'umn', + 'k': 'im', + 'l': 'o', + 'm': 'jk', + 'n': 'hj', + 'o': 'l90', + 'p': '0', + 'q': 'a12', + 'r': 'f45', + 's': 'wxz', + 't': 'g56', + 'u': 'j78', + 'v': 'fg', + 'w': 's23', + 'x': 'sd', + 'y': 'h67', + 'z': 'as', + '1': 'q', + '2': 'qw', + '3': 'we', + '4': 'er', + '5': 'rt', + '6': 'ty', + '7': 'yu', + '8': 'ui', + '9': 'io', + '0': 'op', + } + + # --------------------------------------------------------------------------- + + def corrupt_value(self, in_str): + """Method which corrupts the given input string by replacing a single + character with a neighbouring character given the defined keyboard + layout at a position randomly selected by the position function. + """ + + if len(in_str) == 0: # Empty string, no modification possible + return in_str + + max_try = 10 # Maximum number of tries to find a keyboard modification at + # a randomly selected position + + done_key_mod = False # A flag, set to true once a modification is done + try_num = 0 + + mod_str = in_str[:] # Make a copy of the string which will be modified + + while (done_key_mod == False) and (try_num < max_try): + + mod_pos = self.position_function(mod_str) + mod_char = mod_str[mod_pos] + + r = random.random() # Create a random number between 0 and 1 + + if r <= self.row_prob: # See if there is a row modification + if mod_char in self.rows: + key_mod_chars = self.rows[mod_char] + done_key_mod = True + + else: # See if there is a column modification + if mod_char in self.cols: + key_mod_chars = self.cols[mod_char] + done_key_mod = True + + if done_key_mod == False: + try_num += 1 + + # If a modification is possible do it + # + if done_key_mod == True: + + # Randomly select one of the possible characters + # + new_char = random.choice(key_mod_chars) + + mod_str = mod_str[:mod_pos] + new_char + mod_str[mod_pos + 1 :] + + assert len(mod_str) == len(in_str) + + return mod_str + + +# ============================================================================= + + +class CorruptValueOCR(CorruptValue): + """Simulate OCR errors using a list of similar pairs of characters or strings + that will be applied on the original string values. + + These pairs of characters will be loaded from a look-up file which is a + CSV file with two columns, the first is a single character or character + sequence, and the second column is also a single character or character + sequence. It is assumed that the second value is an OCR modification of + the first value, and the other way round. For example: + + 5,S + 5,s + 2,Z + 2,z + 1,| + 6,G + + It is possible for an 'original' string value (first column) to have + several variations (second column). In such a case one variation will be + randomly selected during the value corruption (modification) process. + + The additional arguments (besides the base class argument + 'position_function') that have to be set when this attribute type is + initialised are: + + lookup_file_name Name of the file which contains the OCR character + variations. + + has_header_line A flag, set to True or False, that has to be set + according to if the look-up file starts with a header + line or not. + + unicode_encoding The Unicode encoding (a string name) of the file. + """ + + # --------------------------------------------------------------------------- + + def __init__(self, **kwargs): + """Constructor. Process the derived keywords first, then call the base + class constructor. + """ + + self.lookup_file_name = None + self.has_header_line = None + self.unicode_encoding = None + self.ocr_val_dict = {} # The dictionary to hold the OCR variations + self.name = 'OCR value' + + # Process all keyword arguments + # + base_kwargs = {} # Dictionary, will contain unprocessed arguments + + for (keyword, value) in kwargs.items(): + + if keyword.startswith('look'): + basefunctions.check_is_non_empty_string('lookup_file_name', value) + self.lookup_file_name = value + + elif keyword.startswith('has'): + basefunctions.check_is_flag('has_header_line', value) + self.has_header_line = value + + elif keyword.startswith('unicode'): + basefunctions.check_is_non_empty_string('unicode_encoding', value) + self.unicode_encoding = value + + else: + base_kwargs[keyword] = value + + CorruptValue.__init__(self, base_kwargs) # Process base arguments + + # Check if the necessary variables have been set + # + basefunctions.check_is_non_empty_string('lookup_file_name', self.lookup_file_name) + basefunctions.check_is_flag('has_header_line', self.has_header_line) + basefunctions.check_is_non_empty_string('unicode_encoding', self.unicode_encoding) + + # Load the OCR variations lookup file - - - - - - - - - - - - - - - - - - - + # + header_list, lookup_file_data = basefunctions.read_csv_file( + self.lookup_file_name, self.unicode_encoding, self.has_header_line + ) + + # Process values from file and their frequencies + # + for rec_list in lookup_file_data: + if len(rec_list) != 2: + raise Exception( + 'Illegal format in OCR variations lookup file ' + + '%s: %s' % (self.lookup_file_name, str(rec_list)) + ) + org_val = rec_list[0].strip() + var_val = rec_list[1].strip() + + if org_val == '': + raise Exception( + 'Empty original OCR value in lookup file %s' % (self.lookup_file_name) + ) + if var_val == '': + raise Exception( + 'Empty OCR variation value in lookup file %s' % (self.lookup_file_name) + ) + if org_val == var_val: + raise Exception( + 'OCR variation is the same as original value in ' + + 'lookup file %s' % (self.lookup_file_name) + ) + + # Now insert the OCR original value and variation twice (with original + # and variation both as key and value), i.e. swapped + # + this_org_val_list = self.ocr_val_dict.get(org_val, []) + this_org_val_list.append(var_val) + self.ocr_val_dict[org_val] = this_org_val_list + + this_org_val_list = self.ocr_val_dict.get(var_val, []) + this_org_val_list.append(org_val) + self.ocr_val_dict[var_val] = this_org_val_list + + # --------------------------------------------------------------------------- + + def corrupt_value(self, in_str): + """Method which corrupts the given input string by replacing a single + character or a sequence of characters with an OCR variation at a + position randomly selected by the position function. + + If there are several OCR variations then one will be randomly chosen. + """ + + if len(in_str) == 0: # Empty string, no modification possible + return in_str + + max_try = 10 # Maximum number of tries to find an OCR modification at a + # randomly selected position + + done_ocr_mod = False # A flag, set to True once a modification is done + try_num = 0 + + mod_str = in_str[:] # Make a copy of the string which will be modified + + while (done_ocr_mod == False) and (try_num < max_try): + + mod_pos = self.position_function(mod_str) + + # Try one to three characters at selected position + # + ocr_org_char_set = set( + [ + mod_str[mod_pos], + mod_str[mod_pos : mod_pos + 2], + mod_str[mod_pos : mod_pos + 3], + ] + ) + + mod_options = [] # List of possible modifications that can be applied + + for ocr_org_char in ocr_org_char_set: + if ocr_org_char in self.ocr_val_dict: + ocr_var_list = self.ocr_val_dict[ocr_org_char] + for mod_val in ocr_var_list: + mod_options.append([ocr_org_char, len(ocr_org_char), mod_val]) + + if mod_options != []: # Modifications are possible + + # Randomly select one of the possible modifications that can be applied + # + mod_to_apply = random.choice(mod_options) + assert mod_to_apply[0] in self.ocr_val_dict.keys() + assert mod_to_apply[2] in self.ocr_val_dict.keys() + + mod_str = ( + in_str[:mod_pos] + + mod_to_apply[2] + + in_str[mod_pos + mod_to_apply[1] :] + ) + + done_ocr_mod = True + + else: + try_num += 1 + + return mod_str + + +# ============================================================================= + + +class CorruptValuePhonetic(CorruptValue): + """Simulate phonetic errors using a list of phonetic rules which are stored + in a CSV look-up file. + + Each line (row) in the CSV file must consist of seven columns that contain + the following information: + 1) Where a phonetic modification can be applied. Possible values are: + 'ALL','START','END','MIDDLE' + 2) The original character sequence (i.e. the characters to be replaced) + 3) The new character sequence (which will replace the original sequence) + 4) Precondition: A condition that must occur before the original string + character sequence in order for this rule to become applicable. + 5) Postcondition: Similarly, a condition that must occur after the + original string character sequence in order for this rule to become + applicable. + 6) Pattern existence condition: This condition requires that a certain + given string character sequence does ('y' flag) or does not ('n' flag) + occur in the input string. + 7) Start existence condition: Similarly, this condition requires that the + input string starts with a certain string pattern ('y' flag) or not + ('n' flag) + + A detailed description of this phonetic data generation is available in + + Accurate Synthetic Generation of Realistic Personal Information + Peter Christen and Agus Pudjijono + Proceedings of the Pacific-Asia Conference on Knowledge Discovery and + Data Mining (PAKDD), Bangkok, Thailand, April 2009. + + For a given input string, one of the possible phonetic modifications will + be randomly selected without the use of the position function. + + The additional arguments (besides the base class argument + 'position_function') that have to be set when this attribute type is + initialised are: + + lookup_file_name Name of the file which contains the phonetic + modification patterns. + + has_header_line A flag, set to True or False, that has to be set + according to if the look-up file starts with a header + line or not. + + unicode_encoding The Unicode encoding (a string name) of the file. + + Note that the 'position_function' is not required by this corruptor + method. + """ + + # --------------------------------------------------------------------------- + + def __init__(self, **kwargs): + """Constructor. Process the derived keywords first, then call the base + class constructor. + """ + + self.lookup_file_name = None + self.has_header_line = None + self.unicode_encoding = None + self.replace_table = [] + self.name = 'Phonetic value' + + def dummy_position(s): # Define a dummy position function + return 0 + + # Process all keyword arguments + # + base_kwargs = {} # Dictionary, will contain unprocessed arguments + + for (keyword, value) in kwargs.items(): + + if keyword.startswith('look'): + basefunctions.check_is_non_empty_string('lookup_file_name', value) + self.lookup_file_name = value + + elif keyword.startswith('has'): + basefunctions.check_is_flag('has_header_line', value) + self.has_header_line = value + + elif keyword.startswith('unicode'): + basefunctions.check_is_non_empty_string('unicode_encoding', value) + self.unicode_encoding = value + + else: + base_kwargs[keyword] = value + + base_kwargs['position_function'] = dummy_position + + CorruptValue.__init__(self, base_kwargs) # Process base arguments + + # Check if the necessary variables have been set + # + basefunctions.check_is_non_empty_string('lookup_file_name', self.lookup_file_name) + basefunctions.check_is_flag('has_header_line', self.has_header_line) + basefunctions.check_is_non_empty_string('unicode_encoding', self.unicode_encoding) + + # Load the misspelling lookup file - - - - - - - - - - - - - - - - - - - - - + # + header_list, lookup_file_data = basefunctions.read_csv_file( + self.lookup_file_name, self.unicode_encoding, self.has_header_line + ) + + # Process values from file and misspellings + # + for rec_list in lookup_file_data: + if len(rec_list) != 7: + raise Exception( + 'Illegal format in phonetic lookup file %s: %s' + % (self.lookup_file_name, str(rec_list)) + ) + val_tuple = () + for val in rec_list: + if val != '': + val = val.strip() + val_tuple += (val,) + else: + raise Exception( + 'Empty value in phonetic lookup file %s" %s' + % (self.lookup_file_name, str(rec_list)) + ) + self.replace_table.append(val_tuple) + + # --------------------------------------------------------------------------- + + def __apply_change__(self, in_str, ch): + """Helper function which will apply the selected change to the input + string. + + Developed by Agus Pudjijono, ANU, 2008. + """ + + work_str = in_str + list_ch = ch.split('>') + subs = list_ch[1] + if list_ch[1] == '@': # @ is blank + subs = '' + tmp_str = work_str + org_pat_length = len(list_ch[0]) + str_length = len(work_str) + + if list_ch[2] == 'end': + org_pat_start = work_str.find(list_ch[0], str_length - org_pat_length) + elif list_ch[2] == 'middle': + org_pat_start = work_str.find(list_ch[0], 1) + else: # Start and all + org_pat_start = work_str.find(list_ch[0], 0) + + if org_pat_start == 0: + work_str = subs + work_str[org_pat_length:] + elif org_pat_start > 0: + work_str = ( + work_str[:org_pat_start] + + subs + + work_str[org_pat_start + org_pat_length :] + ) + + # if (work_str == tmp_str): + # work_str = str_to_change + + return work_str + + # --------------------------------------------------------------------------- + + def __slavo_germanic__(self, in_str): + """Helper function which determines if the inputstring could contain a + Slavo or Germanic name. + + Developed by Agus Pudjijono, ANU, 2008. + """ + + if ( + (in_str.find('w') > -1) + or (in_str.find('k') > -1) + or (in_str.find('cz') > -1) + or (in_str.find('witz') > -1) + ): + return 1 + else: + return 0 + + # --------------------------------------------------------------------------- + + def __collect_replacement__( + self, s, where, orgpat, newpat, precond, postcond, existcond, startcond + ): + """Helper function which collects all the possible phonetic modification + patterns that are possible on the given input string, and replaces a + pattern in a string. + + The following arguments are needed: + - where Can be one of: 'ALL','START','END','MIDDLE' + - precond Pre-condition (default 'None') can be 'V' for vowel or + 'C' for consonant + - postcond Post-condition (default 'None') can be 'V' for vowel or + 'C' for consonant + + Developed by Agus Pudjijono, ANU, 2008. + """ + + vowels = 'aeiouy' + tmpstr = s + changesstr = '' + + start_search = 0 # Position from where to start the search + pat_len = len(orgpat) + stop = False + + # As long as pattern is in string + # + while (orgpat in tmpstr[start_search:]) and (stop == False): + + pat_start = tmpstr.find(orgpat, start_search) + str_len = len(tmpstr) + + # Check conditions of previous and following character + # + OKpre = False # Previous character condition + OKpre1 = False # Previous character1 condition + OKpre2 = False # Previous character2 condition + + OKpost = False # Following character condition + OKpost1 = False # Following character1 condition + OKpost2 = False # Following character2 condition + + OKexist = False # Existing pattern condition + OKstart = False # Existing start pattern condition + + index = 0 + + if precond == 'None': + OKpre = True + + elif pat_start > 0: + if ((precond == 'V') and (tmpstr[pat_start - 1] in vowels)) or ( + (precond == 'C') and (tmpstr[pat_start - 1] not in vowels) + ): + OKpre = True + + elif (precond.find(';')) > -1: + if precond.find('|') > -1: + rls = precond.split('|') + rl1 = rls[0].split(';') + + if int(rl1[1]) < 0: + index = pat_start + int(rl1[1]) + else: + index = pat_start + (len(orgpat) - 1) + int(rl1[1]) + + i = 2 + if rl1[0] == 'n': + while i < (len(rl1)): + if tmpstr[index : (index + len(rl1[i]))] == rl1[i]: + OKpre1 = False + break + else: + OKpre1 = True + i += 1 + else: + while i < (len(rl1)): + if tmpstr[index : (index + len(rl1[i]))] == rl1[i]: + OKpre1 = True + break + i += 1 + + rl2 = rls[1].split(';') + + if int(rl2[1]) < 0: + index = pat_start + int(rl2[1]) + else: + index = pat_start + (len(orgpat) - 1) + int(rl2[1]) + + i = 2 + if rl2[0] == 'n': + while i < (len(rl2)): + if tmpstr[index : (index + len(rl2[i]))] == rl2[i]: + OKpre2 = False + break + else: + OKpre2 = True + i += 1 + else: + while i < (len(rl2)): + if tmpstr[index : (index + len(rl2[i]))] == rl2[i]: + OKpre2 = True + break + i += 1 + + OKpre = OKpre1 and OKpre2 + + else: + rl = precond.split(';') + # - + if int(rl[1]) < 0: + index = pat_start + int(rl[1]) + else: + index = pat_start + (len(orgpat) - 1) + int(rl[1]) + + i = 2 + if rl[0] == 'n': + while i < (len(rl)): + if tmpstr[index : (index + len(rl[i]))] == rl[i]: + OKpre = False + break + else: + OKpre = True + i += 1 + else: + while i < (len(rl)): + if tmpstr[index : (index + len(rl[i]))] == rl[i]: + OKpre = True + break + i += 1 + + if postcond == 'None': + OKpost = True + + else: + pat_end = pat_start + pat_len + + if pat_end < str_len: + if ((postcond == 'V') and (tmpstr[pat_end] in vowels)) or ( + (postcond == 'C') and (tmpstr[pat_end] not in vowels) + ): + OKpost = True + elif (postcond.find(';')) > -1: + if postcond.find('|') > -1: + rls = postcond.split('|') + + rl1 = rls[0].split(';') + + if int(rl1[1]) < 0: + index = pat_start + int(rl1[1]) + else: + index = pat_start + (len(orgpat) - 1) + int(rl1[1]) + + i = 2 + if rl1[0] == 'n': + while i < (len(rl1)): + if tmpstr[index : (index + len(rl1[i]))] == rl1[i]: + OKpost1 = False + break + else: + OKpost1 = True + i += 1 + else: + while i < (len(rl1)): + if tmpstr[index : (index + len(rl1[i]))] == rl1[i]: + OKpost1 = True + break + i += 1 + + rl2 = rls[1].split(';') + + if int(rl2[1]) < 0: + index = pat_start + int(rl2[1]) + else: + index = pat_start + (len(orgpat) - 1) + int(rl2[1]) + + i = 2 + if rl2[0] == 'n': + while i < (len(rl2)): + if tmpstr[index : (index + len(rl2[i]))] == rl2[i]: + OKpost2 = False + break + else: + OKpost2 = True + i += 1 + else: + while i < (len(rl2)): + if tmpstr[index : (index + len(rl2[i]))] == rl2[i]: + OKpost2 = True + break + i += 1 + + OKpost = OKpost1 and OKpost2 + + else: + rl = postcond.split(';') + + if int(rl[1]) < 0: + index = pat_start + int(rl[1]) + else: + index = pat_start + (len(orgpat) - 1) + int(rl[1]) + + i = 2 + if rl[0] == 'n': + while i < (len(rl)): + if tmpstr[index : (index + len(rl[i]))] == rl[i]: + OKpost = False + break + else: + OKpost = True + i += 1 + else: + while i < (len(rl)): + if tmpstr[index : (index + len(rl[i]))] == rl[i]: + OKpost = True + break + i += 1 + + if existcond == 'None': + OKexist = True + + else: + rl = existcond.split(';') + if rl[1] == 'slavo': + r = self.__slavo_germanic__(s) + if rl[0] == 'n': + if r == 0: + OKexist = True + else: + if r == 1: + OKexist = True + else: + i = 1 + if rl[0] == 'n': + while i < (len(rl)): + if s.find(rl[i]) > -1: + OKexist = False + break + else: + OKexist = True + i += i + else: + while i < (len(rl)): + if s.find(rl[i]) > -1: + OKexist = True + break + i += i + + if startcond == 'None': + OKstart = True + + else: + rl = startcond.split(';') + i = 1 + if rl[0] == 'n': + while i < (len(rl)): + if s.find(rl[i]) > -1: + OKstart = False + break + else: + OKstart = True + i += i + else: + while i < (len(rl)): + if s.find(rl[i]) == 0: + OKstart = True + break + i += i + + # Replace pattern if conditions and position OK + # + if ( + (OKpre == True) + and (OKpost == True) + and (OKexist == True) + and (OKstart == True) + ) and ( + ((where == 'START') and (pat_start == 0)) + or ( + (where == 'MIDDLE') + and (pat_start > 0) + and (pat_start + pat_len < str_len) + ) + or ((where == 'END') and (pat_start + pat_len == str_len)) + or (where == 'ALL') + ): + tmpstr = tmpstr[:pat_start] + newpat + tmpstr[pat_start + pat_len :] + changesstr += ',' + orgpat + '>' + newpat + '>' + where.lower() + start_search = pat_start + len(newpat) + + else: + start_search = pat_start + 1 + + if start_search >= (len(tmpstr) - 1): + stop = True + + tmpstr += changesstr + + return tmpstr + + # --------------------------------------------------------------------------- + + def __get_transformation__(self, in_str): + """Helper function which generates the list of possible phonetic + modifications for the given input string. + + Developed by Agus Pudjijono, ANU, 2008. + """ + + if in_str == '': + return in_str + + changesstr2 = '' + + workstr = in_str + + for rtpl in self.replace_table: # Check all transformations in the table + if len(rtpl) == 3: + rtpl += ('None', 'None', 'None', 'None') + + workstr = self.__collect_replacement__( + in_str, rtpl[0], rtpl[1], rtpl[2], rtpl[3], rtpl[4], rtpl[5], rtpl[6] + ) + if workstr.find(',') > -1: + tmpstr = workstr.split(',') + workstr = tmpstr[0] + if changesstr2.find(tmpstr[1]) == -1: + changesstr2 += tmpstr[1] + ';' + workstr += ',' + changesstr2 + + return workstr + + # --------------------------------------------------------------------------- + + def corrupt_value(self, in_str): + """Method which corrupts the given input string by applying a phonetic + modification. + + If several such modifications are possible then one will be randomly + selected. + """ + + if len(in_str) == 0: # Empty string, no modification possible + return in_str + + # Get the possible phonetic modifications for this input string + # + phonetic_changes = self.__get_transformation__(in_str) + + mod_str = in_str + + if ',' in phonetic_changes: # Several modifications possible + tmp_str = phonetic_changes.split(',') + pc = tmp_str[1][:-1] # Remove the last ';' + list_pc = pc.split(';') + change_op = random.choice(list_pc) + if change_op != '': + mod_str = self.__apply_change__(in_str, change_op) + # print in_str, mod_str, change_op + + return mod_str + + +# ============================================================================= + + +class CorruptCategoricalValue(CorruptValue): + """Replace a categorical value with another categorical value from the same + look-up file. + + This corruptor can be used to modify attribute values with known + misspellings. + + The look-up file is a CSV file with two columns, the first is a + categorical value that is expected to be in an attribute in an original + record, and the second is a variation of this categorical value. + + It is possible for an 'original' categorical value (first column) to have + several misspelling variations (second column). In such a case one + misspelling will be randomly selected. + + The additional arguments (besides the base class argument + 'position_function') that have to be set when this attribute type is + initialised are: + + lookup_file_name Name of the file which contains the categorical values + and their misspellings. + + has_header_line A flag, set to True or False, that has to be set + according to if the look-up file starts with a header + line or not. + + unicode_encoding The Unicode encoding (a string name) of the file. + + Note that the 'position_function' is not required by this corruptor + method. + """ + + # --------------------------------------------------------------------------- + + def __init__(self, **kwargs): + """Constructor. Process the derived keywords first, then call the base + class constructor. + """ + + self.lookup_file_name = None + self.has_header_line = None + self.unicode_encoding = None + self.misspell_dict = {} # The dictionary to hold the misspellings + self.name = 'Categorial value' + + def dummy_position(s): # Define a dummy position function + return 0 + + # Process all keyword arguments + # + base_kwargs = {} # Dictionary, will contain unprocessed arguments + + for (keyword, value) in kwargs.items(): + + if keyword.startswith('look'): + basefunctions.check_is_non_empty_string('lookup_file_name', value) + self.lookup_file_name = value + + elif keyword.startswith('has'): + basefunctions.check_is_flag('has_header_line', value) + self.has_header_line = value + + elif keyword.startswith('unicode'): + basefunctions.check_is_non_empty_string('unicode_encoding', value) + self.unicode_encoding = value + + else: + base_kwargs[keyword] = value + + base_kwargs['position_function'] = dummy_position + + CorruptValue.__init__(self, base_kwargs) # Process base arguments + + # Check if the necessary variables have been set + # + basefunctions.check_is_non_empty_string('lookup_file_name', self.lookup_file_name) + basefunctions.check_is_flag('has_header_line', self.has_header_line) + basefunctions.check_is_non_empty_string('unicode_encoding', self.unicode_encoding) + + # Load the misspelling lookup file - - - - - - - - - - - - - - - - - - - - - + # + header_list, lookup_file_data = basefunctions.read_csv_file( + self.lookup_file_name, self.unicode_encoding, self.has_header_line + ) + + # Process values from file and misspellings + # + for rec_list in lookup_file_data: + if len(rec_list) != 2: + raise Exception( + 'Illegal format in misspellings lookup file %s: %s' + % (self.lookup_file_name, str(rec_list)) + ) + + org_val = rec_list[0].strip() + if org_val == '': + raise Exception( + 'Empty original attribute value in lookup file %s' + % (self.lookup_file_name) + ) + misspell_val = rec_list[1].strip() + if misspell_val == '': + raise Exception( + 'Empty misspelled attribute value in lookup ' + + 'file %s' % (self.lookup_file_name) + ) + if org_val == misspell_val: + raise Exception( + 'Misspelled value is the same as original value' + + ' in lookup file %s' % (self.lookup_file_name) + ) + + this_org_val_list = self.misspell_dict.get(org_val, []) + this_org_val_list.append(misspell_val) + self.misspell_dict[org_val] = this_org_val_list + + # --------------------------------------------------------------------------- + + def corrupt_value(self, in_str): + """Method which corrupts the given input string and replaces it with a + misspelling, if there is a known misspelling for the given original + value. + + If there are several known misspellings for the given original value + then one will be randomly selected. + """ + + if len(in_str) == 0: # Empty string, no modification possible + return in_str + + if in_str not in self.misspell_dict: # No misspelling for this value + return in_str + + misspell_list = self.misspell_dict[in_str] + + return random.choice(misspell_list) + + +# ============================================================================= + + +class CorruptDataSet: + """Class which provides methods to corrupt the original records generated by + one of the classes derived from the GenerateDataSet base class. + + The following arguments need to be set when a GenerateDataSet instance is + initialised: + + number_of_mod_records The number of modified (corrupted) records that are + to be generated. This will correspond to the number + of 'duplicate' records that are generated. + + number_of_org_records The number of original records that were generated + by the GenerateDataSet class. + + attribute_name_list The list of attributes (fields) that have been + generated for each record. + + max_num_dup_per_rec The maximum number of modified (corrupted) records + that can be generated for a single original record. + + num_dup_dist The probability distribution used to create the + duplicate records for one original record (possible + distributions are: 'uniform', 'poisson', 'zipf') + + max_num_mod_per_attr The maximum number of modifications are to be + applied on a single attribute. + + num_mod_per_rec The number of modification that are to be applied + to a record + + attr_mod_prob_dict This dictionary contains probabilities that + determine how likely an attribute is selected for + random modification (corruption). + Keys are attribute names and values are probability + values. The sum of the given probabilities must sum + to 1.0. + Not all attributes need to be listed in this + dictionary, only the ones onto which modifications + are to be applied. + An example of such a dictionary is given below. + + attr_mod_data_dict A dictionary which contains for each attribute that + is to be modified a list which contains as pairs of + probabilities and corruptor objects (i.e. objects + based on any of the classes derived from base class + CorruptValue). + For each attribute listed, the sum of probabilities + given in its list must sum to 1.0. + An example of such a dictionary is given below. + + Example for 'attr_mod_prob_dict': + + attr_mod_prob_dict = {'surname':0.4, 'address':0.6} + + In this example, the surname attribute will be selected for modification + with a 40% likelihood and the address attribute with a 60% likelihood. + + Example for 'attr_mod_data_dict': + + attr_mod_data_dict = {'surname':[(0.25,corrupt_ocr), (0.50:corrupt_edit), + (0.25:corrupt_keyboard)], + 'address':[(0.50:corrupt_ocr), (0.20:missing_value), + (0.25:corrupt_keyboard)]} + + In this example, if the 'surname' is selected for modification, with a + 25% likelihood an OCR modification will be applied, with 50% likelihood a + character edit modification will be applied, and with 25% likelihood a + keyboard typing error modification will be applied. + If the 'address' attribute is selected, then with 50% likelihood an OCR + modification will be applied, with 20% likelihood a value will be set to + a missing value, and with 25% likelihood a keyboard typing error + modification will be applied. + """ + + # --------------------------------------------------------------------------- + + def __init__(self, **kwargs): + """Constructor, set attributes.""" + + self.number_of_mod_records = None + self.number_of_org_records = None + self.attribute_name_list = None + self.max_num_dup_per_rec = None + self.num_dup_dist = None + self.num_mod_per_rec = None + self.max_num_mod_per_attr = None + self.attr_mod_prob_dict = None + self.attr_mod_data_dict = None + + # Process the keyword arguments + # + for (keyword, value) in kwargs.items(): + + if keyword.startswith('number_of_m'): + basefunctions.check_is_integer('number_of_mod_records', value) + basefunctions.check_is_positive('number_of_mod_records', value) + self.number_of_mod_records = value + + elif keyword.startswith('number_of_o'): + basefunctions.check_is_integer('number_of_org_records', value) + basefunctions.check_is_positive('number_of_org_records', value) + self.number_of_org_records = value + + elif keyword.startswith('attribute'): + basefunctions.check_is_list('attribute_name_list', value) + self.attribute_name_list = value + + elif keyword.startswith('max_num_dup'): + basefunctions.check_is_integer('max_num_dup_per_rec', value) + basefunctions.check_is_positive('max_num_dup_per_rec', value) + self.max_num_dup_per_rec = value + + elif keyword.startswith('num_dup_'): + if value not in ['uniform', 'poisson', 'zipf']: + raise Exception( + 'Illegal value given for "num_dup_dist": %s' % (str(value)) + ) + self.num_dup_dist = value + + elif keyword.startswith('num_mod_per_r'): + basefunctions.check_is_integer('num_mod_per_rec', value) + basefunctions.check_is_positive('num_mod_per_rec', value) + self.num_mod_per_rec = value + + elif keyword.startswith('max_num_mod_per_a'): + basefunctions.check_is_integer('max_num_mod_per_attr', value) + basefunctions.check_is_positive('max_num_mod_per_attr', value) + self.max_num_mod_per_attr = value + + elif keyword.startswith('attr_mod_p'): + basefunctions.check_is_dictionary('attr_mod_prob_dict', value) + self.attr_mod_prob_dict = value + + elif keyword.startswith('attr_mod_d'): + basefunctions.check_is_dictionary('attr_mod_data_dict', value) + self.attr_mod_data_dict = value + + else: + raise Exception( + 'Illegal constructor argument keyword: "%s"' % (str(keyword)) + ) + + # Check if the necessary variables have been set + # + basefunctions.check_is_integer('number_of_mod_records', self.number_of_mod_records) + basefunctions.check_is_positive( + 'number_of_mod_records', self.number_of_mod_records + ) + basefunctions.check_is_integer('number_of_org_records', self.number_of_org_records) + basefunctions.check_is_positive( + 'number_of_org_records', self.number_of_org_records + ) + basefunctions.check_is_list('attribute_name_list', self.attribute_name_list) + basefunctions.check_is_integer('max_num_dup_per_rec', self.max_num_dup_per_rec) + basefunctions.check_is_positive('max_num_dup_per_rec', self.max_num_dup_per_rec) + basefunctions.check_is_string('num_dup_dist', self.num_dup_dist) + basefunctions.check_is_integer('num_mod_per_rec', self.num_mod_per_rec) + basefunctions.check_is_positive('num_mod_per_rec', self.num_mod_per_rec) + basefunctions.check_is_integer('max_num_mod_per_attr', self.max_num_mod_per_attr) + basefunctions.check_is_positive('max_num_mod_per_attr', self.max_num_mod_per_attr) + if self.max_num_mod_per_attr > self.num_mod_per_rec: + raise Exception( + 'Number of modifications per record must be larger' + + ' than maximum number of modifications per attribute' + ) + basefunctions.check_is_dictionary('attr_mod_prob_dict', self.attr_mod_prob_dict) + basefunctions.check_is_dictionary('attr_mod_data_dict', self.attr_mod_data_dict) + + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + # Check if it is possible to generate the desired number of modified + # (duplicate) corrupted records + # + if ( + self.number_of_mod_records + > self.number_of_org_records * self.max_num_dup_per_rec + ): + raise Exception( + 'Desired number of duplicates cannot be generated ' + + 'with given number of original records and maximum' + + ' number of duplicates per original record' + ) + + # Check if there are enough attributes given for modifications - - - - - - + # + if len(self.attr_mod_prob_dict) < self.num_mod_per_rec: + raise Exception( + 'Not enough attribute modifications given to obtain' + + ' the desired number of modifications per record' + ) + + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + # Create a distribution for the number of duplicates for an original record + # + num_dup = 1 + prob_sum = 0.0 + self.prob_dist_list = [(num_dup, prob_sum)] + + if self.num_dup_dist == 'uniform': + uniform_val = 1.0 / float(self.max_num_dup_per_rec) + + for i in range(self.max_num_dup_per_rec - 1): + num_dup += 1 + self.prob_dist_list.append( + (num_dup, uniform_val + self.prob_dist_list[-1][1]) + ) + + elif self.num_dup_dist == 'poisson': + + def fac(n): # Factorial of an integer number (recursive calculation) + if n > 1.0: + return n * fac(n - 1.0) + else: + return 1.0 + + poisson_num = [] # A list of poisson numbers + poisson_sum = 0.0 # The sum of all poisson number + + # The mean (lambda) for the poisson numbers + # + mean = 1.0 + ( + float(self.number_of_mod_records) / float(self.number_of_org_records) + ) + + for i in range(self.max_num_dup_per_rec): + poisson_num.append((math.exp(-mean) * (mean**i)) / fac(i)) + poisson_sum += poisson_num[-1] + + for i in range(self.max_num_dup_per_rec): # Scale so they sum up to 1.0 + poisson_num[i] = poisson_num[i] / poisson_sum + + for i in range(self.max_num_dup_per_rec - 1): + num_dup += 1 + self.prob_dist_list.append( + (num_dup, poisson_num[i] + self.prob_dist_list[-1][1]) + ) + + elif self.num_dup_dist == 'zipf': + zipf_theta = 0.5 + + denom = 0.0 + for i in range(self.number_of_org_records): + denom += 1.0 / (i + 1) ** (1.0 - zipf_theta) + + zipf_c = 1.0 / denom + zipf_num = [] # A list of Zipf numbers + zipf_sum = 0.0 # The sum of all Zipf number + + for i in range(self.max_num_dup_per_rec): + zipf_num.append(zipf_c / ((i + 1) ** (1.0 - zipf_theta))) + zipf_sum += zipf_num[-1] + + for i in range(self.max_num_dup_per_rec): # Scale so they sum up to 1.0 + zipf_num[i] = zipf_num[i] / zipf_sum + + for i in range(self.max_num_dup_per_rec - 1): + num_dup += 1 + self.prob_dist_list.append( + (num_dup, zipf_num[i] + self.prob_dist_list[-1][1]) + ) + + print('Probability distribution for number of duplicates per record:') + print(self.prob_dist_list) + + # Check probability list for attributes and dictionary for attributes - - - + # if they sum to 1.0 + # + attr_prob_sum = sum(self.attr_mod_prob_dict.values()) + if abs(attr_prob_sum - 1.0) > 0.0000001: + raise Exception( + 'Attribute modification probabilities do not sum ' + + 'to 1.0: %f' % (attr_prob_sum) + ) + for attr_name in self.attr_mod_prob_dict: + assert ( + self.attr_mod_prob_dict[attr_name] >= 0.0 + ), 'Negative probability given in "attr_mod_prob_dict"' + if attr_name not in self.attribute_name_list: + raise Exception( + 'Attribute name "%s" in "attr_mod_prob_dict" not ' % (attr_name) + + 'listed in "attribute_name_list"' + ) + + # Check details of attribute modification data dictionary + # + for (attr_name, attr_mod_data_list) in self.attr_mod_data_dict.items(): + if attr_name not in self.attribute_name_list: + raise Exception( + 'Attribute name "%s" in "attr_mod_data_dict" not ' % (attr_name) + + 'listed in "attribute_name_list"' + ) + basefunctions.check_is_list('attr_mod_data_dict entry', attr_mod_data_list) + prob_sum = 0.0 + for list_elem in attr_mod_data_list: + basefunctions.check_is_tuple('attr_mod_data_dict list element', list_elem) + assert len(list_elem) == 2, ( + 'attr_mod_data_dict list element does ' + 'not consist of two elements' + ) + basefunctions.check_is_normalised( + 'attr_mod_data_dict list probability', list_elem[0] + ) + prob_sum += list_elem[0] + if abs(prob_sum - 1.0) > 0.0000001: + raise Exception( + 'Probability sum is no 1.0 for attribute "%s"' % (attr_name) + ) + + # Generate a list with attribute probabilities summed for easy selection + # + self.attr_mod_prob_list = [] + prob_sum = 0 + for (attr_name, attr_prob) in self.attr_mod_prob_dict.items(): + prob_sum += attr_prob + self.attr_mod_prob_list.append([prob_sum, attr_name]) + # print self.attr_mod_prob_list + + # --------------------------------------------------------------------------- + + def corrupt_records(self, rec_dict): + """Method to corrupt modify the records in the given record dictionary + according to the settings of the data set corruptor. + """ + + # Check if number of records given is what is expected + # + assert self.number_of_org_records == len( + rec_dict + ), 'Illegal number of records to modify given' + + # First generate for each original record the number of duplicates that are + # to be generated for it. + # + dup_rec_num_dict = {} # Keys are the record identifiers of the original + # records, value their number of duplicates + total_num_dups = 0 # Total number of duplicates generated + + org_rec_id_list = list(rec_dict.keys()) + random.shuffle(org_rec_id_list) + + org_rec_i = 0 # Loop counter over which record to assign duplicates to + + while (org_rec_i < self.number_of_org_records) and ( + total_num_dups < self.number_of_mod_records + ): + + # Randomly choose how many duplicates to create for this original record + # + r = random.random() # Random number between 0.0 and 1.0 + ind = -1 + while self.prob_dist_list[ind][1] > r: + ind -= 1 + num_dups = self.prob_dist_list[ind][0] + + assert (num_dups > 0) and (num_dups <= self.max_num_dup_per_rec) + + # Check if there are still 'enough' duplicates to generate + # + if num_dups <= (self.number_of_mod_records - total_num_dups): + + # Select next record for which to generate duplicates + # + org_rec_id = org_rec_id_list[org_rec_i] + org_rec_i += 1 + dup_rec_num_dict[org_rec_id] = num_dups + total_num_dups += num_dups + + assert total_num_dups == sum(dup_rec_num_dict.values()) + + # Deal with the case where every original record has a number of duplicates + # but not enough duplicates are generated in total + # + org_rec_id_list = list(rec_dict.keys()) + random.shuffle(org_rec_id_list) + + while total_num_dups < self.number_of_mod_records: + org_rec_id = random.choice(org_rec_id_list) + + # If possible, increase number of duplicates for this record by 1 + # + if dup_rec_num_dict[org_rec_id] < self.max_num_dup_per_rec: + dup_rec_num_dict[org_rec_id] = dup_rec_num_dict[org_rec_id] + 1 + total_num_dups += 1 + + assert sum(dup_rec_num_dict.values()) == self.number_of_mod_records + + # Generate a histogram of number of duplicates per record + # + dup_histo = {} + for (org_rec_id_to_mod, num_dups) in dup_rec_num_dict.items(): + dup_count = dup_histo.get(num_dups, 0) + 1 + dup_histo[num_dups] = dup_count + print( + 'Distribution of number of original records with certain number ' + + 'of duplicates:' + ) + dup_histo_keys = list(dup_histo.keys()) + dup_histo_keys.sort() + for num_dups in dup_histo_keys: + print( + ' Number of records with %d duplicates: %d' + % (num_dups, dup_histo[num_dups]) + ) + print() + + num_dup_rec_created = 0 # Count how many duplicate records have been + # generated + + # Main loop over all original records for which to generate duplicates - - + # + for (org_rec_id_to_mod, num_dups) in dup_rec_num_dict.items(): + assert (num_dups > 0) and (num_dups <= self.max_num_dup_per_rec) + + print() + print( + 'Generating %d modified (duplicate) records for record "%s"' + % (num_dups, org_rec_id_to_mod) + ) + + rec_to_mod_list = rec_dict[org_rec_id_to_mod] + + d = 0 # Loop counter for duplicates for this record + + this_dup_rec_list = [] # A list of all duplicates for this record + + # Loop to create duplicate records - - - - - - - - - - - - - - - - - - - - + # + while d < num_dups: + + # Create a duplicate of the original record + # + dup_rec_list = rec_to_mod_list[:] # Make copy of original record + + org_rec_num = org_rec_id_to_mod.split('-')[1] + dup_rec_id = 'rec-%s-dup-%d' % (org_rec_num, d) + print( + ' Generate identifier for duplicate record based on "%s": %s' + % (org_rec_id_to_mod, dup_rec_id) + ) + + # Count the number of modifications in this record (counted as the + # number of modified attributes) + # + num_mod_in_record = 0 + + # Set the attribute modification counters to zero for all attributes + # that can be modified + # + attr_mod_count_dict = {} + for attr_name in self.attr_mod_prob_dict.keys(): + attr_mod_count_dict[attr_name] = 0 + + # Abort generating modifications after a larger number of tries to + # prevent an endless loop + # + max_num_tries = self.num_mod_per_rec * 10 + num_tries = 0 + + # Now apply desired number of modifications to this record + # + while (num_mod_in_record < self.num_mod_per_rec) and ( + num_tries < max_num_tries + ): + + # Randomly modify an attribute value + # + r = random.random() # Random value between 0.0 and 1.0 + i = 0 + while self.attr_mod_prob_list[i][0] < r: + i += 1 + mod_attr_name = self.attr_mod_prob_list[i][1] + + if attr_mod_count_dict[mod_attr_name] < self.max_num_mod_per_attr: + mod_attr_name_index = self.attribute_name_list.index(mod_attr_name) + mod_attr_val = dup_rec_list[mod_attr_name_index] + + # Select an attribute to modify according to probability + # distribution of corruption methods + # + attr_mod_data_list = self.attr_mod_data_dict[mod_attr_name] + + r = random.random() # Random value between 0.0 and 1.0 + p_sum = attr_mod_data_list[0][0] + i = 0 + while r >= p_sum: + i += 1 + p_sum += attr_mod_data_list[i][0] + corruptor_method = attr_mod_data_list[i][1] + + # Modify the value from the selected attribute + # + new_attr_val = corruptor_method.corrupt_value(mod_attr_val) + + org_attr_val = rec_to_mod_list[mod_attr_name_index] + + # If the modified value is different insert it back into modified + # record + # + if new_attr_val != org_attr_val: + print(' Selected attribute for modification:', mod_attr_name) + print(' Selected corruptor:', corruptor_method.name) + + # The following weird string printing construct is to overcome + # problems with printing non-ASCII characters + # + print( + ' Original attribute value:', + str([org_attr_val])[1:-1], + ) + print( + ' Modified attribute value:', + str([new_attr_val])[1:-1], + ) + + dup_rec_list[mod_attr_name_index] = new_attr_val + + # One more modification for this attribute + # + attr_mod_count_dict[mod_attr_name] += 1 + + # The number of modifications in a record corresponds to the + # number of modified attributes + # + num_mod_in_record = 0 + + for num_attr_mods in attr_mod_count_dict.values(): + if num_attr_mods > 0: + num_mod_in_record += 1 # One more modification + assert num_mod_in_record <= self.num_mod_per_rec + + num_tries += 1 # One more try to modify record + + # Check if this duplicate is different from all others for this original + # record + # + is_diff = True # Flag to check if the latest duplicate is different + + if this_dup_rec_list == []: # No duplicate so far + this_dup_rec_list.append(dup_rec_list) + else: + for check_dup_rec in this_dup_rec_list: + if check_dup_rec == dup_rec_list: # Same as a previous duplicate + is_diff = False + print('Same duplicate:', check_dup_rec) + print(' ', dup_rec_list) + + if is_diff == True: # Only keep duplicate records that are different + + # Safe the record into the overall record dictionary + # + rec_dict[dup_rec_id] = dup_rec_list + + d += 1 + num_dup_rec_created += 1 + + print('Original record:') + print(' ', rec_to_mod_list) + print( + 'Record with %d modified attributes' % (num_mod_in_record), + ) + attr_mod_str = '(' + for a in self.attribute_name_list: + if attr_mod_count_dict.get(a, 0) > 0: + attr_mod_str += '%d in %s, ' % (attr_mod_count_dict[a], a) + attr_mod_str = attr_mod_str[:-1] + '):' + print(attr_mod_str) + print(' ', dup_rec_list) + print( + '%d of %d duplicate records generated so far' + % (num_dup_rec_created, self.number_of_mod_records) + ) + print() + + return rec_dict + + +# ============================================================================= diff --git a/geco_data_generator/data/age-freq.csv b/geco_data_generator/data/age-freq.csv new file mode 100644 index 0000000000000000000000000000000000000000..2ce38a63255a7a428da62967df8da172c58f0479 --- /dev/null +++ b/geco_data_generator/data/age-freq.csv @@ -0,0 +1,17 @@ +# Example age distribution +# + +0,10 +1,11 +2,12 +3,14 +4,15 +5, +6, +7, + +.. + +99,1 +100,0.5 +120,1 diff --git a/geco_data_generator/data/city-gender-bloodpressure.csv b/geco_data_generator/data/city-gender-bloodpressure.csv new file mode 100644 index 0000000000000000000000000000000000000000..1a59c100dc7330e54028bf10440acaeb61be798e --- /dev/null +++ b/geco_data_generator/data/city-gender-bloodpressure.csv @@ -0,0 +1,13 @@ +# +canberra,10 +m,50,normal,120,12,None,None +f,50,normal,110,23,None,None +sydney,45 +m,45,normal,130,24,None,None +f,55,normal,105,40,None,None +melbourne,35 +f,45,normal,105,16,None,None +m,55,normal,117,19,None,None +hobart,10 +f,55,normal,100,10,None,None +m,48,normal,105,24,None,None diff --git a/geco_data_generator/data/gender-bloodpressure.csv b/geco_data_generator/data/gender-bloodpressure.csv new file mode 100644 index 0000000000000000000000000000000000000000..be65d9d806f7d5442e7d292e1fdf28a150780a71 --- /dev/null +++ b/geco_data_generator/data/gender-bloodpressure.csv @@ -0,0 +1,5 @@ +# Categorical-continuous attribute gender- blood pressure +# +m,40,normal,120,12,None,None +f,35,normal,110,23,None,None +n/a,25,normal,115,18,None,None diff --git a/geco_data_generator/data/gender-city-income.csv b/geco_data_generator/data/gender-city-income.csv new file mode 100644 index 0000000000000000000000000000000000000000..5851c125f13c177a16e9fbfa1e1e096d16501e2f --- /dev/null +++ b/geco_data_generator/data/gender-city-income.csv @@ -0,0 +1,13 @@ +# Look-up file for generating a compound attribute: gender / city / income. For details +# see module generator.py, class GenerateCateCateContCompoundAttribute +# +male,60 +canberra,20,uniform,50000,90000 +sydney,30,normal,75000,50000,20000,None +melbourne,30,uniform,35000,200000 +perth,20,normal,55000,250000,15000,None +female,40 +canberra,10,normal,45000,10000,None,150000 +sydney,40,uniform,60000,200000 +melbourne,20,uniform,50000,1750000 +brisbane,30,normal,55000,20000,20000,100000 diff --git a/geco_data_generator/data/gender-city-japanese.csv b/geco_data_generator/data/gender-city-japanese.csv new file mode 100644 index 0000000000000000000000000000000000000000..26d9f72ca39db3cee284db841786d94097a41765 --- /dev/null +++ b/geco_data_generator/data/gender-city-japanese.csv @@ -0,0 +1,10 @@ +# The first line in this look-up file is a header line +# Look-up file for generating a compound attribute: gender / city. For details +# see module generator.py, class GenerateCateCateCompoundAttribute +# +’j«,60,‰¡•l,7, \ +“Œ‹ž,30,é‹Ê,45, \ +ˆïé,18 +—«,40,‰¡•l,10,“Œ‹ž,40, \ +é‹Ê,20,ç—t,30,ŒQ”n,5,\ +ˆïéh,20 diff --git a/geco_data_generator/data/gender-city.csv b/geco_data_generator/data/gender-city.csv new file mode 100644 index 0000000000000000000000000000000000000000..638124fd12c7165bb3bde5a56e7aa169de72fa33 --- /dev/null +++ b/geco_data_generator/data/gender-city.csv @@ -0,0 +1,11 @@ +cate1,count-cate1,cate2,count-cate2 +# The first line in this look-up file is a header line +# Look-up file for generating a compound attribute: gender / city. For details +# see module generator.py, class GenerateCateCateCompoundAttribute +# +male,60,canberra,7, \ +sydney,30,melbourne,45, \ +perth,18 +female,40,canberra,10,sydney,40, \ +melbourne,20,brisbane,30,hobart,5,\ +perth,20 diff --git a/geco_data_generator/data/gender-income-data.csv b/geco_data_generator/data/gender-income-data.csv new file mode 100644 index 0000000000000000000000000000000000000000..e45b13eec1213a6e80725ef54aa188a0c69a46b8 --- /dev/null +++ b/geco_data_generator/data/gender-income-data.csv @@ -0,0 +1,6 @@ +# +male,55,10000-25000,15, 25000-50000,25, 50000-80000,20,\ +80000-120000,20, 120000-160000,10,160000-1000000,10 +female,45,10000-25000,20, 25000-50000,35, 50000-80000,25,\ +80000-120000,10, 120000-160000,5,160000-1000000,5 + diff --git a/geco_data_generator/data/gender-income.csv b/geco_data_generator/data/gender-income.csv new file mode 100644 index 0000000000000000000000000000000000000000..43c2f1d6d09bd4a22936a6d76c374d50bb55d05e --- /dev/null +++ b/geco_data_generator/data/gender-income.csv @@ -0,0 +1,6 @@ +# Look-up file for generating a compound attribute: gender / income. For details +# see module generator.py, class GenerateCateContCompoundAttribute +# +m,30,uniform,20000,100000 +f,40,normal,35000,100000,10000,None +na,30,normal,55000,45000,0,150000 diff --git a/geco_data_generator/data/givenname_f_freq.csv b/geco_data_generator/data/givenname_f_freq.csv new file mode 100644 index 0000000000000000000000000000000000000000..443d72981b625b70b7c03b2550f08e1c6ef3484f --- /dev/null +++ b/geco_data_generator/data/givenname_f_freq.csv @@ -0,0 +1,529 @@ +# ============================================================================= +# givenname_f_freq.csv - Frequency table for female given names +# +# Sources: - Compiled from various web sites +# +# Last update: 11/04/2002, Peter Christen +# ============================================================================= + +# ============================================================================= +# This table is in a two-column comma separated format, with the first column +# being the names and the second a corresponding frequency count. +# ============================================================================= + +aaliyah,1 +abbey,9 +abbie,2 +abby,4 +abigail,1 +abii,1 +adela,1 +adele,1 +adriana,1 +aikaterina,1 +aimee,2 +ainsley,1 +alaiyah,1 +alana,9 +alannah,2 +aleesha,1 +aleisha,2 +alessandra,2 +alessandria,1 +alessia,1 +alex,1 +alexa-rose,1 +alexandra,17 +alexia,1 +alexis,1 +alia,2 +alice,3 +alicia,5 +alisa,3 +alisha,2 +alison,1 +alissa,2 +alivia,1 +aliza,1 +allegra,1 +alysha,2 +alyssa,3 +amalia,1 +amaya,1 +amber,11 +ambrosia,1 +amelia,5 +amelie,1 +amy,15 +anari,1 +anastasia,1 +andie,1 +andrea,1 +aneka,1 +angelica,2 +angelina,1 +angie,1 +anika,1 +anita,1 +anna,1 +annabel,4 +annabella,1 +annabelle,4 +annalise,2 +anneliese,1 +annika,1 +anthea,1 +april,6 +arabella,3 +arki,1 +asha,1 +ashlee,1 +ashleigh,4 +ashley,1 +ashlie,1 +ashton,1 +aurora,1 +ava,2 +ayla,1 +bailee,3 +bailey,3 +belinda,1 +bella,2 +beth,1 +bethanie,1 +bethany,5 +bianca,5 +breana,1 +bree,1 +breeanne,1 +breony,1 +brianna,7 +bridget,4 +brielle,1 +brigette,1 +brigitte,1 +briley,1 +briony,1 +bronte,1 +brooke,11 +brooklyn,3 +brydee,1 +caitlin,16 +caitlyn,1 +callie,1 +cambell,1 +caresse,1 +carla,2 +carly,2 +carmen,1 +casey,4 +cassandra,3 +cassidy,1 +catherine,3 +channing,1 +chantelle,2 +charlee,1 +charli,1 +charlie,3 +charlize,1 +charlotte,17 +chelsea,12 +chelsie,1 +cheree,1 +chevonne,1 +cheyenne,1 +chloe,23 +christina,1 +claire,3 +claudia,3 +clodagh,1 +corie,1 +courtney,5 +crystal,1 +daniella,2 +danielle,5 +danika,1 +darcie,1 +darcy,1 +dayna,1 +delaney,1 +demie,1 +desi,1 +destynii,1 +diamond,1 +domenique,1 +eboni,1 +ebonie,1 +ebony,7 +elana,1 +eleanor,1 +eleni,1 +elise,1 +elisha,1 +eliza,7 +elizabeth,3 +ella,15 +elle,1 +ellen,3 +elli,1 +ellie,4 +ellorah,1 +ellouise,1 +elly,3 +eloise,1 +elysse,1 +emalene,1 +emerson,1 +emiily,48 +emma,16 +emmerson,1 +erin,14 +esme,1 +esther,1 +eva,2 +evangelia,1 +faith,1 +felicity,3 +finn,2 +fiona,1 +freya,2 +fyynlay,1 +gabriella,1 +gabrielle,4 +gemaley,1 +gemma,1 +genevieve,1 +georgia,19 +georgina,1 +giaan,1 +gillian,1 +giorgia,1 +giuliana,1 +grace,7 +gracie,2 +hana,1 +hanna,1 +hannah,17 +harley,1 +harriet,4 +hattie,1 +haylee,1 +hayley,7 +heather,1 +helena,1 +hollie,1 +holly,14 +imogen,9 +india,2 +indiana,2 +indyana,1 +irene,1 +isabel,1 +isabella,28 +isabelle,9 +isobel,1 +jacinta,3 +jacqueline,4 +jacynta,1 +jade,9 +jaime,2 +jaimee,1 +jamilla,1 +jaslyn,1 +jasmin,1 +jasmine,9 +jasmyn,2 +jayde,1 +jayme,1 +jazz,1 +jemima,1 +jemma,3 +jenna,4 +jennifer,1 +jessica,25 +jessie,1 +jinni,1 +joanna,1 +jordan,2 +jordyn,1 +jorja,1 +joselyn,1 +josephine,2 +julia,5 +juliana,3 +kaela,1 +kailey,2 +kaitlin,4 +kaitlyn,2 +kalli,1 +kallie,1 +karissa,1 +karla,1 +karlee,1 +karli,2 +kasey,1 +kate,3 +katelin,2 +katelyn,6 +katharine,1 +katherine,1 +kathleen,1 +katie,2 +kayla,5 +kaysey,1 +keahley,1 +keeley,2 +keelin,1 +keely,2 +keira,1 +kelsea,1 +kelsey,3 +kelsy,1 +kelsye,1 +keziah,1 +kiana,2 +kiandra,1 +kiara,2 +kiarnee,1 +kiera,2 +kierra,1 +kimberley,1 +kimberly,1 +kira,2 +kiria,1 +kirra,5 +kirrah,1 +koula,1 +kristen,2 +kristin,1 +krystin,1 +kyah,1 +kylee,3 +kylie,1 +kyra,1 +lacey,1 +laetitia,1 +laklynn,1 +lani,1 +lara,7 +larissa,2 +laura,5 +lauren,15 +layla,2 +leah,3 +lexie,1 +lia,1 +liana,1 +libby,1 +lilian,1 +lillian,1 +lillianna,1 +lilly,1 +lily,14 +livia,1 +logan,1 +louise,2 +lucinda,1 +lucy,13 +lushia,1 +lydia,1 +lynae,1 +macey,1 +mackenzi,1 +mackenzie,1 +macy,1 +madalyn,1 +maddison,4 +madeleine,6 +madeline,8 +madelyn,1 +madison,16 +maggie,1 +makayla,2 +makenzi,1 +makenzie,1 +maliah,1 +maria,1 +marianne,1 +marlee,1 +marleigh,1 +marley,1 +mary,1 +mathilde,1 +matilda,4 +matisse,2 +maya,3 +meagan,1 +meg,3 +megan,3 +meggie,1 +melanie,1 +melinda,1 +melissa,1 +mhary,1 +mia,12 +micaela,1 +michaela,3 +michelle,1 +mikaela,2 +mikayla,6 +mikhaili,1 +mikhayla,2 +mila,1 +millie,1 +miranda,1 +mollie,1 +molly,5 +monique,4 +montana,4 +montanna,1 +morgan,1 +mya,1 +mystique,1 +nacoya,1 +naomi,4 +nasyah,1 +natalee,1 +natalia,3 +natalie,1 +natasha,2 +natassia,1 +nell,1 +nellie,1 +nemesia,1 +neneh,1 +neve,1 +niamh,1 +nicola,1 +nicole,2 +nikita,2 +nikki,2 +olivia,18 +pace,1 +paige,4 +pakita,1 +paris,3 +pascale,1 +peta,1 +petreece,1 +peyton,1 +phoebe,5 +pia,1 +polly,1 +portia,1 +prudence,1 +rachael,1 +rachel,7 +raquel,1 +rebecca,4 +rebekah,2 +reegan,1 +reganne,1 +renai,1 +renee,2 +rhiannon,1 +riley,1 +roberta,1 +roisin,1 +rosa,1 +rosie,3 +ruby,14 +ryleh,1 +saara,1 +samantha,12 +samara,1 +sana,1 +sara,3 +sara-louise,1 +sarah,17 +sarsha,1 +sascha,2 +saskia,1 +savannah,1 +schkirra,1 +seanna,1 +serena,1 +shae,1 +shai,2 +shakira,1 +shakirah,1 +shana,1 +shanaye,1 +shandril,1 +shannon,1 +shantal,1 +shelbey,1 +shelby,2 +shenae,1 +shona,1 +sian,1 +sidonie,1 +sienna,3 +simone,2 +skye,1 +sonja,2 +sophie,30 +stella,1 +stephanie,10 +summer,1 +sybella,1 +sylvie,1 +taalia,1 +tabitha,1 +tahlia,4 +tahnee,1 +tahni,1 +takara,1 +takeisha,1 +talena,1 +talia,6 +taliah,3 +talissa,1 +talyah,1 +tansy,1 +tanyshah,1 +tara,10 +tarnee,1 +tarnia,1 +tarshya,1 +tayah,2 +tayla,2 +taylah,7 +taylor,3 +taylor-saige,1 +teagan,3 +teaha,1 +teal,1 +teegan,1 +tegan,1 +teileah,1 +teneille,1 +tenille,1 +teresa,1 +tess,2 +tia,1 +tiahana,1 +tiahnee,1 +tiana,3 +tiarna,3 +tiffany,1 +timara,1 +tori,1 +trinity,1 +tuscany,1 +tylah,1 +tyler,1 +vanessa,3 +vendula,1 +vianca,1 +victoria,3 +willow,1 +xani,1 +xanthe,1 +yana,1 +yasmin,3 +ysobel,1 +zali,3 +zara,2 +zarlia,1 +zoe,4 diff --git a/geco_data_generator/data/givenname_freq.csv b/geco_data_generator/data/givenname_freq.csv new file mode 100644 index 0000000000000000000000000000000000000000..9ad5d5730ca35777a688bfa015b5671b887f69c0 --- /dev/null +++ b/geco_data_generator/data/givenname_freq.csv @@ -0,0 +1,888 @@ +# ============================================================================= +# givenname_freq.csv - Frequency table for given names +# +# Sources: - Compiled from various web sites +# +# Last update: 22/03/2012, Peter Christen +# ============================================================================= + +# ============================================================================= +# This table is in a two-column comma separated format, with the first column +# being the names and the second a corresponding frequency count. +# ============================================================================= + +aaliyah,1 +abbey,9 +abbie,2 +abby,4 +abigail,1 +abii,1 +adela,1 +adele,1 +adriana,1 +aikaterina,1 +aimee,2 +ainsley,1 +alaiyah,1 +alana,9 +alannah,2 +aleesha,1 +aleisha,2 +alessandra,2 +alessandria,1 +alessia,1 +alexa-rose,1 +alexandra,17 +alexia,1 +alexis,1 +alia,2 +alice,3 +alicia,5 +alisa,3 +alisha,2 +alison,1 +alissa,2 +alivia,1 +aliza,1 +allegra,1 +alysha,2 +alyssa,3 +amalia,1 +amaya,1 +amber,11 +ambrosia,1 +amelia,5 +amelie,1 +amy,15 +anari,1 +anastasia,1 +andie,1 +andrea,1 +aneka,1 +angelica,2 +angelina,1 +angie,1 +anika,1 +anita,1 +anna,1 +annabel,4 +annabella,1 +annabelle,4 +annalise,2 +anneliese,1 +annika,1 +anthea,1 +april,6 +arabella,3 +arki,1 +asha,1 +ashlee,1 +ashleigh,4 +#ashley,1 +ashlie,1 +#ashton,1 +aurora,1 +ava,2 +ayla,1 +bailee,3 +#bailey,3 +belinda,1 +bella,2 +beth,1 +bethanie,1 +bethany,5 +bianca,5 +breana,1 +bree,1 +breeanne,1 +breony,1 +brianna,7 +bridget,4 +brielle,1 +brigette,1 +brigitte,1 +briley,1 +briony,1 +bronte,1 +brooke,11 +brooklyn,3 +brydee,1 +caitlin,16 +caitlyn,1 +callie,1 +cambell,1 +caresse,1 +carla,2 +carly,2 +carmen,1 +#casey,4 +cassandra,3 +cassidy,1 +catherine,3 +channing,1 +chantelle,2 +charlee,1 +charli,1 +#charlie,3 +charlize,1 +charlotte,17 +chelsea,12 +chelsie,1 +cheree,1 +chevonne,1 +cheyenne,1 +chloe,23 +christina,1 +claire,3 +claudia,3 +clodagh,1 +corie,1 +courtney,5 +crystal,1 +daniella,2 +danielle,5 +danika,1 +darcie,1 +#darcy,1 +dayna,1 +delaney,1 +demie,1 +desi,1 +destynii,1 +diamond,1 +domenique,1 +eboni,1 +ebonie,1 +ebony,7 +elana,1 +eleanor,1 +eleni,1 +elise,1 +elisha,1 +eliza,7 +elizabeth,3 +ella,15 +elle,1 +ellen,3 +elli,1 +ellie,4 +ellorah,1 +ellouise,1 +elly,3 +eloise,1 +elysse,1 +emalene,1 +emerson,1 +emiily,48 +emma,16 +emmerson,1 +erin,14 +esme,1 +esther,1 +eva,2 +evangelia,1 +faith,1 +felicity,3 +#finn,2 +fiona,1 +freya,2 +fyynlay,1 +gabriella,1 +gabrielle,4 +gemaley,1 +gemma,1 +genevieve,1 +georgia,19 +georgina,1 +giaan,1 +gillian,1 +giorgia,1 +giuliana,1 +grace,7 +gracie,2 +hana,1 +hanna,1 +hannah,17 +#harley,1 +harriet,4 +hattie,1 +haylee,1 +hayley,7 +heather,1 +helena,1 +hollie,1 +holly,14 +imogen,9 +india,2 +indiana,2 +indyana,1 +irene,1 +isabel,1 +isabella,28 +isabelle,9 +isobel,1 +jacinta,3 +jacqueline,4 +jacynta,1 +jade,9 +jaime,2 +jaimee,1 +jamilla,1 +jaslyn,1 +jasmin,1 +jasmine,9 +jasmyn,2 +#jayde,1 +jayme,1 +jazz,1 +jemima,1 +jemma,3 +jenna,4 +jennifer,1 +jessica,25 +jessie,1 +jinni,1 +joanna,1 +#jordan,2 +jordyn,1 +jorja,1 +joselyn,1 +josephine,2 +julia,5 +juliana,3 +kaela,1 +kailey,2 +kaitlin,4 +kaitlyn,2 +kalli,1 +kallie,1 +karissa,1 +karla,1 +karlee,1 +karli,2 +kasey,1 +kate,3 +katelin,2 +katelyn,6 +katharine,1 +katherine,1 +kathleen,1 +katie,2 +kayla,5 +kaysey,1 +keahley,1 +keeley,2 +keelin,1 +keely,2 +keira,1 +kelsea,1 +kelsey,3 +kelsy,1 +kelsye,1 +keziah,1 +kiana,2 +kiandra,1 +kiara,2 +kiarnee,1 +kiera,2 +kierra,1 +kimberley,1 +kimberly,1 +kira,2 +kiria,1 +kirra,5 +kirrah,1 +koula,1 +kristen,2 +kristin,1 +krystin,1 +kyah,1 +kylee,3 +kylie,1 +kyra,1 +lacey,1 +laetitia,1 +laklynn,1 +lani,1 +lara,7 +larissa,2 +laura,5 +lauren,15 +layla,2 +leah,3 +lexie,1 +lia,1 +liana,1 +libby,1 +lilian,1 +lillian,1 +lillianna,1 +lilly,1 +lily,14 +livia,1 +#logan,1 +louise,2 +lucinda,1 +lucy,13 +lushia,1 +lydia,1 +lynae,1 +macey,1 +mackenzi,1 +#mackenzie,1 +macy,1 +madalyn,1 +maddison,4 +madeleine,6 +madeline,8 +madelyn,1 +madison,16 +maggie,1 +makayla,2 +makenzi,1 +makenzie,1 +maliah,1 +maria,1 +marianne,1 +marlee,1 +marleigh,1 +marley,1 +mary,1 +mathilde,1 +matilda,4 +matisse,2 +maya,3 +meagan,1 +meg,3 +megan,3 +meggie,1 +melanie,1 +melinda,1 +melissa,1 +mhary,1 +mia,12 +micaela,1 +michaela,3 +michelle,1 +mikaela,2 +mikayla,6 +mikhaili,1 +mikhayla,2 +mila,1 +millie,1 +miranda,1 +mollie,1 +molly,5 +monique,4 +montana,4 +montanna,1 +morgan,1 +mya,1 +mystique,1 +nacoya,1 +naomi,4 +nasyah,1 +natalee,1 +natalia,3 +natalie,1 +natasha,2 +natassia,1 +nell,1 +nellie,1 +nemesia,1 +neneh,1 +neve,1 +niamh,1 +nicola,1 +nicole,2 +nikita,2 +nikki,2 +olivia,18 +pace,1 +paige,4 +pakita,1 +paris,3 +pascale,1 +peta,1 +petreece,1 +peyton,1 +phoebe,5 +pia,1 +polly,1 +portia,1 +prudence,1 +rachael,1 +rachel,7 +raquel,1 +rebecca,4 +rebekah,2 +reegan,1 +reganne,1 +renai,1 +renee,2 +rhiannon,1 +#riley,1 +roberta,1 +roisin,1 +rosa,1 +rosie,3 +ruby,14 +ryleh,1 +saara,1 +samantha,12 +samara,1 +sana,1 +sara,3 +sara-louise,1 +sarah,17 +sarsha,1 +sascha,2 +saskia,1 +savannah,1 +schkirra,1 +seanna,1 +serena,1 +shae,1 +shai,2 +shakira,1 +shakirah,1 +shana,1 +shanaye,1 +shandril,1 +#shannon,1 +shantal,1 +shelbey,1 +shelby,2 +shenae,1 +shona,1 +sian,1 +sidonie,1 +sienna,3 +simone,2 +skye,1 +sonja,2 +sophie,30 +stella,1 +stephanie,10 +summer,1 +sybella,1 +sylvie,1 +taalia,1 +tabitha,1 +tahlia,4 +tahnee,1 +tahni,1 +takara,1 +takeisha,1 +talena,1 +talia,6 +taliah,3 +talissa,1 +talyah,1 +tansy,1 +tanyshah,1 +tara,10 +tarnee,1 +tarnia,1 +tarshya,1 +tayah,2 +tayla,2 +taylah,7 +taylor,3 +taylor-saige,1 +teagan,3 +teaha,1 +teal,1 +teegan,1 +tegan,1 +teileah,1 +teneille,1 +tenille,1 +teresa,1 +tess,2 +tia,1 +tiahana,1 +tiahnee,1 +tiana,3 +tiarna,3 +tiffany,1 +timara,1 +tori,1 +trinity,1 +tuscany,1 +tylah,1 +#tyler,1 +vanessa,3 +vendula,1 +vianca,1 +victoria,3 +willow,1 +xani,1 +xanthe,1 +yana,1 +yasmin,3 +ysobel,1 +zali,3 +zara,2 +zarlia,1 +zoe,4 +aaron,2 +adam,10 +adrian,1 +aidan,6 +aiden,3 +aidyn,1 +ajay,1 +alec,1 +alex,4 +alexander,15 +aloysius,1 +andrew,10 +angus,3 +anthony,3 +anton,1 +antonio,1 +archer,2 +archie,2 +arren,1 +ash,1 +ashley,1 +ashton,1 +ayden,1 +bailey,11 +bailley,1 +barkly,1 +barnaby,2 +baxter,1 +bayden,1 +bayley,2 +beau,2 +ben,2 +benedict,1 +benjamin,31 +bertie,1 +billy,1 +blade,1 +blaize,1 +blake,11 +blakeston,1 +blayke,1 +bodhi,1 +bradley,3 +braedon,3 +braiden,1 +brandon,2 +brayden,2 +brendan,1 +brett,1 +brinley,1 +brock,1 +brodee,2 +brodie,2 +brody,3 +bryce,2 +brydon,1 +byron,1 +cade,1 +cain,2 +caleb,10 +callum,7 +calvin,1 +cameron,9 +campbell,4 +carlin,2 +casey,1 +charles,4 +charlie,6 +chase,1 +christian,6 +christopher,5 +ciaran,1 +clain,1 +clement,1 +coby,2 +connor,18 +cooper,13 +corey,1 +d'arcy,1 +daen,1 +dakota,1 +dale,2 +damien,2 +daniel,21 +daniele,1 +danjel,1 +danny,1 +dante,4 +darcy,3 +david,5 +deakin,4 +deakyn,1 +dean,2 +declan,1 +declen,1 +devan,1 +dillon,2 +dimitri,1 +dominic,2 +douglas,1 +drew,1 +dylan,13 +eden,1 +edward,3 +elijah,1 +elki,1 +elton,1 +emmet,1 +ethan,19 +evan,4 +ewan,1 +fergus,2 +finlay,3 +finley,1 +finn,3 +finnbar,1 +flynn,7 +francesco,1 +fraser,2 +fynn,1 +gabriel,3 +garth,1 +george,4 +gianni,3 +grayson,1 +gregory,1 +griffin,1 +gus,1 +hamish,4 +hari,1 +harley,2 +harrison,18 +harry,14 +harvey,1 +hayden,9 +heath,2 +henry,5 +hudson,1 +hugh,2 +hugo,3 +hunter,1 +iain,1 +isaac,4 +isaiah,1 +izaac,1 +jack,35 +jackson,12 +jacob,20 +jacobie,1 +jaden,2 +jaggah,1 +jai,3 +jaiden,2 +jairus,1 +jake,14 +jakob,1 +james,28 +jamie,5 +jared,4 +jarod,1 +jarred,1 +jarrod,2 +jarryd,1 +jarvis,1 +jason,1 +jasper,5 +jassim,1 +jaxin,1 +jaxson,1 +jay,1 +jayde,1 +jayden,10 +jaykob,1 +jean-claude,1 +jed,2 +jeremiah,1 +jeremy,1 +jesse,5 +jett,2 +jock,1 +joe,2 +joel,20 +john,3 +john-paul,1 +jonah,1 +jonathon,1 +jordan,11 +jory,1 +joseph,1 +joshua,50 +judah,1 +justin,1 +jye,4 +ka,1 +kade,1 +kadin,1 +kai,3 +kale,1 +kaleb,1 +kane,6 +kayden,1 +kayne,1 +kazuki,1 +keaton,1 +keegan,1 +kenneth,1 +kieran,1 +kieren,2 +kobe,3 +koben,1 +kody,1 +konstantinos,1 +kristo,1 +ky,1 +kydan,1 +kye,2 +kyle,16 +kynan,2 +lachlan,32 +lachlan-john,1 +latham,1 +lawson,1 +lee,1 +leo,2 +leon,2 +levi,2 +lewis,5 +liam,24 +lochlan,2 +logan,3 +louis,2 +luca,1 +lucas,10 +luka,1 +lukas,2 +luke,18 +lynton,1 +mackenzie,1 +mackinley,1 +maconal,1 +macormack,1 +magnus,1 +malakai,1 +marco,1 +marcus,4 +mark,1 +marko,1 +mason,2 +matteus,1 +mattheo,1 +matthew,22 +max,7 +maxin,1 +micah,1 +michael,20 +millane,1 +miller,1 +mitchell,22 +nathan,14 +ned,3 +nicholas,25 +nicolas,1 +noah,13 +oakleigh,1 +oliver,14 +oscar,6 +owen,1 +patrick,6 +paul,1 +pearson,1 +peter,3 +philip,1 +phillip,1 +phoenix,1 +pino,1 +quinn,2 +reece,1 +reeve,1 +reuben,2 +rhett,1 +rhys,3 +richard,2 +ridley,1 +riley,17 +robbie,2 +robert,4 +robin,1 +rohan,1 +ronan,1 +rory,1 +rourke,1 +roy,1 +ruben,1 +rupert,1 +ryan,10 +ryley,1 +sachin,2 +sam,8 +samir,1 +samuel,19 +scott,2 +seamus,1 +sean,4 +sebastian,4 +seth,3 +shane,3 +shannon,1 +shaun,2 +shawn,1 +silas,2 +simon,1 +solomon,1 +spencer,1 +spyke,1 +stelio,1 +stephen,1 +steven,1 +stirling,1 +tai,1 +talan,1 +tanar,1 +tasman,1 +tate,1 +thomas,33 +timothy,11 +toby,5 +todd,1 +tom,1 +tommi-lee,1 +tommy,2 +tony,1 +travis,3 +trent,1 +trevor,1 +trey,2 +tristan,3 +troy,2 +ty,1 +tyler,5 +tynan,2 +tyron,1 +tyrone,1 +vincent,1 +wade,1 +warrick,1 +wil,1 +will,1 +william,26 +wilson,4 +xavier,3 +xepheren,1 +zac,7 +zach,1 +zachariah,2 +zachary,13 +zack,1 +zakariah,1 +zane,4 +zarran,1 +zebediah,1 diff --git a/geco_data_generator/data/givenname_m_freq.csv b/geco_data_generator/data/givenname_m_freq.csv new file mode 100644 index 0000000000000000000000000000000000000000..96cf73e1f68c485bbe8b42f7afb737f803d39816 --- /dev/null +++ b/geco_data_generator/data/givenname_m_freq.csv @@ -0,0 +1,373 @@ +# ============================================================================= +# givenname_m_freq.csv - Frequency table for male given names +# +# Sources: - Compiled from various web sites +# +# Last update: 11/04/2002, Peter Christen +# ============================================================================= + +# ============================================================================= +# This table is in a two-column comma separated format, with the first column +# being the names and the second a corresponding frequency count. +# ============================================================================= + +aaron,2 +adam,10 +adrian,1 +aidan,6 +aiden,3 +aidyn,1 +ajay,1 +alec,1 +alex,4 +alexander,15 +aloysius,1 +andrew,10 +angus,3 +anthony,3 +anton,1 +antonio,1 +archer,2 +archie,2 +arren,1 +ash,1 +ashley,1 +ashton,1 +ayden,1 +bailey,11 +bailley,1 +barkly,1 +barnaby,2 +baxter,1 +bayden,1 +bayley,2 +beau,2 +ben,2 +benedict,1 +benjamin,31 +bertie,1 +billy,1 +blade,1 +blaize,1 +blake,11 +blakeston,1 +blayke,1 +bodhi,1 +bradley,3 +braedon,3 +braiden,1 +brandon,2 +brayden,2 +brendan,1 +brett,1 +brinley,1 +brock,1 +brodee,2 +brodie,2 +brody,3 +bryce,2 +brydon,1 +byron,1 +cade,1 +cain,2 +caleb,10 +callum,7 +calvin,1 +cameron,9 +campbell,4 +carlin,2 +casey,1 +charles,4 +charlie,6 +chase,1 +christian,6 +christopher,5 +ciaran,1 +clain,1 +clement,1 +coby,2 +connor,18 +cooper,13 +corey,1 +d'arcy,1 +daen,1 +dakota,1 +dale,2 +damien,2 +daniel,21 +daniele,1 +danjel,1 +danny,1 +dante,4 +darcy,3 +david,5 +deakin,4 +deakyn,1 +dean,2 +declan,1 +declen,1 +devan,1 +dillon,2 +dimitri,1 +dominic,2 +douglas,1 +drew,1 +dylan,13 +eden,1 +edward,3 +elijah,1 +elki,1 +elton,1 +emmet,1 +ethan,19 +evan,4 +ewan,1 +fergus,2 +finlay,3 +finley,1 +finn,3 +finnbar,1 +flynn,7 +francesco,1 +fraser,2 +fynn,1 +gabriel,3 +garth,1 +george,4 +gianni,3 +grayson,1 +gregory,1 +griffin,1 +gus,1 +hamish,4 +hari,1 +harley,2 +harrison,18 +harry,14 +harvey,1 +hayden,9 +heath,2 +henry,5 +hudson,1 +hugh,2 +hugo,3 +hunter,1 +iain,1 +isaac,4 +isaiah,1 +izaac,1 +jack,35 +jackson,12 +jacob,20 +jacobie,1 +jaden,2 +jaggah,1 +jai,3 +jaiden,2 +jairus,1 +jake,14 +jakob,1 +james,28 +jamie,5 +jared,4 +jarod,1 +jarred,1 +jarrod,2 +jarryd,1 +jarvis,1 +jason,1 +jasper,5 +jassim,1 +jaxin,1 +jaxson,1 +jay,1 +jayde,1 +jayden,10 +jaykob,1 +jean-claude,1 +jed,2 +jeremiah,1 +jeremy,1 +jesse,5 +jett,2 +jock,1 +joe,2 +joel,20 +john,3 +john-paul,1 +jonah,1 +jonathon,1 +jordan,11 +jory,1 +joseph,1 +joshua,50 +judah,1 +justin,1 +jye,4 +ka,1 +kade,1 +kadin,1 +kai,3 +kale,1 +kaleb,1 +kane,6 +kayden,1 +kayne,1 +kazuki,1 +keaton,1 +keegan,1 +kenneth,1 +kieran,1 +kieren,2 +kobe,3 +koben,1 +kody,1 +konstantinos,1 +kristo,1 +ky,1 +kydan,1 +kye,2 +kyle,16 +kynan,2 +lachlan,32 +lachlan-john,1 +latham,1 +lawson,1 +lee,1 +leo,2 +leon,2 +levi,2 +lewis,5 +liam,24 +lochlan,2 +logan,3 +louis,2 +luca,1 +lucas,10 +luka,1 +lukas,2 +luke,18 +lynton,1 +mackenzie,1 +mackinley,1 +maconal,1 +macormack,1 +magnus,1 +malakai,1 +marco,1 +marcus,4 +mark,1 +marko,1 +mason,2 +matteus,1 +mattheo,1 +matthew,22 +max,7 +maxin,1 +micah,1 +michael,20 +millane,1 +miller,1 +mitchell,22 +nathan,14 +ned,3 +nicholas,25 +nicolas,1 +noah,13 +oakleigh,1 +oliver,14 +oscar,6 +owen,1 +patrick,6 +paul,1 +pearson,1 +peter,3 +philip,1 +phillip,1 +phoenix,1 +pino,1 +quinn,2 +reece,1 +reeve,1 +reuben,2 +rhett,1 +rhys,3 +richard,2 +ridley,1 +riley,17 +robbie,2 +robert,4 +robin,1 +rohan,1 +ronan,1 +rory,1 +rourke,1 +roy,1 +ruben,1 +rupert,1 +ryan,10 +ryley,1 +sachin,2 +sam,8 +samir,1 +samuel,19 +scott,2 +seamus,1 +sean,4 +sebastian,4 +seth,3 +shane,3 +shannon,1 +shaun,2 +shawn,1 +silas,2 +simon,1 +solomon,1 +spencer,1 +spyke,1 +stelio,1 +stephen,1 +steven,1 +stirling,1 +tai,1 +talan,1 +tanar,1 +tasman,1 +tate,1 +thomas,33 +timothy,11 +toby,5 +todd,1 +tom,1 +tommi-lee,1 +tommy,2 +tony,1 +travis,3 +trent,1 +trevor,1 +trey,2 +tristan,3 +troy,2 +ty,1 +tyler,5 +tynan,2 +tyron,1 +tyrone,1 +vincent,1 +wade,1 +warrick,1 +wil,1 +will,1 +william,26 +wilson,4 +xavier,3 +xepheren,1 +zac,7 +zach,1 +zachariah,2 +zachary,13 +zack,1 +zakariah,1 +zane,4 +zarran,1 +zebediah,1 diff --git a/geco_data_generator/data/ocr-variations-upper-lower.csv b/geco_data_generator/data/ocr-variations-upper-lower.csv new file mode 100644 index 0000000000000000000000000000000000000000..7936cdb72990a128b36ba3161fca7e49b4bcb46a --- /dev/null +++ b/geco_data_generator/data/ocr-variations-upper-lower.csv @@ -0,0 +1,51 @@ +# OCR character variations +# +5,S +5,s +2,Z +2,z +1,| +6,G +g,9 +q,9 +q,4 +B,8 +A,4 +0,o +0,O +m,n +u,v +U,V +Y,V +y,v +D,O +Q,O +F,P +E,F +l,J +j,i +l,1 +g,q +h,b +l,I +i,'l +13,B +12,R +17,n +iii,m +cl,d +w,vv +ri,n +k,lc +lo,b +IJ,U +lJ,U +LI,U +I-I,H +l>,b +1>,b +l<,k +1<,k +m,rn +l,| +i,: diff --git a/geco_data_generator/data/ocr-variations.csv b/geco_data_generator/data/ocr-variations.csv new file mode 100644 index 0000000000000000000000000000000000000000..89c62d79ec5409f0fbf670fd49c339d74f9c88dd --- /dev/null +++ b/geco_data_generator/data/ocr-variations.csv @@ -0,0 +1,31 @@ +# OCR character variations +# +5,s +2,z +1,| +g,9 +q,9 +q,4 +0,o +m,n +u,v +y,v +j,l +j,i +l,1 +h,b +l,i +i,'l +iii,m +cl,d +w,vv +ri,n +k,lc +lo,b +l>,b +1>,b +l<,k +1<,k +m,rn +l,| +i,: diff --git a/geco_data_generator/data/phonetic-variations.csv b/geco_data_generator/data/phonetic-variations.csv new file mode 100644 index 0000000000000000000000000000000000000000..da455c794949baa4ec3f79af284342b944444207 --- /dev/null +++ b/geco_data_generator/data/phonetic-variations.csv @@ -0,0 +1,358 @@ +# Phonetic variation patterns, developed by Agus Pudjijono, ANU, 2008 +# +ALL,h,@,None,None,None,None +END,e,@,None,None,None,None +ALL,t,d,None,None,None,None +ALL,d,t,None,None,None,None +ALL,c,k,None,None,None,None +ALL,w,@,None,None,None,None +ALL,nn,n,None,None,None,None +ALL,ll,l,None,None,None,None +ALL,ee,i,None,None,None,None +ALL,z,s,None,None,None,None +ALL,s,z,None,None,None,None +ALL,ie,i,None,None,None,None +END,y,i,None,None,None,None +ALL,g,k,None,None,None,None +ALL,th,t,None,None,None,None +ALL,rr,r,None,None,None,None +ALL,b,p,None,None,None,None +ALL,j,s,None,None,None,None +ALL,ey,y,None,None,None,None +ALL,s,j,None,None,None,None +ALL,tt,t,None,None,None,None +ALL,ei,i,None,None,None,None +ALL,ou,o,None,None,None,None +ALL,au,o,None,None,None,None +ALL,ck,k,None,None,None,None +ALL,ia,ya,None,None,None,None +ALL,j,z,None,None,None,None +ALL,z,j,None,None,None,None +ALL,k,ck,None,None,None,None +ALL,ya,ia,None,None,None,None +ALL,v,f,None,None,None,None +ALL,f,v,None,None,None,None +ALL,s,st,None,None,None,None +ALL,oo,u,None,None,None,None +ALL,ph,f,None,None,None,None +ALL,mm,m,None,None,None,None +ALL,ce,se,None,None,None,None +ALL,ry,rie,None,None,None,None +ALL,rie,ry,None,None,None,None +ALL,ff,f,None,None,None,None +ALL,x,@,None,None,None,None +ALL,q,k,None,None,None,None +END,ss,s,None,None,None,None +MIDDLE,j,y,V,V,None,None +ALL,sh,x,None,None,None,None +START,ha,h,None,None,None,None +ALL,ng,nk,None,None,None,None +END,es,s,None,None,None,None +ALL,pp,p,None,None,None,None +START,ch,x,None,None,None,None +ALL,dd,t,None,None,None,None +ALL,nk,ng,None,None,None,None +ALL,sch,sh,None,None,None,None +ALL,ci,si,None,None,None,None +ALL,aa,ar,None,None,None,None +ALL,kk,k,None,None,None,None +START,ho,h,None,None,None,None +END,ee,ea,None,None,None,None +END,sz,s,None,None,None,None +START,ts,t,None,V,None,None +ALL,sz,s,None,None,None,None +ALL,cc,k,None,None,None,None +ALL,gg,k,None,None,None,None +START,he,h,None,None,None,None +MIDDLE,gh,@,y;-2;b;h;d,None,None,None +END,r,ah,V,None,None,None +ALL,tch,ch,None,None,None,None +START,hu,h,None,None,None,None +MIDDLE,ch,x,None,None,None,None +MIDDLE,z,s,None,V,None,None +ALL,zz,s,None,None,None,None +END,re,ar,None,None,None,None +START,sl,s,None,None,None,None +ALL,cia,sia,None,None,None,None +START,oh,h,None,None,None,None +ALL,bb,p,None,None,None,None +ALL,sc,sk,None,None,None,None +ALL,cy,si,None,None,None,None +START,ah,h,None,None,None,None +ALL,zs,s,None,None,None,None +ALL,ca,ka,None,None,None,None +ALL,dg,g,None,None,None,None +ALL,yth,ith,None,None,None,None +ALL,cy,sy,None,None,None,None +START,kn,n,None,None,None,None +START,sn,s,None,None,None,None +START,hi,h,None,None,None,None +ALL,wha,wa,None,None,None,None +START,sm,s,None,None,None,None +ALL,isl,il,None,None,None,None +END,gh,e,V,None,None,None +ALL,co,ko,None,None,None,None +MIDDLE,gi,ji,None,None,None,None +ALL,cio,sio,None,None,None,None +END,ss,as,V,None,None,None +END,gn,n,None,None,None,None +END,gne,n,None,None,None,None +ALL,mps,ms,None,None,None,None +END,le,ile,C,None,None,None +ALL,whi,wi,None,None,None,None +ALL,tia,xia,None,None,None,None +MIDDLE,stl,sl,V,None,None,None +END,sch,x,None,None,None,None +ALL,cia,xia,None,None,None,None +ALL,jj,j,None,None,None,None +START,cy,s,None,None,None,None +MIDDLE,sch,x,None,None,None,None +ALL,cie,sie,None,None,None,None +START,cz,c,None,None,None,None +START,eh,h,None,None,None,None +ALL,tch,x,None,None,None,None +ALL,mpt,mt,None,None,None,None +ALL,cg,k,None,None,None,None +ALL,umb,um,None,None,None,None +ALL,gh,k,n;-1;i,None,None,None +START,hy,h,None,None,None,None +START,gn,n,None,None,None,None +ALL,sce,se,None,None,None,None +ALL,sci,si,None,None,None,None +END,hr,ah,V,None,None,None +END,mb,m,V,None,None,None +ALL,lough,low,None,None,None,None +ALL,why,wy,None,None,None,None +ALL,ght,t,None,None,None,None +ALL,whe,we,None,None,None,None +ALL,rz,rsh,None,None,None,None +START,chr,kr,None,V,None,None +ALL,cq,k,None,None,None,None +ALL,ghn,n,None,None,None,None +START,x,s,None,None,None,None +END,dl,dil,None,None,None,None +START,mn,n,None,V,None,None +START,pt,t,None,None,None,None +ALL,lle,le,None,None,None,None +ALL,qq,k,None,None,None,None +START,chh,kh,None,None,None,None +START,ih,h,None,None,None,None +MIDDLE,lj,ld,V,V,None,None +ALL,zz,ts,None,None,None,None +MIDDLE,ach,k,None,n;1;i;e,None,None +END,dt,t,None,None,None,None +ALL,td,t,None,None,None,None +END,ned,nd,None,None,None,None +ALL,lz,lsh,None,None,None,None +ALL,ghne,ne,None,None,None,None +MIDDLE,z,ts,C,None,None,None +START,cl,kl,None,V,None,None +START,pf,f,None,None,None,None +START,uh,h,None,None,None,None +START,tj,ch,None,V,None,None +START,gh,g,None,None,None,None +MIDDLE,gy,ky,n;-1;e;i,None,n;rgy;ogy,None +MIDDLE,r,ah,V,C,None,None +MIDDLE,cz,ch,None,None,None,None +ALL,cci,xi,None,None,None,None +END,tl,til,None,None,None,None +ALL,ough,of,None,None,None,None +ALL,ff,v,None,None,None,None +START,cr,kr,None,V,None,None +START,gh,@,None,None,None,None +ALL,cu,ku,None,None,None,None +MIDDLE,aggi,aji,None,None,None,None +END,ew,e,None,None,None,None +ALL,nc,nk,None,None,None,None +START,ps,s,None,None,None,None +ALL,xx,@,None,None,None,None +ALL,who,wo,None,None,None,None +ALL,wr,r,None,None,None,None +END,ow,o,None,None,None,None +ALL,sholm,solm,None,None,None,None +ALL,vv,f,None,None,None,None +ALL,gh,f,y;-1;u|y;-3;c;g;l;r;t,None,None,None +ALL,wh,h,None,None,None,None +ALL,wicz,wis,None,None,None,None +MIDDLE,q,kw,V,V,None,None +ALL,ysl,yl,None,None,None,None +ALL,vv,ff,None,None,None,None +ALL,ff,vv,None,None,None,None +START,pn,n,None,V,None,None +START,ghi,j,None,None,None,None +START,gin,kin,None,None,None,None +ALL,dge,je,None,None,None,None +ALL,whu,wu,None,None,None,None +ALL,tion,xion,None,None,None,None +END,gnes,ns,None,None,None,None +START,gy,ky,None,None,None,None +START,gie,kie,None,None,None,None +MIDDLE,mch,mk,None,None,None,None +ALL,jr,dr,None,None,None,None +ALL,xc,@,None,None,None,None +START,gey,key,None,None,None,None +START,vanch,vank,None,None,None,None +END,gc,k,None,None,None,None +END,jc,k,None,None,None,None +START,wr,r,None,None,None,None +ALL,ct,kt,None,None,None,None +ALL,btl,tl,None,None,None,None +ALL,augh,arf,None,None,None,None +START,q,kw,None,None,None,None +MIDDLE,gn,n,None,C,None,None +MIDDLE,wz,z,V,None,None,None +ALL,hroug,rew,None,None,None,None +START,yj,y,None,V,None,None +ALL,nx,nks,None,None,None,None +START,tsj,ch,None,V,None,None +MIDDLE,wsk,vskie,V,None,None,None +END,wsk,vskie,V,None,None,None +END,stl,sl,V,None,None,None +END,tnt,ent,None,None,None,None +END,eaux,oh,None,None,None,None +ALL,exci,ecs,None,None,None,None +ALL,x,ecs,None,None,None,None +MIDDLE,hr,ah,V,C,None,None +END,les,iles,C,None,None,None +ALL,mpts,mps,None,None,None,None +MIDDLE,bacher,baker,None,None,None,None +MIDDLE,macher,maker,None,None,None,None +START,caesar,sesar,None,None,None,None +ALL,chia,kia,None,None,None,None +MIDDLE,chae,kae,None,None,None,None +START,charac,karak,None,None,None,None +START,charis,karis,None,None,None,None +START,chor,kor,None,None,None,None +START,chym,kym,None,None,None,None +START,chia,kia,None,None,None,None +START,chem,kem,None,None,None,None +START,chl,kl,None,None,None,None +START,chn,kn,None,None,None,None +START,chm,km,None,None,None,None +START,chb,kb,None,None,None,None +START,chf,kf,None,None,None,None +START,chv,kv,None,None,None,None +START,chw,kw,None,None,None,None +ALL,achl,akl,None,None,None,None +ALL,ochl,okl,None,None,None,None +ALL,uchl,ukl,None,None,None,None +ALL,echl,ekl,None,None,None,None +ALL,achr,akr,None,None,None,None +ALL,ochr,okr,None,None,None,None +ALL,uchr,ukr,None,None,None,None +ALL,echr,ekr,None,None,None,None +ALL,achn,akn,None,None,None,None +ALL,ochn,okn,None,None,None,None +ALL,uchn,ukn,None,None,None,None +ALL,echn,ekn,None,None,None,None +ALL,achm,akm,None,None,None,None +ALL,ochm,okm,None,None,None,None +ALL,uchm,ukm,None,None,None,None +ALL,echm,ekm,None,None,None,None +ALL,achb,akb,None,None,None,None +ALL,ochb,okb,None,None,None,None +ALL,uchb,ukb,None,None,None,None +ALL,echb,ekb,None,None,None,None +ALL,achh,akh,None,None,None,None +ALL,ochh,okh,None,None,None,None +ALL,uchh,ukh,None,None,None,None +ALL,echh,ekh,None,None,None,None +ALL,achf,akf,None,None,None,None +ALL,ochf,okf,None,None,None,None +ALL,uchf,ukf,None,None,None,None +ALL,echf,ekf,None,None,None,None +ALL,achv,akv,None,None,None,None +ALL,ochv,okv,None,None,None,None +ALL,uchv,ukv,None,None,None,None +ALL,echv,ekv,None,None,None,None +ALL,achw,akw,None,None,None,None +ALL,ochw,okw,None,None,None,None +ALL,uchw,ukw,None,None,None,None +ALL,echw,ekw,None,None,None,None +ALL,cht,kt,None,None,None,None +ALL,chs,ks,None,None,None,None +ALL,orches,orkes,None,None,None,None +ALL,archit,arkit,None,None,None,None +ALL,orchid,orkid,None,None,None,None +START,sch,sk,None,None,None,None +START,vonch,vonk,None,None,None,None +ALL,acci,aksi,None,n;1;hu,None,None +ALL,acce,akse,None,n;1;hu,None,None +ALL,acch,aksh,None,n;1;hu,None,None +ALL,uccee,uksee,None,None,None,None +ALL,ucces,ukses,None,None,None,None +ALL,cce,xi,None,None,None,None +ALL,cch,xh,None,None,None,None +ALL,cc,k,None,None,None,None +ALL,cq,k,None,None,None,None +ALL,cg,k,None,None,None,None +ALL,dgi,ji,None,None,None,None +ALL,dgy,jy,None,None,None,None +ALL,dg,tk,None,None,None,None +ALL,dt,t,None,None,None,None +MIDDLE,gh,k,n;-1;a;i;u;e;o,None,None,None +START,gh,k,None,None,None,None +MIDDLE,gn,kn,y;-1;a;i;u;e;o,None,n;slavo,y;a;i;u;e;o +MIDDLE,gney,ney,None,None,n;slavo,None +MIDDLE,gli,kli,None,None,n;slavo,None +START,ges,kes,None,None,None,None +START,gep,kep,None,None,None,None +START,geb,keb,None,None,None,None +START,gel,kel,None,None,None,None +START,gib,kib,None,None,None,None +START,gil,kil,None,None,None,None +START,gei,kei,None,None,None,None +START,ger,ker,None,None,None,None +MIDDLE,ger,ker,n;-1;e;i,None,n;danger;ranger;manger,None +MIDDLE,ge,ke,None,None,None,y;van;von;sch +MIDDLE,gi,ki,None,None,None,y;van;von;sch +MIDDLE,aggi,aki,None,None,None,y;van;von;sch +MIDDLE,oggi,oki,None,None,None,y;van;von;sch +MIDDLE,oggi,oji,None,None,None,None +MIDDLE,ge,jy,None,None,None,None +MIDDLE,gy,jy,None,None,None,None +MIDDLE,gier,jier,None,None,None,None +MIDDLE,get,ket,None,None,None,None +START,yh,h,None,None,None,None +MIDDLE,sanjose,sanhose,None,None,None,None +END,illo,ilo,None,None,None,None +END,illa,ila,None,None,None,None +END,alle,ale,None,None,None,None +ALL,pb,p,None,None,None,None +START,sugar,xugar,None,None,None,None +ALL,sheim,seim,None,None,None,None +ALL,shoek,soek,None,None,None,None +ALL,sholz,solz,None,None,None,None +START,sw,s,None,None,None,None +ALL,scher,xer,None,None,None,None +ALL,schen,xen,None,None,None,None +ALL,schoo,skoo,None,None,None,None +ALL,schuy,skuy,None,None,None,None +ALL,sched,sked,None,None,None,None +ALL,schem,skem,None,None,None,None +START,sch,x,None,n;1;a;i;u;e;o;w,None,None +ALL,scy,sy,None,None,None,None +END,aiss,ai,None,None,None,None +END,aisz,ai,None,None,None,None +END,oiss,oi,None,None,None,None +END,oisz,oi,None,None,None,None +ALL,tth,t,None,None,None,None +END,aw,a,None,None,None,None +END,iw,i,None,None,None,None +END,uw,u,None,None,None,None +END,yw,y,None,None,None,None +ALL,witz,ts,None,None,None,None +ALL,wicz,ts,None,None,None,None +END,iaux,iauks,None,None,None,None +END,eaux,eauks,None,None,None,None +END,aux,auks,None,None,None,None +END,oux,ouks,None,None,None,None +ALL,zh,jh,None,None,None,None +END,i,y,None,None,None,None +ALL,zzo,so,None,None,None,None +ALL,zzi,si,None,None,None,None +ALL,zza,sa,None,None,None,None +MIDDLE,z,s,n;-1;t,None,y;slavo,None +MIDDLE,ks,x,None,None,None,None +MIDDLE,cks,x,y;-1;a;i;u;e;o,None,None,None +END,l,le,y;-1;ai,None,None,None diff --git a/geco_data_generator/data/postcode_act_freq.csv b/geco_data_generator/data/postcode_act_freq.csv new file mode 100644 index 0000000000000000000000000000000000000000..eb2c29145022b53fb6b605f3d3bb6b12dda9bf91 --- /dev/null +++ b/geco_data_generator/data/postcode_act_freq.csv @@ -0,0 +1,43 @@ +# ============================================================================= +# postcode_act_freq.csv - Frequency table for postcodes in the ACT +# +# Based on 'Australia on Disk' data files (2002) +# +# Last update: 31/03/2005, Peter Christen +# ============================================================================= + +# ============================================================================= +# This table is in a two-column comma separated format, with the first column +# being the names and the second a corresponding frequency count. +# ============================================================================= + +2582,4 +2586,24 +2600,2912 +2601,546 +2602,10842 +2603,3455 +2604,3359 +2605,4581 +2606,3416 +2607,5504 +2608,4 +2609,287 +2611,9273 +2612,4157 +2614,7762 +2615,13417 +2617,8737 +2618,457 +2620,273 +2621,98 +2900,424 +2902,5781 +2903,3472 +2904,4525 +2905,9313 +2906,4848 +2911,34 +2912,65 +2913,6823 +2914,1164 diff --git a/geco_data_generator/data/qwerty-keyboard.csv b/geco_data_generator/data/qwerty-keyboard.csv new file mode 100644 index 0000000000000000000000000000000000000000..f44dd3948463ac77283d8c1e9bf9e4d4a2af354a --- /dev/null +++ b/geco_data_generator/data/qwerty-keyboard.csv @@ -0,0 +1,9 @@ +# QWERTY keyboad layout +# +q,w,e,r,t,y,u,i,o,p +a,s,d,f,g,h,j,k,l +z,x,c,v,b,n,m +# +7,8,9 +4,5,6 +1,2,3 diff --git a/geco_data_generator/data/state-income.csv b/geco_data_generator/data/state-income.csv new file mode 100644 index 0000000000000000000000000000000000000000..991a42f38bf8e1432315873761cd263555a3f98c --- /dev/null +++ b/geco_data_generator/data/state-income.csv @@ -0,0 +1,11 @@ +# Look-up file for generating a compound attribute: state / income. For details +# see module generator.py, class GenerateCateContCompoundAttribute +# +act,7,uniform,20000,200000 +nsw,25,uniform,25000,500000 +vic,21,normal,45000,10000,15000,None +qld,14,uniform,20000,100000 +nt,3,uniform,20000,100000 +tas,8,normal,25000,20000,10000,None +sa,12,uniform,25000,250000 +wa,10,normal,65000,60000,20000,None diff --git a/geco_data_generator/data/surname-freq-japanese.csv b/geco_data_generator/data/surname-freq-japanese.csv new file mode 100644 index 0000000000000000000000000000000000000000..1f3535a6878811223a039b0fbca05439387d0c9e --- /dev/null +++ b/geco_data_generator/data/surname-freq-japanese.csv @@ -0,0 +1,22 @@ +‘Šì,5 +–Ø,30 +ˆäo,110 +ˆÉW‰@,5 +ˆÉ“¡,2000 +‘¾“c,281 +¬—Ñ,872 +Ž™“‡,390 +Ä“¡,901 +²“¡,5016 +ú±ŽR,90 +—é–Ø,2098 +“c’†,2592 +‘L,421 +“y“c,120 +L“c,208 +‹´–{,872 +X“c,398 +ŽR–{,1104 +‹{“c,383 +‹g“c,981 +“n•Ó,123 diff --git a/geco_data_generator/data/surname-freq.csv b/geco_data_generator/data/surname-freq.csv new file mode 100644 index 0000000000000000000000000000000000000000..d96516d60362ee0563233a1cf8b713e228e6fdff --- /dev/null +++ b/geco_data_generator/data/surname-freq.csv @@ -0,0 +1,9159 @@ +aaberg,2 +aakre,1 +aarts,1 +aaternir,1 +abat,2 +abbatista,1 +abbetmeyer,1 +abbondandola,2 +abdel salam,1 +abdol,1 +abdullah,8 +abdulsubahan,1 +abejo,1 +abera,2 +aberg,2 +aberham,1 +abeygunawardena,1 +abeysuriya,1 +abeywickrama,1 +abifarraj,1 +ablamowicz,2 +able,3 +abolf,1 +abou-zeid,1 +abourjeili,1 +abraha,1 +abrahamson,10 +absell,1 +absenger,3 +abud,1 +abulmouna,1 +abushawsh,1 +acciairresa,1 +achkar,1 +ackermans,1 +adair,25 +adamou,1 +addo,2 +adelaide,1 +adhikari,3 +adikari,1 +adnerson,1 +adorni-braccesi,1 +adrain,4 +adshed,1 +adzaip,3 +aesche,7 +aeuckens,2 +afford,38 +afiabo,1 +afrassa,1 +agagliate,1 +agapitos,1 +agerbeek,4 +agett,3 +aggarwal,7 +agius,73 +agno,1 +agriogiannis,1 +ah chin,3 +ah kit,2 +aherne-vonhoff,1 +ahier,5 +ahillias,1 +ahlin'smith,1 +ahmed,26 +ahmepagic,1 +ahsam,1 +ahwah,1 +aimes'emery,1 +airs,2 +airwolf,1 +aisatullin,3 +aiston,11 +aitken-moss,1 +akar,1 +akaula,1 +akauola,2 +akele,1 +akerland,1 +akerlind,2 +akker,5 +akkermans,7 +akmacic,2 +akot,1 +akritidis,1 +akroyd,2 +aksentijevic,1 +aktov,1 +al safi,1 +al-zubaidy,1 +ala saarela,1 +alagich,3 +alahiotis,2 +alate,1 +alberd,1 +albert-ward,1 +albertini,10 +alberty,2 +albore,1 +alcazar,4 +alcoe,1 +alderman,34 +alderson,82 +aldous,19 +aldrich,1 +alearez,1 +aleksander,1 +aleksandric,1 +alessi,6 +aletras,1 +alexander-grieve,1 +alfords,1 +algo,3 +alhabsji,1 +alhaiery,1 +aliadi,2 +alias,4 +alibek,1 +alimanovic,1 +alisauskas,2 +allabanda,3 +allanby,27 +allard,32 +allchin,11 +allcroft,6 +allegretto,6 +allen mckenzie,1 +allermo,1 +allica,1 +allik,2 +allister,3 +allmich,2 +allon,1 +allsopp,18 +alma,2 +almazan,2 +almeida,8 +alrobiay,1 +alsic,2 +alste,1 +alstin,2 +alstrom,2 +alszko,1 +alt,3 +alton,4 +altorjay-arnoul,1 +alty,3 +alves,18 +alwast,1 +alyta,1 +amafuji,1 +amagula,3 +amarasekara,1 +amarasekera,2 +amarjit,1 +ambjerg-pedersen,1 +amega,1 +amiet,8 +aminthe,1 +ammer,1 +amorim,2 +ampelas,1 +amri,2 +amur,1 +anable,1 +anatoly,1 +andersch,8 +anderson-haig,1 +anderson-ives,1 +andrae,18 +andreae,3 +andreescu,1 +andrepoulos,1 +andresen,15 +andretti,3 +andretzke,16 +andricic,2 +andrionne,1 +andrioti,1 +andrysz,1 +anestopoulos,2 +ang,19 +angerson,2 +angie,3 +angus-welcome,1 +anic-ivicic,1 +anicic,4 +anjewierden,2 +anne,4 +annetta,3 +anninos,5 +anns,2 +ansaar,1 +ansford,1 +anshan,1 +ansone,1 +ansselin,1 +antees,1 +anthanassiou,1 +anthomy,1 +antiuschka,2 +antoinette,1 +antoku,1 +antuar,3 +anwyl,2 +ao,1 +aoun,5 +apathy,5 +apiata,1 +apoleski,1 +apolinar,1 +apostoloff,4 +appletree,1 +apruzzese,1 +apse,4 +apsitis,4 +apted,42 +aquila,1 +arabilla,2 +arachchide,1 +araisuru,1 +arakiel,3 +arana,1 +arandale,1 +araujo,5 +aravena,1 +araya,4 +arbalis,1 +arbuckle,12 +archdall,12 +arda,1 +ardalich,3 +arenz,1 +arganese,9 +argentieri,1 +arghittu,1 +argiridis,1 +arhar,1 +arhdntoulis,1 +arhipoff,8 +arikawe,1 +ariuu,1 +ariyaratme,1 +arkadianos,2 +arkcoll,1 +arkit,2 +arkwright,2 +arland,2 +arlott,4 +arlotta,1 +armanas,2 +armanini,7 +armanious,2 +armata,1 +armfield,22 +armiento,11 +armstrong-essery,2 +arnald,1 +arnaoutis,1 +arnaudon,1 +arndt,8 +arneil,3 +arozoo,1 +arragon,3 +arribas,2 +arrigoni,1 +arrison,1 +arsenijevic,2 +artacho,2 +arthure,1 +arthus,1 +artis,41 +arts,1 +artym,2 +artymowycz,4 +arulanandam,3 +arvanitakis,5 +asbroek,3 +asbury,1 +asche,6 +aseffa,1 +asendorf,4 +ashbey,1 +asher,24 +ashpole,1 +askell-wilson,1 +askins,2 +asmus,3 +asperti,3 +aspery,2 +aspey,3 +aspinall,50 +assadi khansari,1 +asser,15 +astinall,1 +astley,23 +asusaar,2 +atahan,1 +atefi,1 +athanasoulias,3 +athans,6 +athnansiou,1 +atholwood,1 +atighi,1 +atkinson-crawford,1 +atsalas,4 +atsalis,3 +atsaves,5 +attis,1 +attle,2 +au,23 +aualiitia,1 +auch-schwelk,1 +audino,2 +audze,1 +aufiero,1 +augey,1 +augustijn,1 +aujard,6 +auldridge,1 +aulert,1 +auman,2 +aungle,1 +ausserlechner,3 +austin-crowe,1 +autengiuber,1 +auvaa,1 +avcarich,1 +avdic,2 +aveil,1 +avendano,1 +averats,4 +averay-jones,1 +averis,12 +averkin,3 +avoty,1 +awadahl,1 +awarau,1 +awatere,1 +axam,1 +axelson,1 +ayer,3 +ayotte,1 +ayres,82 +azarovsky,2 +azeez,1 +azimi,4 +azzopardi-williams,1 +baars,3 +baart,1 +baayens,3 +babare,1 +babarowski,1 +babefhoff,1 +babic,25 +babol,1 +babos,3 +baccarin,1 +bacchus,13 +bachan,1 +bachli,4 +backcoller,1 +bacskai,6 +bacueti,1 +badalassi,2 +badawee,2 +baddeley,7 +badewitz,1 +badger,34 +badhan,1 +badia,1 +badman,45 +badowicz,1 +baensch,2 +baerwald,1 +bagdan,1 +baggalley,2 +baginska,1 +bagot,8 +bagusauskas,4 +bagwell,2 +bahgat,2 +bahnisch,11 +bahouche,1 +bahwech,1 +bail,18 +bailiht,3 +baillie,85 +baj,1 +bajic,5 +bajtek,2 +bajurin,1 +baker-cresswell,1 +bakewell,6 +bakirtzakis,3 +bakken,1 +balasubramaniam,3 +balazs,7 +balcher,1 +balchin,15 +baleibaravi,1 +balga,1 +balingit,1 +ballantyne,69 +balmain,3 +balmford,1 +baloban,1 +baloch,1 +balsarini,1 +baltagie,2 +baltidis,1 +bambas,1 +bambino,2 +bambling,5 +bammant,1 +ban,7 +ban malssen,1 +banagala,1 +banasevich,1 +bandi,1 +bandick,8 +bandte,2 +banelis,4 +banful,2 +banham,24 +bani,1 +banjavcic,1 +bankowski,1 +bansemer,13 +bansgrove,2 +banson,2 +bantolas,1 +banute,1 +baohm,11 +baptist,5 +barabara,1 +baradakis,4 +baraiolo,4 +barancek,1 +barazda,2 +barberien,2 +barbiellini,1 +barbier,2 +barbuto,6 +barchero,1 +barelds,3 +barges,2 +baricevac,1 +barisic,20 +barko,4 +barmore,1 +barnaby,2 +barnes-keoghan,1 +barnetson,4 +barol,1 +barossa,2 +barra,5 +barram,1 +barrangul,1 +barre,1 +barrett-woodbridge,3 +barritt,12 +barsoum,1 +bartel,75 +barthomew,1 +bartkow,2 +bartley-steele,1 +barton-ancliffe,5 +bartone,4 +bartos,5 +bartosic,1 +barvo,1 +barwon-parry,1 +barzen,2 +bascik,1 +base,1 +basedow,12 +basey,3 +bashum,1 +basis,1 +baskarada,1 +baskin,2 +basri,1 +bassal,1 +bassaletti,1 +bassani,8 +basselot-hall,2 +bastardi,1 +basterfield,3 +basterrechea,1 +bastiaans,12 +bastin,13 +basting,1 +basyaruddin,3 +bat,2 +batemam,1 +bates-brownsword,8 +batiste,2 +battisson,13 +battistessa,1 +batusic,2 +baucks,1 +bauerstock,1 +baugh,9 +bauman,5 +baumgart,3 +baust,7 +bavagh,1 +bavin,2 +bayet,3 +baynes,37 +bazevski,1 +bazley,2 +beaben,1 +beadel,4 +beadell,4 +beadle,28 +beahan,2 +beak,1 +beal,37 +beams,53 +beardon,2 +beasland,1 +beattie,180 +beatton,10 +beaty,41 +beaufort,1 +beauman,4 +beaumaris,4 +beaumont-smith,1 +beazley,23 +bechtold,4 +becirevic,1 +beck-clark,1 +beckwith,34 +bedarev,1 +bedding,12 +beddison,2 +bedington,2 +bednar,1 +bednarczyk,3 +beeche,3 +beegling,1 +beelitz,29 +beemster,3 +beerbiuum,1 +beeslee,2 +beganovic,1 +beh,3 +behill,1 +behnke,6 +beiler,1 +beilicz,1 +beissel,2 +beiwinkler,1 +bela,1 +belavic,2 +belbello,1 +belchel,1 +belci,6 +belding,1 +bell-towers,2 +bellamy,28 +bellchambers,110 +bellew,4 +belling,10 +bellofatto,2 +bellon,12 +bellot,2 +belonoha,1 +belperio,74 +belsham,6 +beltrami,2 +beltsos,2 +bem,2 +bemowski,1 +ben-gurion,1 +bencze,2 +bendt,1 +bendyk,6 +bendyna,1 +bene,1 +benetto,1 +benger,58 +bengtell,1 +beniston,2 +benjafield,2 +benjamin,34 +benkovic,1 +bennell,17 +bennier,45 +bentham,7 +bentin,1 +bento,1 +benveniste,4 +beran,2 +berce,4 +berenyi,5 +bereza,5 +berezansky,2 +berezny,1 +bergamaschi,10 +berghout,1 +bergrud,1 +bergsma,2 +beric,7 +berisa,1 +berketa,5 +berkinshaw,4 +berly,1 +berman,4 +bernardo,8 +bernath,4 +bernattek,1 +bernauer,1 +bernhart,3 +beros,1 +berresford,12 +berrgren,1 +berry,527 +berryman,91 +bersable,1 +bersten,1 +bertagno,2 +berwald,1 +beryl,2 +berzel,4 +betemarim,1 +bethesda,1 +bethley,1 +betiavas,1 +betrum,1 +betschart,3 +betschild,1 +bettens,13 +betti,2 +bettineschi,2 +beudeker,1 +beugelaar,2 +beurich,1 +beutler,4 +bevan-lewis,2 +beverakis,1 +beverlee,1 +bevin,9 +bevis,33 +bevitt,1 +bezos,8 +bezuch,4 +bezuidenhoudt,1 +bhalla,2 +bholanat,1 +bhummabhuti,2 +bialous,4 +biancardi,3 +bianchin,3 +bibb,1 +bibby,16 +bibrowicz,1 +bicanski,1 +bichler,1 +bickerstaffe,1 +bidal,1 +biden,1 +bidwell,5 +bieber,1 +biec,1 +bieckmann,1 +bielenberg,3 +bienkowski,1 +bierenboim,2 +bigge,1 +bihar,3 +bilecki,10 +bilinski,1 +billman,2 +billsborrow,2 +bilowus,2 +bimitrijevic,1 +bin-gapore,1 +bindi,4 +bindoff,6 +binggong,1 +biniek,1 +binkowski,7 +binns,104 +birchby,7 +bircher,1 +birdling,1 +birg,1 +birindzic,1 +birkill,2 +birkin,26 +birkner,1 +birthisel,3 +birthwhistle,1 +bisazza,2 +biscan,1 +bischelberger,2 +biscoe,5 +bishop,636 +bisht,1 +bissember,1 +bissett,64 +bissmire,4 +bistik,1 +bitmead,27 +bittins,2 +bivone,8 +bixley,1 +bizjak,7 +bjorksten,1 +blachnicki,1 +blacka,2 +blacklaws,1 +blacklow,21 +blackney,5 +blackwell,229 +bladel,3 +blake,370 +blam,1 +blanchette,2 +blancodini,1 +blandis,3 +blaschke,7 +blask,1 +blaskett,4 +blazey,4 +bleeser,1 +blenkinsopp,1 +blenkle,1 +blessios,1 +blewett,17 +bligh,24 +blignault,1 +bligzna,3 +blinman,9 +blissenden,2 +blizard,1 +block,51 +blocki,4 +blohm,2 +blomberg,5 +blondel,1 +bloomfield,92 +blowe,1 +blowes,26 +blows,18 +bluemmel,1 +blunden,60 +blurton,1 +blyde,2 +boak,1 +boam,4 +boase,28 +boaz,3 +bobbitt,1 +bobets,1 +bobko,1 +bobroff,3 +bobstchlinski,1 +boccabella,1 +bocchino,7 +boccuzzo,2 +boceanu,1 +bochmann,6 +bochnicek,2 +boczkowski,2 +bodfish,1 +bodman,6 +boe,1 +boecke,2 +boekel,2 +boesten,3 +boettinger,2 +boevink,2 +boeyen,8 +bof,4 +bohonis,1 +boi,1 +boigt,1 +boileau,5 +boissery,1 +boitcheff,1 +boizard,1 +boling,2 +bolis,1 +bollen,18 +boller,6 +boman,11 +bomben,1 +bondar,3 +bondza,3 +bonnefin,4 +bonnie,1 +bonomo,1 +bonthuis,2 +bonvino,1 +boocock,7 +boonen,3 +boothroyd,6 +bootton,1 +bopping,3 +boravos,2 +bordeaux,2 +bordin,10 +bordon,3 +borejko,1 +borel,1 +borg caruana,1 +borgardt,1 +borgelt,8 +borges,4 +borgmeyer,8 +borholm,1 +borick,1 +borkowskis,1 +bornholn,1 +boromisa,2 +borrill,3 +borsut,1 +bortkiewicz,2 +borysiak,1 +bosboom,2 +boschen,1 +boschma,1 +bosecke,2 +bosi,4 +bosonworth,1 +boss,23 +bosse,1 +bossence,1 +bossley,1 +boswest,1 +boteju,1 +botham,5 +bott-sarma,1 +botta,2 +bottroff,31 +bouchierr,1 +bough,2 +bouldin,2 +boulter,32 +bouras,13 +bourchardt,1 +bourgeois,4 +bourrell,1 +bouskill,1 +bousky,1 +boutchard,12 +boutland,1 +bouzalas,3 +bovill,8 +bowdern,1 +bowen-smith,1 +bowerman,104 +bowes-johnston,1 +bowick,1 +bowles-baker,1 +bowness,1 +bowran,3 +bowron,6 +boxer,34 +boxhall,45 +boxshall-slean,1 +boyes,43 +boyle,209 +boylon,5 +boysey,1 +boyton-carverry,1 +bozanco,1 +bozdarovski,1 +bozoki,1 +bozzetti,3 +bozzon,2 +brabants,1 +bracci,5 +bracht,2 +braciak,2 +brack,6 +brackett,2 +bradby,1 +braddy,8 +bradicich,1 +bradshaw,214 +braemer,1 +bragicevich,1 +braido,1 +brain,104 +braine,3 +braithwaite,103 +brajkovic,4 +brakel,2 +brakensiek,1 +bralic,6 +bramble,6 +bramfit,1 +brammy,17 +brandall,1 +brandreth,1 +brandstetter,2 +brangwen,1 +braniff,2 +brann,5 +brannelly,3 +bransby,3 +branski,1 +branston,3 +brasdandi,1 +brash,2 +braslis,1 +bratina,1 +bratko,1 +bratovic,3 +braumann,1 +braunack,39 +braunwalder,1 +brayshay,1 +brayton,2 +brazzalotto,12 +bredel,1 +bredl,1 +breedt,2 +breglove,1 +breheny,11 +bremers,1 +bremstaller,2 +brenchley-gaal,1 +brennand,8 +brentnall,7 +brenzel,1 +breschi,2 +bresnik,1 +bresvansin,1 +bretland,2 +breuninger,1 +brey,1 +brgles,7 +briceno,1 +bridgefoot,1 +bridgeland,4 +bridgland,32 +brining,1 +brinsmead,10 +bristow,80 +bristow-smith,1 +britten,69 +brittion,1 +brne,1 +broadby,46 +broade,1 +broadhead,12 +brock,130 +broders,4 +broinowski,2 +brokenshire,25 +brommeyer,1 +broniecki,1 +bronwyn,2 +brooker,72 +brookes-inglis,3 +brookhouse,6 +broughan,4 +broullet,1 +brouwers,4 +brovcenko,1 +browne,257 +browngold,1 +broxam,6 +bruck,2 +brudo,1 +brugler,1 +bruhn,59 +bruinewoud,4 +brumbt,1 +brumley,3 +brummer-archer,1 +brunborg,1 +brunne,1 +brunoro,4 +brunssen,3 +brus,9 +bruse,9 +brushe,1 +brushett,1 +bryce-watson,1 +brydon,12 +bryers,3 +brysland,1 +brzezinska,2 +buccini,4 +buchhorn,6 +buchiw,6 +buchold,2 +bucholtz,3 +buckell,7 +buckinghan,1 +buckmaster,12 +buckoke,2 +bucks,1 +budel,2 +buder,6 +budge,6 +budreika,2 +budzynski,3 +buer,3 +bueschike,1 +buesel,1 +buffett,2 +bugera,1 +bugslag,1 +buhagiar,27 +buhle,1 +bui-kensington,1 +buil,1 +builth,2 +buitendyk,2 +bujnowski,5 +bujtas,1 +bulbrook,1 +bulfone,1 +bulford,1 +bulgin,1 +bullamore,1 +bullion,1 +bullivant,9 +bullock,129 +bulmeister,1 +bulner,2 +bulyga,2 +bunch,2 +bunjo,3 +bunt,8 +bunuggurr,1 +buracott,1 +burchel,1 +burdin,3 +burdzielow,1 +burford,225 +burgar,5 +burgemeifter,1 +burghof,2 +burghr,1 +burgmann,2 +burgstett,1 +burkenhagen,2 +burkevics,9 +burleigh,32 +burman,39 +burmeister,4 +burn-adams,1 +burnell,64 +burrill,15 +burtenshaw,5 +buscall,1 +buschauer,1 +buterfield,1 +butt,116 +butter,3 +buttons,1 +buttrose,16 +buttsworth,2 +butvila,2 +buxton-collins,1 +buzow,1 +bycroft,5 +byers,74 +byers-thomas,2 +byham,2 +bykow,1 +bynder,1 +byrd,2 +byreddy,1 +byrt,11 +bysord,1 +cabos,1 +cacciotti,4 +cachia,9 +caddick,8 +cadman,29 +cadwallader,5 +cagialis,1 +cagliuso,2 +cagnan,1 +cahir,4 +caine,12 +caire,40 +cakic,1 +calan,5 +calantzis,2 +calarco,3 +calcroft,1 +calgie,2 +calhourn,1 +calic,4 +calio,5 +calipari,9 +calisto,1 +callado,4 +callagan,1 +callahan,40 +callister,6 +calloway,1 +calnan,14 +calnin,1 +caloghiris,3 +calov,2 +calow,7 +caluzzi,1 +calvett,2 +calzadalla,1 +camarotto,1 +cambell,4 +cameirao,3 +camens,10 +cameron-hill,1 +camffermann,2 +camillo,1 +camiss,1 +camozzato,6 +camp,38 +campain,32 +campana,1 +campbell,1414 +campbell-kennedy,1 +campbell-smith,6 +campble,1 +campton,15 +camuscini,1 +can,3 +canavan,19 +canavese,3 +canciller,1 +candale,2 +candida,10 +cangelosi,1 +canini,1 +canizares,2 +cankett,2 +cannell,71 +cannons,10 +cansfield-smith,2 +cantarella,1 +cantini,3 +canton,7 +cantrall,1 +capek,1 +capel,13 +capell,12 +capio,1 +capiro,2 +cappelluti,18 +cappelutti,1 +capurro,1 +capurso,40 +caputi,2 +carallis,1 +caranci,1 +carberry,11 +carbone,136 +carbray,2 +carcuro,6 +cardier,1 +cardnell,4 +careless,10 +carella,3 +carger,4 +carich,1 +carie,3 +carige,7 +carington,2 +carington-smith,1 +carioti,2 +carless,5 +carlington,1 +carlmark,1 +carluccio,2 +carlus,1 +carmax,1 +carmody,86 +carmont,1 +carnachan,3 +carnicelli,2 +carnmer,1 +carnuccio,4 +carofano,5 +carosella,3 +carp,1 +carpanzano,1 +carrabba,2 +carradine,1 +carraill,10 +carratt,2 +carrel,2 +carrera,8 +carrigg,3 +carruthers-taylor,2 +carsley,1 +cartland,4 +cartmel,2 +caruana,51 +carugno,1 +carullo,2 +carvalho,4 +carvel,1 +casanovas,1 +casaretto,4 +casasola,1 +caselli,1 +casimiro,4 +casper,1 +cassebohm,7 +casser,1 +cassilles,2 +cassimatis,4 +castelanelli,2 +castellari,4 +castelluzzo,5 +casten,1 +castleman,4 +catalinac,1 +catalini,1 +caterer,3 +catherwood,3 +catt-green,1 +cattigan,4 +cauna,2 +cavaivolo,1 +cavallard,1 +cavanaugh,2 +cavinagh,1 +cawkwell,4 +cayoun,1 +cazes,2 +cazzlato,1 +cebalo,1 +cebin,1 +cecere-palazzo,3 +cecotti,3 +cecovic,2 +ceiffman,1 +ceiley,1 +cenatiempo,1 +cenin,7 +center,1 +centofinti,1 +ceper,1 +cerchi,2 +cereceda,1 +cerins,1 +cernaz,1 +cerritos,1 +cervo,1 +cesari,1 +cetic,1 +cetinich,3 +chabrel,6 +chadburn,3 +chahin,1 +chakouch,1 +chala,1 +challenor,7 +chalson,1 +chamalaun,3 +chambis,2 +chammen,5 +champion de crespign,4 +chandler,280 +chanter,3 +chantha,1 +chantrill,1 +chappel,22 +chaptini,1 +charitonidis,1 +charlton-white,1 +charman,33 +chater,4 +chaternuch,2 +chatloup,1 +chattin,4 +chaudhary,1 +chauveau,1 +chav,2 +chawla,3 +chawtur,1 +cheap,1 +chee,7 +cheel,15 +cheers,10 +cheffon,1 +chegwidden,6 +chehon,1 +cheliotis,1 +chell,4 +chelmers,1 +chemello,1 +chemny,2 +chereda,1 +cherini,3 +cheshire,22 +chestnut,3 +chetter,1 +chetwyn,2 +chevallier,2 +chiappetta,5 +chico,1 +chidzey,1 +chighine,1 +chigros,8 +chijiwa,2 +chilko,1 +chin quan,1 +chiotis,1 +chippett,4 +chitti,4 +chittinoori,1 +chittleborough,33 +chitts,2 +chmelar,2 +chodacki,1 +choi-lundberg,1 +chol,2 +cholawinskyj,3 +cholmondeley,1 +chomos,2 +choon,1 +chorley,15 +chorny,2 +chote,1 +chou,12 +choumar,1 +chowdhury,9 +chraplewski,1 +chreb,1 +chrisakos,1 +christanto,1 +christerson,4 +christie-taylor,1 +christo,5 +christofilos,2 +christos,1 +chrost,1 +chrysanthou,1 +chua-chang,1 +chubb,7 +chuck,22 +chudzinski,1 +chueler,1 +chuong,1 +churches,23 +churchill-bateman,1 +churkin,1 +chuying,1 +chwalczyk,1 +ciannemea,1 +ciardullo,5 +ciavarella,1 +cibiras,2 +cicchini,10 +cicconi,5 +cichanowski,1 +ciciksza,1 +cicolella,4 +cifali,2 +cimbora,1 +cioffi,5 +cionci,4 +ciotti,5 +ciplys,3 +cirelli,5 +cirottola,1 +cirvydas,1 +ciuciu,1 +civil,3 +claasz,1 +clacy,2 +cladingboel,2 +claffey,1 +clapham,14 +claremont,3 +clarke,1781 +clarke-hall,1 +clarysse,1 +clasper,3 +clauson,4 +clayden,9 +claydon,14 +clearay,1 +cleaver-smith,1 +clelland,15 +clemes,2 +clendenning,1 +cleugh,1 +cliffe-hickling,2 +climo,1 +clisby,26 +clissold,11 +cloke,8 +clos,1 +clota,3 +cloudsdale,9 +clowes,4 +clucas,2 +clutterbuck,24 +cmarch,1 +cmielewski,3 +cnossen,1 +co,1 +coady,19 +coatsworth,7 +coaxton,1 +cobbett,2 +cobbin,5 +cobuccio,1 +cochrane,139 +cockerham,2 +coenen,4 +coey,1 +coffey,104 +cofinas,1 +cogzell,2 +cohonen,1 +cohorts,1 +cokley,1 +colantoni,4 +colantuono,2 +colaric,1 +colasante,6 +colbron,1 +coldell,1 +coldicutt,6 +cole-adams,2 +colefax,3 +colegate,16 +coleman,529 +coleman-bock,1 +coleopy,2 +colev,3 +colicchio,1 +colis,1 +collier,87 +collingham,1 +collins hartley,1 +collinson,51 +collishaw,1 +colliss,1 +collo,1 +collufio,1 +colombini,3 +colpo,2 +colquhoun,87 +colston,1 +colthorpe,6 +coltman,8 +comacchio,7 +comahig,1 +comben,1 +combridge,8 +combs,1 +comersord,1 +comisari,1 +comitis,1 +commons,16 +commozzato,1 +compagne,6 +compton,26 +conaghty,26 +conboy,7 +concannon,6 +conder,10 +condessa,3 +condo,20 +condozoglou,1 +condric,2 +conely,1 +connerty,4 +connier,3 +connochie,1 +conrick,18 +constance,12 +constantas,1 +cookson,20 +coolahan,3 +cooper-heeney,1 +cooper-white,1 +coopers,1 +coopman-dewis,1 +cootam,1 +copine,1 +coplestone,4 +copp,9 +copperstone,4 +coppinger,9 +coppock,21 +coppola,26 +coquia,1 +corbin,26 +corbitt,4 +corboz,1 +cordang,1 +cordina,8 +cordiner,5 +cording,4 +cordingley,8 +cordoba,1 +corera,1 +coridas,1 +cormick,13 +corneille,2 +cornioley,1 +corocoran,1 +corones,2 +corpett,1 +corre,1 +corrick,8 +corrie,22 +corsico,2 +cort,2 +corthouts,1 +corujo,4 +corver,5 +cosenza,1 +cosgrove-brown,1 +cosier,4 +cosmetto,2 +cossich,3 +cossman,1 +costain,8 +costessi,1 +costigan,19 +cotchin,1 +cother,12 +couch-keen,1 +couchi,1 +coudraye,2 +coulls,20 +coulson,147 +coulton,7 +coumans,3 +coupard,1 +courtenay-ralph,1 +courtnell,3 +cousin,6 +couszins,1 +coutsoumis,1 +couzens,32 +coveny-sanders,1 +covino,36 +cowcill,2 +cowden,8 +cowell,56 +cowlam,1 +cowle,11 +cowman,3 +cox-mckinnon,1 +coxon,32 +cradock,13 +cragg-sapsford,2 +crain,8 +cramb,3 +cranefield,3 +crannage,2 +crapp,6 +craske,11 +craswell,7 +craze,2 +crea,2 +creafter,1 +creagh,12 +creber,11 +creighton-jay,1 +crellin,14 +cremasco,9 +cresceteili,2 +cresp,20 +creten,8 +crews,9 +crighton,8 +crighton-mills,1 +crimes,3 +crisafulli,2 +crisci,15 +cristenfeldt,1 +cristiani,2 +criswood,1 +crkvencic,2 +crlik,1 +croad,1 +croci,5 +crocket,1 +crofton,4 +crofts,14 +croker,42 +cromer,11 +croning,1 +cronis,1 +cronshaw,9 +crook,116 +crookall,6 +crooke,6 +cropper,6 +crosetta,1 +crosser,1 +crossingham,5 +crossman,78 +crosswell,108 +crosthwaite,6 +crouch,205 +crowest,1 +crown,1 +cruicksank,1 +cruickshanks,3 +crute,11 +cruttenden,8 +csanaki,2 +csejtey,1 +cseko,1 +cseleda,1 +cseri,1 +csik,2 +csomor,1 +ctercteko,1 +cube,1 +cuerden-clifford,1 +cuffley,1 +culbertson,13 +cullens,3 +cullerton,1 +cullinane,1 +culliton,4 +culovici,1 +culph,6 +cuming,20 +cummin,3 +cundell,5 +cunha,4 +cuniak,1 +cunich,2 +cunnett,2 +cupo,2 +cure,39 +curea,2 +cureton,9 +curihual,1 +currinckx,1 +curry,59 +cursley,2 +curson,2 +curteis,2 +curth,2 +curthoys,2 +curtoni,1 +curwen-walker,2 +cushnie,1 +custamce,1 +cutcliffe,5 +cute,11 +cuthbert-mundy,1 +cwiek,2 +cybulski,3 +cymbl,1 +cyrillo,3 +czajka,1 +czarnik,1 +czekalewski,1 +czerniawski,5 +czobik,1 +czoloszynski,1 +czura,1 +czylok,1 +d'abate,2 +d'addio,2 +d'alterio,1 +d'antiochia,2 +d'apollonio,3 +d'arne,1 +d'emden,11 +d'sylau,1 +d'unienville,1 +daavittila,1 +dabb,1 +dabinet,16 +dabruzzo,1 +dabson,1 +dach,1 +dacktyl,1 +dadasovic,1 +dadic,1 +dady,2 +daehn,3 +dagley,2 +dagli-orti,1 +dahl-helm,1 +dahler,4 +dahlquist,2 +daicof,1 +daily,3 +daimanti,1 +dainton,2 +daish,14 +dajeman,2 +dakin,35 +dakis,4 +dalkin,4 +dall'armi,1 +dallacqua,1 +dallas,23 +dallemolle,1 +dalli,3 +dallos,4 +daloia,3 +dalpozzo,1 +dalpra,2 +dalrymple,7 +daltoe,1 +dalton-lum,2 +damhuas,1 +damhuis,8 +damianos,1 +damodaran,1 +damyanovsi,1 +danby,10 +dancey,5 +dandie,2 +danelon,4 +danisewitsch,1 +dankers,1 +danner,1 +dantiochia,1 +danyushevski,1 +danzig,1 +daoutidis,1 +dapollonio,1 +darbishire,3 +darby-cocks,1 +darch,7 +darcy-clarke,1 +dargaville,10 +dargenio,3 +dargusch,1 +darlaston,1 +darley-bentley,1 +daronco,1 +darrington,5 +dasilva,4 +dasovic,5 +datavs,1 +dathe,1 +datlen,5 +dato,3 +daughty,1 +daumont,1 +daven,1 +david,96 +david-smith,2 +daviess,11 +davila-sanhdars,1 +davis-bennett,2 +davis-bishop,1 +davis-goff,1 +dawborn,1 +dawood,1 +dayes,1 +daykin,8 +daymond,5 +daysh,5 +de angelis,24 +de boar,9 +de bock,1 +de boeck,1 +de boni,1 +de bono,16 +de borzatti,1 +de burgh-day,2 +de chellis,1 +de clouett,1 +de courcey,1 +de crespigny,4 +de fantis,1 +de fazio,8 +de flumeri,2 +de gennaro,11 +de greef,4 +de gruchy,2 +de gryse,1 +de judicibus,1 +de julia,1 +de la cruz,4 +de landre,1 +de leur,1 +de los rios,1 +de lucia,6 +de march,1 +de marzi,2 +de michele,10 +de nadai,1 +de nichilo,5 +de paoli,13 +de peinder,1 +de pierro,3 +de pizzol,3 +de raden,1 +de rijk,1 +de salvio,1 +de savi,3 +de sciscio,7 +de smeth,3 +de teliga,1 +de totth,2 +de voga,1 +de vrieze,1 +de wouytch,1 +de'hoedt,2 +de'low,1 +de-silver,1 +deaha,1 +deakin,33 +deally,2 +dearing,36 +death,13 +debais,1 +debelle,2 +deblasio,4 +debrenni,3 +debritt,4 +debroughe,1 +deceukelaire,1 +deck,4 +deckert,8 +decolongon,1 +decrevel,1 +dedicoat,4 +dedovic,2 +deese,2 +defrancesco,10 +degasperi,6 +degenaars,1 +degeorge,1 +degoede,1 +degree,3 +degugelmo,1 +deguisa,3 +dehass,1 +dehesh,1 +dehey,1 +dehoedt,2 +deionno,4 +deja,1 +dejesus,4 +dekoff,1 +dekrell,1 +dekretser,1 +dekuijer,2 +dekuyer,1 +del checcolo,2 +del monaco,1 +delacy,11 +deleon,3 +delev,2 +delfos,3 +delgardo,1 +delizo,1 +delkic,1 +della giustina,2 +della-putta,1 +della-robson,2 +della-verde,6 +dellaforesta,1 +delledonne,2 +dellmann,1 +delloiacono,1 +delloste,2 +delohery,1 +delorme,1 +delos santos,1 +delrue,2 +delvendiep,4 +demarco,23 +demasson,1 +demenezes,2 +demetriou,17 +demura,1 +den elzen,1 +den otter,4 +denberger,2 +denduyn,1 +denellis,1 +denhertog,1 +denholm,73 +denisenko,1 +denne,16 +dennes,14 +denness,2 +denning,9 +dennington,6 +dent,131 +dentchev,1 +denwer,2 +deoki,1 +depanfilis,1 +depares,3 +depold,2 +depoma,1 +deporteous,2 +derganz,1 +derick,1 +derkson,1 +derlagen,1 +dermatis,2 +dermidy,1 +deroos,1 +derrett,2 +desalis,1 +desantis,3 +desaro,1 +deschmann,2 +desilva,13 +dessart,6 +dessi,3 +detzner,2 +deutscher,2 +devenny,1 +devin,4 +devonshire,2 +devriadis,1 +dews,4 +dhara,1 +dhondee,1 +di caterina,1 +di cesare,2 +di chiera,2 +di cola,2 +di domenic,1 +di lernia,2 +di manno,4 +di meglio,1 +di narzo,1 +di pinto,4 +di rosso,1 +diamandis,1 +diamandou,2 +diangmiyang,1 +diantsis,1 +diashko,1 +dibb,3 +dibb-smith,1 +dibben,25 +dibble,4 +dicamillo,2 +dicaterina,4 +dicenso,1 +dichiera,28 +dichtl,1 +dicic,1 +dicks,10 +dicovska,1 +didas,2 +dieckmann,5 +diegan,2 +diekman,5 +dielenberg,1 +dietmayer,1 +dietrich,24 +dietzel,3 +differy,1 +digan,4 +digiuseppe,1 +dignam,9 +dikic,1 +dileva,1 +dilkes,1 +dillion,1 +dillon-kenny,1 +dillworth,2 +diluvio,1 +dimachki,1 +dimauro,5 +dimitrijevich,2 +dimitriovski,1 +dimmack,3 +dimonte,2 +dimov,1 +dimuccio,2 +dine,4 +dinfdale,1 +dingo,3 +dinh,39 +diniro,1 +diniz,1 +dinnison,25 +dinon,10 +dinow,1 +dios-brun,1 +diperna,1 +dipietro,2 +dirr,1 +diss,2 +dissinger,3 +ditfort,1 +dittmayer,1 +ditty,5 +divona,3 +dixey,6 +dixon,603 +dizmanis,1 +dizon,1 +djamatatradja,1 +djugiba,1 +djurdjevic,1 +dlugosz,1 +dmytrenko,3 +dmytriw,3 +dobel,2 +dobell,8 +doblinger,5 +dobney,3 +dobrigna,2 +dobrzanski,1 +dobrzinski,2 +dobrzycki,1 +doby,1 +docchio,1 +dockray,3 +dodic,2 +dods,7 +dodunski,1 +does,1 +dogg,2 +doheny,2 +dohse,14 +doi,3 +doimo,1 +doinbee,1 +doitschinov,1 +dojcic,1 +dojcincovic,1 +dokas,4 +dola,4 +dolan,95 +dolatowski,1 +dolby,7 +dolejs,1 +dolkens,2 +dolliver,18 +dolzan,1 +doman,44 +domarecki,2 +domek,4 +domergue,1 +domhoff,2 +dominey,3 +domingo,5 +domkus,1 +donaldson,207 +donda,4 +donegan,13 +donela,1 +donetzkow,1 +dongas,1 +donithorne,1 +donkin,7 +donnaruma,1 +donnellon,2 +donnison,4 +donnolley,7 +donskoj,1 +doody,41 +doogue,5 +dooke,1 +dooley,46 +doornekamp,2 +doray,1 +dorin,1 +doring,2 +dorling,9 +dorn,5 +doroodkar,1 +doroszczonek,1 +dorree,3 +dorrell,6 +dorsey,11 +dosmyk,1 +doudakliev,1 +doudman,1 +dougal,4 +dougals,1 +doumouras,2 +dountsis,1 +douthwaite,1 +douvos,4 +dovner,1 +dowdney,1 +dowland,1 +dowley,5 +dowling-hanson,1 +downsborough,1 +doy,3 +drady,6 +draffen,1 +dragas,3 +dragh,1 +dragheim,1 +dragomirescu,1 +draiden,1 +drallini,1 +drance,1 +drawwater,1 +draycott,1 +drayson,7 +drechsler,49 +dreckow,29 +drenovac,1 +drenth,5 +dreon,1 +drewe,3 +dreyer,25 +drilling,6 +drinkell,3 +dritsas,5 +driver-smith,1 +droegemueller,6 +dropulic,1 +drougas,5 +drought,3 +drown,1 +drozdowski,3 +druitt,8 +druszcz,3 +drymalik,1 +drymis,1 +drysdale,38 +drzezdzon,1 +du,20 +dua,1 +dubbeldam,2 +dubbioso,3 +dubicki,3 +dubrava,1 +duca,1 +ducanson,1 +duchatenier,3 +ducornez,1 +ducrou,2 +dudek,8 +dudgeon,19 +dudley,71 +due,3 +duenow,3 +duerinckx,1 +dufelmeier,1 +duffew,1 +dugdale,11 +dugec,2 +dugonjic,1 +duits,2 +dukelow,1 +dukeson,4 +dukic,11 +dulfer-hyams,1 +dulko,1 +duller,3 +dulnoan,1 +dumbrell,6 +dumetz,1 +dumpe,3 +dumphy,1 +dumsa,1 +dumuid,2 +dun,5 +dundovic,1 +dunis,2 +dunling,4 +dunnicliff,18 +dunnington,1 +dunstone,48 +dunthorn,2 +duont,1 +durairaj,1 +durban,2 +durbridge,27 +durdev,2 +durnin,6 +durovic,4 +durr,5 +dusek,2 +duss,1 +dutson,6 +dutt,1 +duus,3 +duvnjak,11 +duxfield,1 +dworak,2 +dwyerreid,1 +dzamko,1 +dziki,1 +dzino,1 +e,1 +eagar,1 +eamer,1 +eanbaram,1 +early,13 +earson,1 +earwaker,1 +easdale,1 +easlea,7 +easley,4 +easling,6 +eastaughffe,3 +easthope,6 +eayrs,5 +ebben,2 +ebdell,7 +ebert,77 +ebrahim,2 +ebzery,1 +echevarria,1 +eckersley-maslin,2 +econompoulos,1 +edakkadan,1 +eder,7 +edgecock,2 +edgecombe,25 +edgoose,1 +edgworth,1 +edhouse,4 +edi,1 +ediriweera,2 +edis,14 +edman,3 +edmeades,5 +edmonds-wilson,2 +edmonston,2 +edmundson,3 +edser,1 +edson,74 +edwarda,1 +edwardson,8 +efthimiou,7 +eftimiou,1 +egan,169 +eggan,1 +eggerstedt,1 +egglestone,21 +eglinton,76 +eglite,2 +ehmcke,2 +eichinger,3 +eight,2 +eilander,3 +eileen,2 +eimen,1 +eimerl,1 +einthal,3 +eisel,1 +eisele,13 +eisenhut,1 +eisner,7 +ejlak,2 +eka,1 +eke,2 +ekers,5 +ekiert,2 +ekner,1 +el-istamboli,1 +elas,1 +elavanalthoduka,1 +elbanna,1 +elbert,1 +elburn,2 +elderton,5 +eldregde,1 +elekes,2 +elekessy,3 +elferkh,1 +elfes,1 +elfstrom,1 +elgeezawy,1 +elhelou,1 +eliasaf,1 +eliassi,1 +elika,1 +eljaroudi,1 +elkhair,2 +elks,1 +elksnat,1 +elkson,3 +ellem,19 +ellston,7 +ellsum,1 +elphick,56 +elrick,16 +elstob,2 +elsworth,6 +eltantavy,1 +elwan,1 +elword,1 +emberg,1 +emberton,2 +embrey,6 +emel,1 +emerton,9 +emllin,1 +emmanuel,7 +emmott,4 +emptage,1 +emson,1 +eneberg,4 +enfield,1 +eng,3 +english-obst,1 +engst,3 +enjakovic,3 +ennanenidis,1 +eno-grant,1 +ens,1 +entresz,2 +epari,1 +epasinghe,1 +erdeljac,1 +erett,1 +ernster,1 +errigo,2 +ertzen,1 +eshpeter,1 +esimae,1 +eskandari-marandi,2 +esklund-kaim,1 +eskrigge,2 +eslambolchi,1 +esplen,1 +estacio,1 +estanillo,2 +estcourt,17 +estepa,1 +esterman,1 +estrella,2 +etchell,10 +etheridge,13 +etherington,34 +eton,1 +etschmann,2 +euakittiroj,1 +eubel,2 +euth,2 +evans-street,1 +evans-zijlstra,1 +everding,2 +everett,142 +everill,2 +eversen,3 +every,12 +eves,20 +eveston,6 +evison,12 +ewald,4 +exalto,1 +excell,53 +exell,3 +extremera,3 +eyles,80 +eyre,34 +ezard,4 +ezepina,1 +ezis,3 +faatupuinati,1 +fabbro,14 +fabel,5 +facci,2 +faehse,8 +fagerlund,3 +faggetter,1 +fahey-thomas,1 +fahlberg,2 +fail,1 +fair,16 +fairbrass-king,1 +fairgrieve,1 +fairnington,6 +fajri,1 +fakaris,2 +faker,1 +falcetta,2 +falcione,1 +falcone,1 +falivene,2 +falkous,1 +fallarino,1 +fallo,1 +falting,17 +falusi,2 +falvey,3 +famelis,1 +fancsali,2 +fancsik,1 +fang,7 +fangler,1 +fanner,1 +fanraatree,1 +faraday,1 +farah,15 +farazer,1 +fardell,13 +fargahry-tolba,1 +faria,2 +farleigh,1 +farndell,2 +farnham,26 +farnworth,1 +farokhmehr,1 +farragher,1 +farrajota,1 +farrimond,10 +farronato,2 +faskheev,1 +fassina,10 +fassos,2 +fatah,1 +fatale,1 +fatigati,1 +faulhaber,1 +faull,23 +fauser,43 +favaro,4 +favero,2 +favotti,1 +fawkner,16 +fax,3 +fazis,1 +feakes,1 +fearnall,2 +fearon,7 +feary,5 +feast,48 +febrianto,1 +feciak,3 +feeley,7 +feeney,32 +fehlmann,2 +fehrenbach,2 +fehrmann,2 +feil,12 +feinle,1 +feldbergs,1 +feleppa,16 +felici,5 +felicity,1 +felke,1 +fellner,1 +felmingham,36 +felstead,8 +felten,1 +felton-taylor,1 +felusch,4 +fely,2 +fendy,1 +feneley,9 +fenis,1 +fenlon,1 +fenoughty,3 +fenu,3 +fenwick,76 +fergie,5 +fergus,6 +fergusson-stewart,1 +ferley,1 +fernan,1 +fernance,8 +fernando,26 +ferrar,14 +ferrazzola,4 +ferretti,5 +ferri,7 +ferris,95 +ferrison,1 +ferron,1 +fest,1 +fester,1 +fey,10 +ffrench-rudd,1 +fhoumack,1 +ficara,2 +field-dodgson,1 +fiene,1 +fierinck,1 +fijolek,1 +fikar,1 +filander,1 +filce,4 +filgate,11 +filip,5 +filipetto,1 +filipic,1 +filipov,1 +filipovic,10 +filipovski,1 +filliponi,1 +fimeri,14 +fimmano,8 +finamore,2 +finey,6 +fingas,1 +finlay,137 +finnemore,2 +fiorani,2 +fiorenza,8 +fisher-johnson,1 +fitisemanu,1 +fitt,4 +fittock,12 +fitzimons,1 +fitzpatrick,271 +fizgerald,1 +fizio,1 +fjeldsbo,1 +flacco,2 +flahavan,1 +flamey,1 +flannery,35 +flassman,4 +flatman,15 +flaubert,1 +flaus,3 +fleck,1 +fledge,1 +fleet,48 +flegg,2 +fleischmann,2 +flesfader,2 +fletcher-jones,7 +flockhart,9 +flores,17 +florinis,1 +flowerday,1 +foall,1 +focas,1 +foch,3 +foenander,5 +fogg,27 +fogliano,5 +fokeas,2 +follese,2 +folmer,3 +folo,1 +fondum,3 +foottit,2 +forbes-ewan,2 +forby,12 +forehan,1 +forgie-wendt,2 +forlot,1 +formichella,6 +formigoni,1 +fornachon,1 +fornarino,2 +foronda,1 +forshaw,10 +forsten,1 +forstick,1 +forstner,2 +fortuna,1 +forwood,24 +fosdick,1 +fostiak,2 +fotinos,1 +fotkou,1 +fotopoulos,13 +foulger,1 +fowdry,1 +fowkes,2 +foxall,2 +frada,1 +fraenkel,2 +fragomeli,4 +frahn,77 +frainey,1 +frammartino,1 +francica,1 +frangie,1 +frankiewicz,1 +franklin-browne,2 +frantiesk,1 +frantova,1 +franzin,5 +franzke,1 +frauenfelder,3 +fraval,1 +frazer-oakley,1 +frecker,1 +freeborn,16 +freeburn,3 +freiman,1 +french-kennedy,1 +frencham,5 +fretwell,12 +freud,1 +freudenberger,1 +frew,26 +friar,1 +friebel,13 +friedman,8 +friman,1 +frisina,2 +friswell,3 +frits,2 +frnklin,1 +frogley,7 +frohmuller,1 +frolow,5 +fromentin,2 +froomes,1 +froscio,3 +frosina,1 +froud,10 +frundt,1 +frusher,5 +fuamli,1 +fuda,10 +fudali,5 +fuenzalida,1 +fuff,1 +fuhlendorff,2 +fukushim,1 +fule,2 +fulgido,3 +fullam,1 +fullerton,37 +fullgrabe,41 +fullwood,13 +funadiki,1 +furbow,4 +furfari,5 +furing,1 +furmaniak,1 +furnari,3 +furneaux,5 +furner-smith,1 +furness,27 +furseman,3 +furtado,2 +furze,16 +fusco,24 +fusillo,1 +futcher,5 +fysh,14 +gabbert,4 +gabriel-jones,1 +gacek,1 +gade,13 +gaden,11 +gager,2 +gaglioti,2 +gail,4 +gailis,2 +gailor,1 +gaitanis,1 +gajda,8 +galangarri,1 +galantomos,8 +galappaththi,1 +galarneau,1 +galazowski,1 +galbraith,61 +galek,2 +galffy,3 +galgaardt,1 +galich,3 +galinec,4 +galister,1 +gallan,1 +galle,1 +gallehawk,2 +gallichio,1 +gallinsky,2 +gallio,6 +gallirhir,1 +gallizzi,4 +gallman,8 +gallnor,1 +galnadiwuy,1 +gamaly,1 +gambiraza,1 +gambranis,5 +gamlin,19 +ganesharajah,1 +ganev,2 +ganfield,1 +gani,2 +ganibegovic,2 +gannah,1 +gao,17 +garad,1 +garam,2 +garanggar,1 +garard,3 +garas,3 +garbas,1 +garbicz,1 +garcia,83 +garcia-lavarache,1 +gardawan,2 +garden,16 +gardenier,3 +gardoni,1 +garforth,10 +garg,2 +gariglio,1 +garipou,1 +garlett,1 +garnett,33 +garnsey,8 +garran,4 +garrand,1 +garrigan,8 +garrood,5 +garthwaite,2 +gartlan,10 +gartley,1 +gartz,2 +garven,3 +garwell,1 +garzo,2 +gascoigne,18 +gaskin,86 +gaspardis,2 +gasparin,11 +gasset,3 +gastarini,1 +gatcke,1 +gatward,4 +gaugg,2 +gavel,2 +gawanbuy,1 +gawthrop,3 +gayda,1 +gaylard,10 +gaynes,6 +gazley,1 +gazzola,34 +geappen-taylor,1 +gearen,2 +gearin,2 +gearman,7 +gecele,1 +geduld,2 +geertsema,2 +gehling,10 +gehlken,11 +geischek,1 +geissmann,1 +gelati,1 +gelok,2 +gemo,2 +gen,1 +gencheff,3 +gendron,3 +general,1 +gengi,1 +genner,5 +genockey,2 +genovese,18 +geo,1 +george,480 +georgee,1 +georgeou,2 +georgetti,2 +georgiadis,16 +georgievski,1 +georgios,1 +georgou,1 +geraghty,45 +gerdes,1 +gergely,9 +gerhardt,4 +gerhmann,1 +gerick,3 +germinario,9 +gerogles,1 +gerritsen,13 +gers,6 +gershon,1 +gerste,3 +gerstel,1 +gessner,1 +gethen,1 +getzler,1 +geue,56 +geyash,1 +gfarrick,1 +ghagtaf,1 +ghan,1 +ghanooni,1 +gheller,1 +ghisalberti,1 +ghosn,1 +giacca,1 +giacomo,1 +giagu,1 +giampiccolo,1 +gianakis,5 +giandzis,1 +giannakeas,2 +giannaris,1 +giannes,3 +giannikouris,4 +giannoni,5 +giannopolous,1 +giannos,1 +giannou,2 +giardini,1 +gibb,85 +gibbett,10 +giday,2 +giefdercht,1 +giehl,3 +gielen,3 +gierus,4 +giesen,1 +gigliotti,2 +gigney,31 +gikopoulos,3 +gilbertson,76 +gilcher,3 +gilcrist,10 +gildea,8 +gilfedder,8 +gilfelt,2 +gilian,1 +gilkef,1 +gilkes,22 +gillard,118 +gillert,2 +gilles,13 +gilley,7 +gillick,6 +gillis,25 +gillkum,1 +gilrane,3 +gilsoul,1 +gimamenez,1 +gimbrere,3 +gimoukis,1 +giniotis,2 +gioia,5 +giola,1 +giolbas,1 +gioni,1 +gionis,1 +giordano,9 +giorgatzis,1 +giorginis,2 +giouzelis,2 +girando,2 +girdauskas,1 +girdler,25 +girling,5 +gissing,4 +giuffrida,1 +giuggioli,1 +giugovaz,1 +giunti,1 +giurelli,1 +gladman,14 +gladysz,1 +glascock,1 +glascott,1 +glass,90 +glavach,2 +glazewski,1 +gleissner,2 +glennon,17 +glerum,1 +gliessert,3 +glifos,1 +glinatsis,3 +gliscinski,1 +glisinski,1 +glod,1 +glossop,7 +gloster,6 +glouftsis,10 +gloustfis,1 +glover-smith,2 +glowick,1 +gluck,1 +gluschke,3 +gluszyk,1 +glutz,1 +gnesel,1 +goadsby,1 +gobuccio,1 +gocentas,6 +goczan,2 +gocze,1 +goda,1 +godbier,1 +godding,2 +godfrey,228 +godsiff,1 +goess,3 +goessling,1 +goetze,9 +goffredo,1 +gogel,27 +gogovcev,2 +gohl,13 +goich,1 +golanski,5 +golburn,1 +gold,24 +golden,9 +golder,35 +goldsworthy,166 +golenda,1 +golis,1 +gomerski,2 +gomulka,1 +goncharov,1 +gondzioulis,3 +gonsalex,1 +gontar,2 +gonzales,8 +goodacre,9 +goodchap,1 +goode,143 +gooder,1 +goodeve,1 +goodisson,3 +goodrum,7 +goodwin-jones,1 +goodworth,2 +goonan,8 +goonewardend,1 +gorgolon,1 +gorjan,2 +gorjanc,2 +gornicki,1 +gornunovs,1 +gorog,1 +goryan,2 +gosain,1 +gosztola,1 +gotovac,3 +gottaas,3 +gottliebsen,1 +gottschling,1 +gotz,1 +gou,1 +goubil,1 +goult,5 +gouneau,1 +gourd,10 +gouvoussis,1 +gowers,3 +gowin,2 +gowling,35 +goy,2 +goymour,4 +goz,1 +gozdzik,2 +grabau,1 +grabek,2 +grabler,1 +gracie,15 +gradischer,1 +gradley,1 +graesser,3 +graetzer,3 +grafanakis,2 +grafton,25 +graham-jones,5 +graham-king,1 +grainger,75 +granadurai,1 +granburg,1 +grandal,2 +grandioso,4 +grandison vaughan,1 +graneek,1 +granter,1 +granville-edge,1 +grasse,1 +gratez,1 +gratzis,2 +graue,25 +graus,2 +gravenall,1 +gravis,1 +grawich,1 +gray-grzeszkiewicz,1 +graydon,2 +graziotin,1 +grbovac,2 +grcman,1 +grdobic,1 +gread,1 +greathouse,1 +greatwich,1 +green,1685 +greenacre,2 +greenberg,8 +greenhalgh,52 +greenland,14 +greenleaf,2 +greenshields-hannah,2 +greep,3 +greg,3 +gregorace,2 +gregorevitch,1 +gregori,1 +gregorin,1 +gregorovic,1 +grehan,2 +greig-francis,2 +greiveson,1 +gretschmann,2 +grewar,2 +grewe,1 +grey-skinner,1 +grey-smith,1 +grgurich,1 +grgurovic,5 +grie,1 +grier-smith,1 +grierson,33 +griffen,26 +grigolato,1 +grigorev,1 +grigs,1 +grillas,3 +grillett,24 +grimaldi,8 +grimditch,4 +grimm,30 +grimsell,1 +grimsley,5 +grimstead,1 +grimster,3 +grimwade,12 +grincelis,4 +grindley,10 +griptom,1 +gripton,12 +grisham,1 +grobler,4 +groenewege,8 +groenewoud,4 +groenier,2 +groenveld,9 +gromball,3 +gronow,6 +grooby,7 +grosser,105 +grosskopf,3 +grossman,30 +grosvenor,36 +groves-ordway,1 +grubb,100 +grudnoff,1 +gruener,1 +grummer,1 +grundner,1 +grybowski,3 +grygiel,1 +gryn,1 +grypma,1 +grzesniak,2 +grzybek,1 +guarino,8 +guarino-watson,1 +gudelj,1 +guduguntla,1 +gue,3 +guelzow,2 +guglani,1 +gugushess,1 +guihenneuc,1 +guildea,1 +guiler,2 +guilmarten,1 +gukulurruwuy,1 +gulesserian,1 +gulia,1 +gulin,9 +gullick,2 +gulliver,22 +gully,47 +gultjaeff,3 +gumbys,1 +gunawan,9 +gundogeu,1 +gune,1 +gunillasson,1 +gunnell,3 +gunnlangsson,1 +gunnlaugsson,1 +gunstone,1 +gusain,1 +gush,1 +gushow,1 +gustas,2 +gustini,3 +gustowski,3 +guthridge,10 +gutschi,1 +guyatt,9 +guymer,23 +gwatking,15 +gwyn,2 +gyapjas,1 +gyasi-agyei,1 +gyergyak,1 +gyory,3 +haack,11 +haak,2 +haapakoski,1 +haar,15 +haberfield,12 +haberstich,1 +habtemariam,1 +hackenberg,2 +hacking,1 +hadaj,4 +hadchiti,1 +hadchity,1 +hadnuk,1 +hadsis,1 +haee,1 +haemel,1 +haeusler,26 +haga,1 +hage,106 +hagemann,7 +hagenbruch,3 +hages,5 +haggan,7 +haggett,40 +haghighatjoo,1 +hague,30 +hague-rout,1 +hah,1 +hai van,1 +hainke,1 +haj,1 +hajda,1 +haji,3 +haklar,1 +halamaj,1 +halbe,1 +halberda,1 +halchuk,1 +halestrap,1 +halik,3 +halikos,2 +halimee,1 +halinen,1 +halladay,1 +hallatt,1 +hallegraeff,2 +hallert,1 +hallet,2 +halley,29 +halligan,16 +hallmaier,1 +hallock,2 +haloulos,2 +halvarsen,1 +hambasyi,1 +hamberger,1 +hamblin,10 +hamblyn,4 +hambridge,4 +hamdan,7 +hamel,4 +hamelink,3 +hamers,3 +hamilton-smythe,1 +hamley,9 +hammell,1 +hammer,68 +hammerton,2 +hammill,28 +hammonds,2 +hamon,19 +hamouche,1 +hampsen,1 +hampton-smith,4 +hamrol,3 +hand,115 +handberg,6 +handel,3 +handy,5 +haner,2 +hanigan,19 +haniotis,3 +hank,13 +hanks,25 +hanna,116 +hannaby,1 +hannagan,35 +hannett,6 +hannink,2 +hannus,2 +hanretty,1 +hanselman,3 +hanseon,1 +hansongkram,1 +hantke,5 +hantken,3 +hanxomphou,1 +hap,1 +hapiak,1 +happold,1 +har,2 +haralambos,1 +harald,1 +haraszti,1 +harbard,1 +harbord,4 +harbottle,12 +hardbottle,5 +hardiker,3 +hardono,1 +hare,48 +haren,27 +hargreaves-morris,1 +hargrove,2 +harinen,1 +hariss,2 +harjanta,2 +harkotsikas,3 +harmse,1 +harmston,1 +haroon,1 +harrer,4 +harrington,187 +harris-stone,1 +harrity,4 +harrland,5 +harsing,2 +harslett,13 +hartkop,1 +hartland,18 +hartley-smith,1 +hartzenberg,3 +harvey-fuller,1 +harward,2 +hase,2 +hasenbalg,3 +hashemizadeh,4 +hashmi,2 +haskayne,2 +haskett,32 +hassack,1 +hassall,27 +hassel,1 +hassell,33 +hassfurter,1 +hassold,7 +hathaway,20 +hatherell,3 +hatji,3 +hatsis,1 +hatter,2 +hauff,6 +haughney,2 +haupt,12 +hauripz,3 +hauser,24 +haussen,4 +havelberg,28 +haverfield,4 +havetta,1 +haviv,2 +havrda,1 +havriluk,6 +havu,3 +hawe,2 +hawes,85 +hawke-fitzhardy,3 +hawkers,1 +hawkings,2 +hawkridge,3 +haxton,2 +hayam,1 +hayball,9 +haydock-wilson,2 +haymes,2 +haythorpe,19 +haze,3 +hazell,65 +hazlitt,1 +headon,18 +healsmith,2 +heans,1 +hearde,1 +hearn,76 +heathfield,8 +hebberman,27 +hebisch,1 +heckenberg,5 +hedaux,3 +hede,1 +heenan,22 +heerey,16 +heerschap,1 +heesemans,4 +heesom,1 +heesom-green,1 +hefford,49 +heffron,1 +hegerty,1 +heggan,1 +hegger,1 +heggs,1 +heidrich,38 +heiland,1 +heiligenberg,1 +heilmair,2 +hein-taylor,1 +heinke,1 +heinlaid,1 +heithersay-jones,1 +hekele,2 +hekmeijer,1 +held,6 +helen,5 +helliar,3 +helling,6 +hellyeloard,1 +helmot,2 +hem,4 +hemanth,1 +hemed,1 +hemerka,1 +hemlof,1 +hemmings,40 +hemus,1 +henderson-smith,2 +henderson-wilson,11 +hendie,1 +hendricks,17 +hendriksen,4 +hendy-pooley,3 +heney,2 +henneken,1 +hennicke,4 +hennie,1 +hennigs,3 +hensellek,1 +henshaw,31 +hentze,2 +henzel,2 +heouo,1 +heraud,2 +herbach,1 +herbert,259 +herburt,2 +hercog,1 +herendeen,1 +hereora,1 +hereth,1 +herford,1 +hering,10 +hermans,10 +hermely,1 +hermiston,2 +hermosisima,2 +hern,11 +heron,100 +hersey,32 +herson,1 +hervey,3 +hessler,1 +heuer,9 +heuston,6 +hevera,3 +heweston,1 +hewetson,6 +hewitt-banks,1 +hewittson,1 +hewson,38 +heyer,13 +heyes,21 +heyhoe,1 +hiam,1 +hibenic,1 +hibibis,1 +hick,20 +hicki,2 +hickinbotham,6 +hide,4 +higges,1 +higgin,1 +highet,28 +highfield,9 +highfold,3 +highmore,4 +highson,1 +higlett,3 +hignett,10 +hildenhagen,1 +hill-smith,10 +hillary,10 +hilleson,1 +hills-wright,1 +hillsdon,1 +hilsberg,2 +hilton,114 +hiltula,1 +hinchcliff,5 +hinchey,11 +hinchliff,1 +hindess,1 +hindley,14 +hindmarch,9 +hingee,2 +hingston,132 +hinks,22 +hinksman,1 +hinkston,1 +hinterreiter,1 +hipkiss,11 +hiras,4 +hirose,3 +hirota,2 +hirschfield,2 +hirschman,1 +hirsimaki,1 +hirsinger,3 +hirstle,1 +hirvihalme,2 +hirzel,2 +hiscoke,2 +hiscox,11 +hislop,31 +hissan,1 +hitchenor,2 +hiu,1 +hlawa,2 +hlawatsch,1 +hnarakis,4 +ho,128 +hoang,46 +hoaresykes,1 +hobbis,3 +hobill,1 +hobson,85 +hochstadter,1 +hochuli,8 +hochwimmer,1 +hodby,12 +hodgens,9 +hodgy,1 +hodor,1 +hoebee,3 +hoebergen,4 +hoehne,3 +hoeller,2 +hoelmer,3 +hoepfner,5 +hoerner,4 +hoffman,132 +hofhuis,3 +hog,1 +hoger,2 +hoggan,5 +hogge,1 +hohn,6 +hoistech,1 +hol,1 +holasek,2 +holberry,1 +holbery,1 +holbrow,2 +holburn,3 +holdenby,1 +holderhead,4 +holer,5 +holgar,1 +holgate,23 +holland-dukes,1 +hollett,2 +hollind,1 +hollowood,1 +hollworth,1 +holme,25 +holmyard,8 +holna,1 +holoubek,2 +holsten,3 +holthuis,3 +holweg,4 +holwill,2 +holyhrim,1 +holyoak,15 +holyoake,3 +holzbauer,2 +holzner,3 +homann,12 +homles,1 +homolya,1 +hompoth,1 +hondrovasilopoulos,2 +honeychurch,29 +honig-kangoo,1 +honold,1 +hoogendoorn,3 +hoogesteger,1 +hoogvliet,1 +hoover,2 +hope,180 +hoque,2 +horance,1 +horkings,4 +horriat,2 +horsley,21 +horstler,1 +horswill,4 +horta,1 +horvathe,1 +hosgood,8 +hoshino,1 +hosne,1 +hosneara,1 +hoss,1 +hostler,2 +hotich,1 +hotota,1 +houillon,1 +houldsworth,5 +houllis,2 +houlson,3 +houssenloge,1 +houweling,2 +hoving,2 +howie,104 +howlet,1 +hows,2 +howser,1 +hoyland,5 +hoysted,3 +hozha,1 +hristodoulou,1 +hruby,1 +hrynaewiecki,1 +hrynczuk,1 +hsin,1 +hubczenko,2 +hubner,3 +hudd,20 +huddy,45 +huebner,9 +hueneke,2 +huettenrauch,1 +hugelmann,1 +hugen,3 +huggins,22 +huggonson,2 +hughston-wynne,1 +hujsak,1 +hukowskyj,1 +hulands,3 +hulanicki,2 +hulley,2 +hully,1 +hulston,2 +humberdross,5 +humphars,1 +humphreys,93 +humpreys,2 +hund,1 +hunns,1 +hunting,5 +hurem,4 +hurkett,2 +hurl,3 +hursey,20 +huseinovic,1 +hushi,1 +husseini,1 +huster,1 +husy,1 +hutcheson,19 +hutchieson,1 +hutchines,1 +hutiuk,3 +hutten,1 +huttlestone,2 +huupponen,1 +huverova,1 +huxley,59 +huynhn,1 +huysse,2 +hyakutake,1 +hygonnet,1 +hyland,198 +hyles,10 +hyrycz,3 +iacopetta,12 +iancar,2 +iasenzaniro,1 +idai,1 +idini,1 +idris,3 +idzikowski,4 +ierodiaconou,1 +iffland,2 +igag,1 +ihnatko,1 +ikea,1 +ikeda,6 +ikeguchi,1 +ikonomou,11 +ikpatt,1 +ilczak,1 +ileris,1 +ilgen,2 +ilicak,1 +ilievski,2 +iliffe,6 +iliopoulos,4 +ilitch,1 +ilmberger,1 +imanian,1 +imgraben,4 +imhof,2 +imire,1 +imison,2 +inall,6 +indelicato,1 +indielid,1 +inge,6 +ingels,2 +inglas,1 +inglebret,1 +inglese,3 +ingley,1 +innis,9 +innocenti,1 +inserra,1 +inski,1 +insley,2 +intrapanya,2 +inveen,3 +iolovska,1 +ionnidis,1 +ions,1 +iovino,7 +ippoliti,3 +irizarry,3 +irons,19 +irudayaraj,1 +irving-rodgers,1 +is,1 +isakov,2 +isgro,1 +ishak,1 +isio,1 +iskra,3 +ismakic,2 +isobelle,1 +isola,4 +issell,2 +iswaran,1 +itinisoff,1 +ito,3 +iuka,1 +iussa,2 +ivanco,1 +ivar,2 +ivers,9 +iviglia,1 +iwase,1 +jablouskas,1 +jackermis,2 +jackett,4 +jacmon,2 +jacobus,1 +jacues,1 +jacura,2 +jadana,1 +jaeck,1 +jaffar,1 +jaffe,1 +jaffres,1 +jagodnik,2 +jagodzinski,1 +jahic,4 +jakab,1 +jakimow,2 +jakiwczyk,1 +jaktman,2 +jalayer,1 +jaldiani,1 +jamaludin,1 +james-palmer,1 +jaminon,1 +jancek,2 +janda,5 +jandrea,1 +janejka,2 +janet,1 +jang,6 +janicek,1 +jankiwsky,1 +jankunas,1 +jankus,6 +janowicz,4 +janowska,1 +janowski,2 +janusz,1 +janzso,2 +jaquiery,1 +jaquillard,2 +jardine,24 +jaric,2 +jarick,2 +jasniach,2 +jaudzems,6 +jayaraman,2 +jayaswal,1 +jean,11 +jeandupeux,1 +jedynak,3 +jefferys,8 +jeffreson,4 +jeffries,139 +jehle,3 +jehne,1 +jeitner,1 +jelenkovic,1 +jelk,1 +jember,1 +jenei,1 +jenje,1 +jenko,4 +jennion,1 +jennions,1 +jenvey,2 +jermolajew,1 +jervis,24 +jeschke,5 +jessen,14 +jesser,40 +jessup,97 +jesurasingham,1 +jetter,1 +jevons,5 +jewkes,1 +jeyathevan,1 +jeziorski,1 +jezzard,1 +jiang,14 +jigede,1 +jiggens,1 +jillian,1 +jimenea,4 +jinks,12 +jinmauliya,1 +jirgens,1 +jnguye nphamhh,1 +joannou,11 +joaquim,1 +jobber,3 +jobbins,5 +jocobson,1 +joel,4 +joergensen,1 +joinbee,1 +jolly,301 +jolta,1 +joly,1 +jonauskas,3 +jongebloed,5 +jongewaard,5 +jongh,1 +jonjic,1 +jonnek,2 +jonsson-harrison,1 +joraslafsky,14 +jorge,1 +jorkowski,1 +jormanainen,1 +joseland,1 +joselin,1 +jouravlev,1 +jovanovitch,1 +jovcic,1 +jover,2 +jovicic,1 +jozefowski,1 +jozelich,2 +jozic,1 +jozwa,2 +ju,2 +juanta,4 +judkins,2 +juel,1 +jugovac,5 +jukic,13 +julavdzija,1 +julge,2 +julian-bailey,1 +julius,4 +juma,2 +jumamoy,1 +junge,1 +jungkyu,1 +juntanamalaga,2 +jurant,1 +juraschek,2 +jurdi,1 +jurenka,2 +juric,12 +jurrah,1 +juskevics,2 +juskevisc,1 +juzuf,1 +kacic-bartulovic,1 +kacir,1 +kacopieros,1 +kaddatz,2 +kaderes,4 +kadii,1 +kaegai,1 +kahadugoda,2 +kahfi,1 +kahl-smith,1 +kahlon,4 +kahnert,1 +kaholi,1 +kaim,2 +kaithakulam,1 +kakakios,1 +kakko,5 +kalaburnis,2 +kalamaris,1 +kalambakas,1 +kaldy,4 +kaleb,4 +kalend,1 +kalicinski,1 +kalinowski,8 +kalirajan,1 +kalistis,1 +kalitsounakis,2 +kaljovic,1 +kalka,2 +kallis,2 +kalma,2 +kalmus,3 +kalnins,17 +kalogerakos,2 +kalogeras,5 +kambitsis,1 +kambouras,1 +kaminskas,5 +kamler,1 +kammerman,10 +kammermann,41 +kamp,10 +kamruzzaman,1 +kanagasabai,1 +kandunias,1 +kaneilopoulos,1 +kanellos,7 +kaney,1 +kang,19 +kania,1 +kanikula,2 +kanizay,3 +kannangara,3 +kannikorn,1 +kantamessa,1 +kanter,1 +kao,4 +kapadia,1 +kapeen,1 +kapel,2 +kapeller,7 +kapetina,1 +kapioldassis,1 +kaplan,7 +kaplanis,1 +kaploon,2 +kapoor,5 +kappe,2 +kapusniak,1 +karadinovski,1 +karafilidis,1 +karafilis,1 +karafilloudis,1 +karafyllis,1 +karahalios,5 +karakoulakis,2 +karalus,2 +karamanakis,1 +karanikolis,1 +karantonis,3 +karasavas,2 +karatasakis,1 +karaterpos,1 +karauda,1 +kardwell,1 +karimizandi,1 +karipa,1 +karkatsalis,1 +karkazis,3 +karling,2 +karlovcec,1 +karlsen,5 +karolewski,1 +karoussis,4 +karpa,1 +karpathios,4 +karpfen,3 +karppinen,1 +karrannis,1 +kars,1 +karstaedt,1 +karunadasa,1 +karvelas,2 +karvounaris,1 +kasch,1 +kasehagen,5 +kaselow,3 +kasinathan,2 +kasotakis,1 +kaspar,3 +kassai,2 +kassir,1 +kassos,5 +kassoudakis,1 +kastelan,1 +kastelik,2 +kastrappis,3 +katarski,5 +katesook,2 +katnich,3 +katracis,1 +katsaitis,2 +katsiavos,4 +katsicologos,1 +katsikas,1 +kattas,2 +katzer,1 +kaufman,10 +kaufman hall,4 +kauhanen,2 +kaukov,1 +kaun,1 +kaunesis,2 +kava,3 +kavaleris,1 +kavals,1 +kaveberg,1 +kavouklis,1 +kaw,2 +kawan,1 +kaxhiro,1 +kaylock,6 +kayser,14 +kayvas,1 +kazimir,1 +keane-stack,1 +keaney,3 +keany,7 +kearnes,10 +keatch,9 +kecskes,1 +keeble-buckle,1 +keel,3 +keelty,1 +keepence,3 +kees,2 +kegge,1 +keiski,1 +keith-ladhams,1 +kelaart,3 +kelakios,3 +keldher,1 +kellar,4 +kellerman-clarke,1 +kelley,61 +kellogg,3 +kellow,22 +kemenyvary,4 +kemish,1 +kemmif,1 +kempe,36 +kempson,10 +kempton,15 +kemsley,7 +kenafacke,1 +kenakidis,2 +kenche,1 +kennaway,7 +kennealy,9 +kennerley,7 +kennion,1 +kennison,5 +kenpster,1 +kent-burford,1 +kentsch,1 +keoh,1 +kepple,1 +kerbellec,1 +keri,3 +kerkham,22 +kerkhoff,3 +kerkhofs,1 +kerkvliet,2 +kerley,47 +kermeen,9 +kerney,3 +kernutt,1 +kerr-sullivan,2 +kerrod,1 +kerschke,2 +kerslake,56 +kerslake-ling,2 +kert,1 +kervers,4 +kesseck,1 +kessegian,1 +kestermann,1 +ketelaars,1 +ketoglou,1 +ketter,1 +kettewell,2 +kettleton,1 +kevic,1 +keville,1 +kexel,1 +keyhoe,1 +keyworth,1 +khaleeq,1 +khalid,2 +khaliq,1 +khalu,1 +khammash,5 +khanbhai,1 +khandker,1 +khanthavongsa,4 +khelghati,1 +khider,1 +khodan,1 +khom,1 +khouzan,1 +khuc,3 +khut,2 +kibby,1 +kibukamusoke,1 +kiczurczak,2 +kidner,3 +kidsley,2 +kiea,1 +kiebach,1 +kiek,2 +kielczewski,1 +kielstra,1 +kiernan,18 +kiesewetter,2 +kight,1 +kiker,1 +kilbuen,1 +kilby,37 +kilham,2 +killick-moran,1 +killin,3 +killingbeck,3 +killington,1 +killip,2 +kilmartin,21 +kilponen,1 +kimmonth,1 +kinal,1 +kincaid,5 +kindavong,2 +kindblad,2 +king-harris,1 +king-jones,3 +kinghorn,4 +kingscott,1 +kingsley,26 +kingswell,3 +kinnane,31 +kinniburgh,2 +kinniff,2 +kinsele,1 +kinter,11 +kinzett,2 +kiosses,11 +kioussis,2 +kirana,1 +kirasak,1 +kirby-fahey,2 +kirchener,2 +kireev,1 +kirimovs,1 +kiripolszki,2 +kirkmoe,3 +kirkness,1 +kiroff,3 +kirste,1 +kirton,3 +kisch,1 +kiss,28 +kissling,1 +kitas,1 +kitche,1 +kitney,1 +kitzelmann,1 +kiukucans,1 +kivrins,1 +kiziridis,1 +kizmanic,1 +kjaer,1 +klanarong,1 +klander,3 +klees,2 +kleiner,4 +kleinstueck,1 +klekociuk,5 +klemencic,3 +klemm,51 +klemse,1 +kleve,1 +kliem,2 +klimkiewicz,1 +klimowski,1 +klingohr,1 +klinovski,5 +klintukh,1 +klisch,2 +kljaic,1 +klopfer,1 +kloth,1 +kloubek,3 +kluge-vass,1 +klugman,2 +klus,2 +kluske,41 +kmitas,1 +knapman,13 +knappstein,17 +kneal,2 +knell,1 +knerr,1 +knipler,1 +knoblich,1 +knockolds,1 +knoester,2 +knoing,1 +knopf,1 +knowling,16 +knuplez,1 +knynenburg,2 +kobotheclas,2 +kobus,1 +kochiwama,1 +kocholla,1 +kocini,1 +koeford,1 +koelman,4 +koeman,1 +koenders,6 +koennacke,1 +koerbin,6 +kofler,2 +kogon,1 +kohansal,1 +koivisto,1 +kokins,1 +kokkotos,3 +koklas,1 +kokorinos,3 +kolabinski,3 +koldea,1 +koldej,1 +kolednik,2 +kolodina,1 +kolodziejczky,1 +kolosche,5 +kolowca,1 +kolton,1 +kolze,2 +komaris,1 +komenza,1 +kominek,2 +komsic,2 +kon,6 +kondakov,2 +kondo,1 +kondraciuk,1 +kondratavicius,2 +kondylakis,1 +kongkerntune,1 +kongmalavong,2 +konistis,2 +konitsis,1 +konopacki,2 +konstad,4 +konstantinopoulos,1 +kontibas,4 +kontogonis,6 +kontopoulos,6 +koolen,3 +koopman,17 +kooyman,7 +kooymans,5 +kopecki,3 +kopernick,1 +kopetow,2 +kopievsky,2 +kopilas,2 +koppan,3 +koral,4 +koranjis,1 +korbut,2 +kordic,2 +korff,8 +korfia,1 +koricic,1 +korman,1 +kormendy,1 +kornetzke,2 +korniotakis,1 +korolija,1 +korompay,1 +koroneos,1 +korponay,1 +korrelvink,1 +korth,1 +kosch,4 +koschelew,3 +kosewicz,1 +kosich,1 +kositcin,2 +koslowicz,3 +kostantakis,2 +kostaras,1 +kostelnik,1 +kostoff,5 +kostovski,2 +kostrej,1 +kostrzynski,2 +koszorus,2 +kotal,4 +kotaro,1 +koteschel,2 +kothe,3 +kotowski,2 +kotsiomitis,2 +kotsomitis,1 +kotzbeck,1 +kotze,4 +kouba,4 +kouimanis,5 +koulenios,1 +koulianos,12 +koulizos,5 +koundouzis,1 +kounis,5 +kountourogiannis,1 +kourou,2 +kousiandas,3 +koussidis,2 +koutlakis,8 +koutoulogenis,1 +koutsaimanis,1 +koutsoubos,1 +kouvelis,1 +kouvoussis,2 +kouzaba,2 +kovacic,17 +kowald,65 +kowanko,2 +kowcza,1 +kowlessar,1 +kowplos,2 +kowtun,3 +koziol,8 +kozlowska,1 +kozoolin,4 +kozubiewicz,1 +kozuh,1 +kradolfer,4 +kragelius,1 +krajcinger,1 +krajewski,3 +krajnc,2 +kraly,1 +krambousanos,1 +kramsamy,1 +kranenborg,2 +kranic,3 +kranz,41 +krasioukova,1 +krasts,1 +kratschmer,1 +kratz,1 +kratzer,1 +krauklis,1 +kray,2 +krecinic,1 +krecmanis,1 +krecu,3 +kreft,2 +kreibig,4 +kremneff,4 +krempl,1 +krenske,2 +kreymborg,2 +kriaris,2 +kriekenbeek,3 +kriesel,1 +krige,2 +krile,3 +krishnan,9 +krishnananthan,1 +krist,4 +kristalyn,1 +kristens,1 +kristoff,1 +krisvoshev,1 +krivenkov,1 +krivitch,1 +krivushenko,1 +krix,6 +krochmal,1 +krollig,29 +krombholtz,1 +kromwyk,8 +krone,1 +kronquist,1 +kroopin,1 +kropinyeri,5 +kropman,1 +krouch,1 +kruck,2 +kruhse,4 +krupa,2 +krvavac,1 +krzemionka,1 +krzempek,1 +krzoska,1 +krzys,5 +krzyszton,1 +kubenk,11 +kudahl,1 +kue,1 +kuehlich,2 +kueval,1 +kuhadasan,1 +kuhlwind,1 +kuhndt,8 +kuiters,1 +kujala,1 +kuki,1 +kukla,3 +kuklin,1 +kulacz,3 +kulas,11 +kulbach,2 +kulesza,8 +kulikovsky,4 +kulkarni,1 +kullmann,1 +kulshrestha,2 +kuma,1 +kumaran,1 +kumaranayakam,1 +kumarasamy,2 +kumpus,3 +kunia,1 +kunik,1 +kunoth,10 +kupcs,1 +kuras,2 +kurasiak,1 +kurr,4 +kusel,1 +kushelew,3 +kushnir,2 +kuskie,2 +kusnezow,3 +kustrin,1 +kusuma,2 +kusunoki,2 +kutni,1 +kutschki,2 +kutzmanovic,1 +kuzmicz,1 +kuzmycz,2 +kuzniarski,3 +kvapil,1 +kwesius,1 +kwiatek,3 +kwik,2 +kwoun,1 +kyne,4 +kyprianoy,1 +kypriz,1 +kyratzoulis,3 +kyriacou,48 +kyriakos,1 +kyriakou,2 +la falce,3 +la lande,1 +la palombara,3 +la porte,2 +la rance,2 +la roche,5 +la tone,1 +la-kryz,1 +laanekorb,2 +labarthe,1 +lablack,5 +labrin,2 +labrinadis,1 +laburn,5 +lacanan,1 +lace,8 +lacis,2 +lackner,6 +laczko,1 +ladaniwskyj,3 +lademan,7 +ladgrove,1 +ladiges,1 +ladyman,5 +laferi,1 +laforet,1 +lafsky,2 +lagarde,1 +lagerewskij,6 +laggan,1 +lagrone,1 +lahey,24 +lahska,1 +lahz,3 +laik,1 +lail,2 +lainez,1 +laing,112 +lajos,3 +lakis,1 +lalagaresi,1 +lalusic,5 +lamacka,2 +lambden-stewart,3 +lambert-smith,2 +lamberton,6 +lambertus,1 +lamborn,3 +lamborne,2 +lambrinos,6 +lambropoulos,9 +lambton-young,1 +lamdin,2 +lamkin,7 +lamonaca,2 +lamotte,1 +lamprell,3 +lamprey,74 +lamprill,3 +landau,10 +landauer,2 +landhurr,1 +landini,1 +lando,3 +landon-lane,1 +landone,1 +landow,1 +laney,8 +langer,9 +langi,1 +lango,2 +langrehr,6 +laning,12 +lansbury,1 +lansdell,19 +lansford,1 +lante,6 +lantzke,3 +lanyon,38 +lanzotti,6 +laohaphan,1 +lapic,1 +lapico,1 +lapienis,1 +lapies,2 +lapsley,3 +laraibi,1 +larder,1 +larenas,4 +larg,2 +large,59 +laria,5 +larocca,4 +larrisa,1 +larslen,1 +lasalle,1 +lascala,1 +laskaridis,2 +lass,1 +latchmi,1 +lategui,1 +latella,4 +lath,1 +lather,1 +lathouras,6 +lathouros,3 +latifi,1 +latzer,1 +lauchlan,1 +laucht,2 +laudereau,1 +lauffenburger,1 +laughlan,2 +laundon,4 +laundy,27 +laurendi,4 +lauret,1 +laurier,1 +laurikainen,2 +lauss,2 +lavel,1 +lavender,34 +laverick,7 +laverty,46 +lavigne,3 +lavingdale,1 +lavis,27 +lavokovic,1 +lavrencic,4 +lawsuba,1 +lays,1 +lazaraki,5 +lazare,2 +lazaric,1 +lazaroff,8 +lazauskas,2 +lazir,2 +le bars,1 +le bombte,1 +le cooke,1 +le goy,1 +le grand,6 +le griffon,1 +le guern,1 +le lacheur,3 +le leu,9 +le lievre,18 +le messurier,19 +le mottee,3 +le-che,1 +le-leu,1 +leadbeatter,1 +leaf-milham,2 +leaford,4 +leah,4 +leamy,1 +leane,64 +lease,2 +leatham,4 +leaver,58 +leavold,2 +lebani,1 +leblond,3 +lebretton,1 +lebrique,3 +lechki,1 +lecke,1 +lecky,1 +lederthoug,1 +ledeunff,1 +leditschke,16 +ledsham,2 +ledwell,4 +lee-jones,1 +leembruggen,1 +leesong,6 +leesue,4 +leeuwenburg,3 +leferink,1 +leger,2 +leggio,3 +legzdins,1 +lehane,6 +leicester,16 +leicht,3 +leishman,21 +leissner,1 +leitis,4 +leleika,1 +lelic,1 +lelievre,1 +lember,1 +lemke,12 +lemmer,4 +lemonn,1 +lena,8 +lenart,1 +lenartowicz,7 +leney,1 +lengerink,1 +lennig,1 +lenzi,10 +leon,22 +leonardi,12 +leonardos,5 +leonavicius,4 +leong,56 +leoni,4 +leonid,1 +leppard,15 +lero,3 +leroi,2 +lerwill,1 +les,4 +leschner,1 +lesevre,2 +lesinger,1 +lesiuk,5 +lesiw,1 +lesker,1 +leslie,181 +lesurf,1 +leszczynski,8 +lete,1 +letford,4 +lette,39 +leung,59 +leupi,2 +leveritt,1 +levet,2 +levicki,1 +levykin,1 +lewan,7 +lewincamp,3 +lewis-brown,1 +lewis-shaw,1 +lewkowicz,6 +leybourn,1 +leythamm,1 +liambis,3 +liapis,8 +liar,1 +liaudinskas,2 +liberts,4 +libikas,1 +librandi,24 +licciardello,2 +liccioni,1 +lichacz,1 +licitis,3 +licourinos,1 +liddy,44 +lieben,2 +liebenberg,1 +liepe,1 +liersch,17 +liesegang,1 +lifshack,4 +ligas,5 +lighten,3 +liguoro,3 +lihou,13 +lilee,1 +lill,19 +lillicrap,2 +lillie-hinrichs,1 +lilly,2 +lillycrapp,1 +limbach,1 +limbert,16 +linberg,2 +lindau,2 +lindesay,1 +lindeyer,1 +lindholm,15 +lindorff,1 +lindschau,5 +linedale,2 +lingbeek,3 +linggood,2 +linnell,29 +linssen,5 +linwood,2 +liolios,4 +lionis,7 +lipinski,4 +lipovic,1 +lippett,7 +lipscomb,4 +lipscombe,29 +lipsett,4 +lipton,5 +lira-gonzalez,1 +lisacek,3 +lisiak,6 +lisners,1 +lisowski,2 +lissner,10 +lisy,1 +liteplo,1 +litfin,1 +litten,3 +littge,1 +littlely,7 +littman,3 +liuzzo,1 +lizzi,1 +ljevak,1 +ljostad,2 +ljubic,7 +ljubisic,1 +lloydd-wright,2 +lo-sapio,1 +lobert,2 +lobzin,6 +lock,282 +lodder,5 +lodge,149 +lodiong,2 +lodovici,2 +lodum,1 +loeding,1 +loehr,4 +loggie,2 +logli,2 +logvinski,1 +lohberger,2 +lohe,7 +lohmann,15 +loke,6 +lokusooriya,1 +loli,1 +lolias,1 +lombardi,47 +lomman,70 +lomp,2 +londesborough,1 +londrigan,1 +longden,19 +longhurst,32 +longman,28 +longo,51 +lonie,10 +lontoc,1 +loofs-wissowa,1 +loomes,2 +loong,1 +loos,3 +loosmore,9 +lootens,1 +loprespi,1 +lorraway,1 +losberg,1 +losco,1 +lotswin,1 +lotu,1 +louca,8 +loughrey,1 +loukes,3 +loukopoulos,3 +louloudias,1 +lount,3 +loupos,1 +loutakis,1 +loutsis,1 +loveland,3 +lovelock,54 +loverence,2 +lovi,1 +lowe,574 +lowrence,1 +lowry,82 +lowson,3 +lozoraitis,2 +lu-bow,1 +lu-dizon,1 +lubawy,3 +lubbe,4 +lubulwa,2 +lucadou wells,2 +lucas-perring,2 +luchetti,3 +luchko,1 +luckens,5 +luckman,17 +lucock,4 +lucyk,1 +luddy,2 +ludeke,4 +ludgate,17 +ludowici,1 +ludski,1 +ludzioweit,2 +luglaetti,1 +lugsden,2 +luher,1 +lukasiewicz,1 +lukaszewacz,1 +lukehurst,5 +lukeman,8 +lukomski,1 +lukomskyj,1 +lukosius,5 +lukunic,1 +lumabas,1 +lumbars,1 +lume,2 +lund,38 +lungershausen,2 +lungwitz,1 +lunter,1 +lupoi,10 +lupone,1 +lusambili,2 +lusted,12 +luteria,1 +luters,1 +luthra,2 +lutz,30 +luvisi,1 +luyendyk,1 +luzecki,3 +lvarga,1 +lyddon,4 +lyden,20 +lydon,7 +lygtenberg,1 +lyllywhite,1 +lymberis,5 +lynema,3 +lyntch,1 +lynton-moll,1 +ma,40 +ma'ake,1 +maasepp,1 +maax,1 +maberley,1 +mabokmarial,1 +mac an,1 +mac crosty,3 +mac donell,4 +mac gennhan,1 +mac ginley,1 +mac h,4 +mac halski,1 +mac hentsew,1 +mac kell,3 +mac kinder,4 +mac knight,2 +mac krow,2 +mac leavy,1 +mac neal,1 +mac neill,6 +mac onochie,2 +mac partland,1 +mac quarrie,1 +mac ura,1 +macarlino,3 +maccann,1 +maccrum,1 +macgowan,32 +macha,1 +mackinlay,10 +mackowiack,1 +maclaine,17 +maclel,1 +maclennan,12 +maclucas,5 +macphail,4 +macraild,1 +maczkowiack,38 +madadi,1 +maddecks,1 +maddon,2 +madeira,1 +madera,2 +madge,6 +madhaven nair,1 +madigan,73 +maetze,4 +mafopust,1 +mafra,1 +magaletta,2 +maganga,1 +magaton,1 +magaw,1 +magazin,4 +mager,3 +magerl,2 +magnusdottir,1 +magripilis,3 +mahaffey,3 +mahajani,1 +mahamoud,2 +mahim,1 +mahmoud,4 +mahmud,2 +mahomed-gleeson,1 +mahon,38 +mahony,61 +maida,2 +maier,32 +maihua,1 +mailo,1 +mainero,2 +maingay,3 +maingot,2 +mainprize,3 +mainsbridge,8 +mainwood,1 +maitianos,5 +maizen,2 +majchrowska,1 +majdak,2 +majdandzic,1 +majetic,4 +majid,3 +majidi,1 +makarouchkine,1 +makedonez,1 +makina,1 +makkonen,2 +makovetsky,2 +makropoulos,1 +maksim,2 +malabar,1 +malack,1 +malala,1 +malbasic,3 +malbon,3 +malcholm,3 +malcolmson,1 +malcos,1 +maleganeas,2 +malesic,1 +maleszka,1 +malev,1 +malibiran,1 +maliel,1 +malin,21 +malinauskas,2 +malingre,1 +maliphongs,1 +maliyasena,1 +maljik,2 +malkoun,1 +malladi,1 +malliff,1 +mallion,1 +malloch,2 +malloney,2 +malor,2 +malpas,15 +maltman,3 +malvern,1 +malvestuto,1 +malzard,6 +mamac,1 +mamarika,8 +mamczak,1 +manalac,1 +mancic,1 +manconi,1 +mandica,6 +mandry,1 +mandusic,1 +manfield,32 +manfong,3 +mangafas,1 +mangels,2 +manger,3 +mangini,3 +manias,5 +manicastri,1 +maniotto,1 +manisty,1 +manita,1 +manivone,1 +mankowski,1 +mannern,1 +manock,3 +manos,13 +manousos,2 +mansford,2 +manskey,5 +manson,82 +mansoori,2 +manteit,1 +mantel,3 +manthongsy,2 +manthorpe,18 +mantovan,2 +mantovano,3 +manyem,1 +manzie,5 +mao,11 +mapham,4 +mappas,1 +mapstone,2 +mar fan,1 +marado,1 +marampon,1 +marc,1 +marcaros,2 +marceau,3 +marceta,2 +marchenko,1 +marchetto,2 +marchiori,1 +marcic,2 +marcola,1 +marczuk,2 +margles,1 +margrie,7 +margriso,1 +margush,4 +mariager,2 +marilyn,1 +marin-ulloa,1 +marina,2 +marine,1 +mariner-schrenk,1 +marinos,19 +marjoribanks,4 +markakis,2 +markellos,5 +markijevic,1 +marklew,1 +markotany,7 +markoulli,2 +markov,7 +markowski,14 +markulic,1 +marlow,40 +marous,4 +marousakis,1 +marovich,1 +marpaung,1 +marrable,3 +marring,1 +marris,11 +marroncelli,2 +marsella,2 +marshal,5 +marshell,3 +marshman,48 +marsom,1 +marson,14 +marson-pidgeon,1 +martello,2 +martin-jard,1 +martinello,9 +martinic,1 +martinovic,9 +martinson,7 +martlow,3 +marveggio,2 +marvell,3 +marwaha,1 +marzec,5 +marzilli,2 +masciantonio,2 +masen,2 +mashberg,1 +masiello,1 +masitto,1 +maskiell,3 +maslac,1 +maslich,1 +masnicki,1 +masolatti,2 +mason,790 +mason-foweraker,1 +massara,1 +massoumi,1 +mastantuono,3 +mastin-smith,2 +mastins,1 +mastripolito,1 +mastrippolito,1 +mastroieni,2 +mastrosavas,4 +mataj,1 +mate,6 +mateos,2 +matern,2 +mathason,2 +mathe,6 +matias,3 +matisz,1 +matoga,4 +matson,49 +matthews,1029 +matthiessen,6 +matuschik,1 +matzka,1 +maureen,1 +mauric,3 +mavity,1 +mavrangelos,3 +mavrogenes,1 +mavromihalis,2 +mawlai,2 +mayer,52 +mayling,1 +mayman,9 +maymuru,3 +maynard,232 +maytisathit,1 +maytum,1 +mazek,1 +maziakowski,2 +mazionis,1 +mazitelli,1 +mazurek,10 +mazurkiewicz,7 +mazzocchetti,2 +mazzon,1 +mazzone,47 +mcahon,1 +mcallion,1 +mcandrew,13 +mcanna,2 +mcard,2 +mcaulisse,1 +mcauslan,4 +mcbryde,14 +mccaffrey,19 +mccagh,1 +mccalman,3 +mccalum,1 +mccambley,1 +mccandlish,1 +mccarter,7 +mccarthy,620 +mccaskil,1 +mccausland,12 +mcclare,3 +mcclarty,4 +mcclatchy,1 +mcclay,8 +mcclelan,1 +mcclelland,52 +mccloskey,6 +mccol,1 +mccollam,3 +mccolough,1 +mccombe,7 +mccombes,1 +mccomiskie,1 +mcconnal,1 +mcconnel,4 +mcconvell,1 +mccosker,6 +mccourtie,4 +mccowat,5 +mccracken,43 +mccrohan,4 +mccrum,3 +mccully,6 +mccurdy,9 +mcdaid,3 +mcdermid,18 +mcdermitt,1 +mcdonnell-davis,1 +mcduffie,2 +mcelhinney,8 +mcelwee,26 +mcentyre,1 +mcfadden,32 +mcfeeters,8 +mcgahey,9 +mcgain,1 +mcgargil,1 +mcgarrigan,13 +mcgarty,2 +mcgilchrist,4 +mcginity,4 +mcgirr,8 +mcglinn,7 +mcgrechan,1 +mcgregor,277 +mcguren,1 +mcgurk,18 +mchenry,36 +mchughes,4 +mchutchinson,1 +mcilvain,1 +mcilvar,5 +mcilvride,1 +mcinerney-smith,1 +mcinnes-shelley,1 +mcjannett,6 +mckaig,2 +mckane,9 +mckanna,1 +mckearney,2 +mckerlie,37 +mckiernan,8 +mckimm,1 +mckinnell,23 +mckirdy,5 +mckitrick,1 +mckone,9 +mckoy,1 +mclachlam,1 +mclafferty,6 +mclaine,12 +mclaren-gates,1 +mclarty,5 +mclelland,11 +mclennan-heigl,1 +mclochlan,1 +mcloed,1 +mcmahan,1 +mcmanaway,1 +mcmasters,1 +mcmellon,7 +mcmullen,53 +mcmurdo,8 +mcneeley,2 +mcneill,106 +mcnicholl,10 +mcnidholl,1 +mcpeace,1 +mcphail,49 +mcpharline,1 +mcphie,15 +mcqualtei,1 +mcsheffrey,2 +mcsorley,7 +mcsporran,8 +mcstay,1 +mcsweyn,3 +mctague,1 +mctier,4 +mcturk,7 +mcveigh,16 +mcvey,13 +mcvicar,28 +mcvilly,27 +mcwhirter-whitlock,1 +mdonald,1 +meaby,1 +meachan,3 +meacher,1 +meacle,1 +meadows,40 +meager,2 +meale,8 +meaney,101 +meares,11 +mearns,8 +mech,2 +medaris,1 +medcof,1 +meddings-blaskett,3 +mediratta,1 +mednis,4 +medved,5 +medwig,1 +meeking,5 +mees,5 +meffre,1 +megic,1 +megovimovic,1 +megram,1 +meidl,1 +meijs,1 +meinecke,2 +meinhold,4 +meisel-dennis,1 +meixner,9 +mekler,1 +melandri,1 +melendez,2 +melenzed,1 +melhado,1 +melham,2 +melin,4 +melissourgos,2 +mellas,5 +mellick,6 +mells,3 +mellsop,1 +melzner,4 +memeniman,1 +memovic,1 +menache,1 +menard,2 +mendrin,5 +menetrey,1 +menghini,1 +menke,2 +menken,1 +menpes,2 +menssen,1 +mentasti,2 +menteith,1 +mentis,2 +menzies,107 +mepstead,2 +mercae,1 +merckenschlager,2 +mercorella,48 +mercovich,2 +merenda,9 +merghani,1 +merkoureas,1 +mermer,1 +mernitz,2 +merola,4 +merryfull,1 +mertes,1 +mertheringham,1 +mesecke,41 +mesidis,1 +mesiti,1 +mesnill,1 +messinese,1 +mestrov,3 +metaxiotis,1 +metherall,1 +metherell,6 +meucci,1 +meuli,1 +meulink,1 +meuris,7 +mew,14 +mewett,43 +mewha,1 +mexon,2 +mexted,3 +meyhandan,1 +meyler,1 +mezhvinsky,4 +mezic,4 +mezzomo,2 +mguyen,1 +miar,1 +miari,2 +miatt,2 +micairan,2 +micek,2 +michail,6 +michailou,1 +michalatos,1 +michalek,14 +michaux,5 +michelmore,56 +michielan,5 +michopoulos,1 +micke,4 +mickelsen,1 +micola-von-furstenre,1 +middlebrook,4 +middlehuis,1 +middlemis,1 +middlin,4 +miell,11 +miels,44 +mierisch,6 +miezitis,5 +mihailevs,1 +mihajlovac,1 +mihal,6 +mihalenko,1 +mihart,1 +mihaylov,2 +mihelcic,2 +miholos,1 +mijatovic,3 +mikajewski,3 +mikas,1 +mikeska,1 +miki,1 +milburn,64 +milcs,2 +mildren,52 +miles,303 +milevoj,1 +miliano,3 +milisavljevic,1 +milkins,8 +millane,7 +millanta,1 +millar,262 +millemaci,1 +miloloza,2 +milosevski,2 +milota,2 +milovancev,2 +milter,3 +milway,2 +milwright,1 +milycha,1 +minards,5 +mincher,4 +minchin-king,1 +minchinton,3 +mineely,1 +minero,1 +minh,4 +minner,1 +minnican,2 +minniecon,2 +minnock,1 +minol,3 +minorchio,3 +minter,9 +minther,2 +minto,6 +miocevich,1 +miotto,6 +mir,2 +miranda-veloso,1 +miraneu,1 +mirkovic,2 +mirritjawuy,1 +misagh,1 +mislov,12 +misner,3 +misopopas,1 +misrachi,3 +missaridis,1 +mitakidis,1 +mitchel,3 +mitchell-collins,3 +miteff,7 +miteloudis,2 +miteva,1 +mitigas,1 +mitric,4 +mitsotoulos,1 +mitsoulis,2 +mittelstadt,1 +mitton,54 +mixon,1 +mizerski,2 +mizielinski,1 +mizon,5 +mizuno,1 +mkandala,1 +mo,5 +mobers,1 +moble,1 +moder,2 +modystach,12 +moegreen,2 +moerkerke,1 +moerland,3 +moerman,5 +mogavero,2 +mohammadi,1 +mohammod,1 +mohring,3 +moine,1 +mokros,1 +moldavtsev,1 +moldehn,2 +molemoeng,1 +molineaux,2 +molkenthien,1 +mollaj,1 +molland,3 +mollard,2 +mollart,2 +mollross,11 +moltow,1 +molyneaux,1 +momcilovic,3 +monaco,13 +monaghann,1 +monasterio,1 +monba,1 +monda,5 +money,7 +monis,6 +monjean,9 +monola,3 +monotti,1 +monshizada,1 +monssen,1 +montalvan,1 +montalvo,3 +montandon,1 +monteleone,33 +montfort,2 +montfrooy,3 +montgomery-quin,1 +montroy,4 +montuori,4 +montz,1 +monz,1 +moody,152 +moog,2 +moolenaar,2 +moorby,12 +moorcock,1 +moore-crouch,1 +mor,2 +morata-plaza,1 +morato,2 +morby,3 +morcom,61 +morden,6 +mordeniz,2 +morecroft,6 +moreira,1 +morell,4 +moren,2 +morganti,2 +morio,1 +morioka,1 +morissey,1 +mormina,1 +morra,1 +morrish,21 +morrison,614 +mort,11 +morter-grant,1 +mortiner,1 +mortlock,26 +morton-jones,1 +moscarda,2 +moscatt,7 +mosheev,2 +moshos,4 +mosk,1 +moskwa,5 +mosman,3 +mosmondor,1 +mossman,6 +mosti,1 +mostris,2 +mostyn-smith,1 +motbey,8 +motyka,1 +moua,1 +moubarak,7 +moucho,1 +mouglbay,1 +moujalli,1 +moulton,23 +moun,3 +mounce,7 +mounzer,3 +mourtaroglou,1 +mousellis,3 +mouser,2 +moustos,3 +moutsatsos,3 +moutsokapas,1 +movall,1 +mowling,1 +moyse,36 +mposu,1 +mrosek,1 +mrozinski,1 +mrvelj,2 +msapenda,1 +muallem,1 +mucolloch,1 +mudaliar,6 +muder,1 +muehlberg,3 +mueller-dyer,1 +muenchow,5 +mugo,1 +muhanna,1 +muhldorff,3 +muhsam,2 +muir-cochrane,1 +mujmanovac,1 +mukans,2 +mukavec,1 +mulcare,1 +mulconray,2 +mulgan,1 +mullavey,4 +mullin,24 +mullner,5 +mulquiney,4 +mulree,1 +multa,1 +mulvey,6 +mulvie,2 +mulville,1 +munam,1 +munford,6 +munforti,2 +muniswamappa,1 +munuggur,1 +munyarryun,4 +muongsene,1 +mur,3 +murabito,4 +muraya,1 +murphy-dorsett,1 +murry,7 +murtha,3 +murton,41 +musca,1 +muschamp,2 +muskee,6 +musolino,116 +musovic,1 +mussell,1 +mustac,3 +musto,2 +musumeci,2 +mutavcic,1 +muthukuda,5 +mutikainen,1 +mycko,3 +mydlak,3 +mykyta,3 +myles,46 +mylne,2 +myriti,2 +mysko,7 +naar-cafentas,1 +nabi,2 +nabialek,3 +naborlh borlh,1 +nachazel,1 +nadels,5 +nadin,2 +nadolny,2 +naegler,1 +naess,1 +nagaria,1 +nahalewicz,1 +naidu naidu,1 +najm,2 +nakahara,2 +nakone,4 +nalecz,1 +nalpantidis,6 +nammensna,1 +nampjnpa,1 +namundja,2 +nand,4 +nannini,2 +nanos,2 +nanuan,1 +naoum,3 +naoun,1 +napora,2 +nappo,1 +narayana,3 +narinder,1 +narracott,9 +narulla,1 +nascivera,2 +nass,1 +nassaris,2 +nassau,3 +nastopoulos,1 +natsiopoulos,2 +naum,1 +naumoska,4 +navalli,1 +navarro,13 +navatu,1 +naveda,1 +nayilibidj,1 +nazzocchitti,1 +ndambuki,1 +neadle,1 +neailey,2 +neander,8 +nearhos,1 +nebl,1 +nedaie,1 +nedcraft,1 +nederpel,3 +neeb,3 +needham,53 +neelagama,1 +neeland,1 +neff,2 +nefiodovas,3 +negash,1 +negent,1 +negerman,2 +negnevitski,1 +negrean,1 +negri,10 +negrin,3 +neighan,1 +neik,1 +neill-fraser,1 +neimoeller,1 +neitzel,1 +nekar,1 +nekoee,1 +nel,4 +nelmes,7 +nelsen,17 +nelson-field,1 +nemec,8 +neol,1 +neophyton,1 +nerlekar,1 +nesgos,1 +nesham,3 +nesich,1 +netherton,12 +netteefold,1 +nettlefood,1 +nettleford,1 +neuendorf,5 +neufeld,1 +neufing,1 +neumann,114 +nevard,1 +neveceral,1 +neville,148 +nevin,21 +nevis,2 +nevjestic,1 +newberry,23 +newbould,6 +newbound,15 +newbown,3 +newel,1 +newey,12 +newns,3 +newport,29 +newton-howieson,1 +newton-smith,1 +newton-tabrett,4 +neyens,1 +neyle,1 +neylon,14 +ngadi,1 +ngai,10 +ngei,1 +nguyen,974 +nguyen-do,1 +nguyen-humphrey,1 +nicely,1 +nicker,1 +nickerson,1 +nicklason,18 +nickolai,26 +nicolaides,3 +nicolakopoulos,1 +nicoletti,3 +nicoll,29 +nicolle,77 +nicoloulias,3 +niddrie,6 +niebling,1 +niederkofler,1 +niekel,3 +niemietz,1 +nieminski,1 +nieuwendyk,2 +nieva,4 +nijhawan,1 +nika,1 +nikakis,1 +nikiforova,1 +nikkerud,3 +niklaus,4 +nikolai,4 +nikolec,1 +nikolenko,1 +nikolich,1 +nilssen,2 +nimmett,1 +nimnualsan,2 +nimpis,1 +ninchich,1 +ning,6 +nirrpuranydji,1 +nirta,8 +nishizana,1 +nite,1 +nitereka,1 +nitsolas,1 +niznik,2 +nizynski,3 +no,1 +noack,83 +nobay,1 +noble,452 +nocella,1 +nofi,2 +nogueria,1 +nohdnoor,1 +noisier,1 +nojima,1 +non,1 +nonas,4 +nong,2 +norday,1 +nording,1 +norgate,5 +normandale,6 +normanington,1 +norrison,1 +northway,14 +norton-baker,6 +norvill,4 +noslanta,1 +notarianne,1 +noter,1 +nou,5 +nourath,1 +nouruzi,1 +novacek,2 +novak,50 +novick,1 +novis,2 +novitski,1 +novotny,2 +nowaczyk,1 +nowakowska,1 +nowers,1 +nowickys,1 +nowlan,5 +noyce,29 +noyen,3 +nozhat,1 +nozoma,1 +nozza,2 +nuan,1 +nubel,1 +nudl,2 +nuebauer,1 +nuh,2 +numina,1 +nun-belton,1 +nunggumajbarr,1 +nunthalath,1 +nunzio,1 +nurse,16 +nurwahyudi,1 +nutter,5 +nutton,1 +nuttycombe,1 +nuwandjali,1 +nyakuengama,1 +nye,20 +nyeng,1 +nygaard,4 +nyiro,2 +nykamp,4 +nylander,2 +nysten,4 +nyunt,2 +o'casey,1 +o'connel,1 +o'day,10 +o'farell,1 +o'flynn,5 +o'garey,8 +o'goerk,1 +o'hea,2 +o'kronk,1 +o'malveney,1 +o'neall,3 +o'nieil,1 +o'range,1 +o'shannessy,19 +oake,5 +oaks,5 +oatey,10 +oats,54 +obajdin,1 +ober,2 +oberdorf,3 +oberfichtner,1 +obersteller,2 +obkircher,1 +obod,4 +obringer,1 +obsivac,2 +occleshaw,2 +ochernal,1 +ockwell,1 +oclee,1 +oddy,8 +odfeldt,1 +odontiadis,2 +oest,4 +offoin,1 +ofrecio,1 +ogareff,2 +ogborn,1 +ogi,1 +oglanby,2 +oglivy,1 +ogston,4 +ohlin,3 +ohsson,1 +ohurra,1 +oi,1 +okely,7 +okita,1 +okla,1 +okolski,1 +okoniewski,3 +okubo,1 +okulewicz,2 +ola,3 +olbrei,1 +olechwicz,1 +oleksinski,1 +olender,1 +oleszcuk,1 +oliphamt,1 +olivares,1 +oliveri,4 +ollett,3 +ollis,2 +ollivier,4 +ollwitz,4 +olveczka,1 +omari,2 +omay,1 +ongkiko,1 +ongley,17 +onklundee,1 +onorato,4 +onus,2 +oo,6 +oolgaard-snijder,1 +opbroek,4 +opitz-bockmann,1 +opsima,1 +orban,2 +orbons,3 +orchard,79 +orchid,1 +ordasi,1 +ordogh,2 +orefice,2 +oreilly,2 +oreskovic,5 +orian,2 +orkney,2 +orledge,1 +orlick,1 +orlovic,6 +orme,18 +oroogi,1 +orouke,1 +orpwood,13 +orr-young,2 +orzelek,1 +osfield,2 +osgerby,1 +osgrove,1 +oshaughnessy,2 +ospapuk,1 +ossadtchouk,1 +osseweijer,1 +osteraas,1 +osterman,3 +ostrovski,1 +ottens,37 +ottery,1 +ottewell,10 +otto-coats,1 +oulsnam,2 +oussatchev,2 +outred,3 +ovanesyan,1 +ovaskainen,1 +ovens,13 +overheu,1 +overington,4 +overman,1 +overmeyer,3 +owerko,3 +oxenbould,1 +oxenbridge,1 +oxley-wakeman,1 +oyevaar,3 +ozdowski,2 +ozhylovski,2 +ozimkowski,1 +ozimo,1 +ozkan,1 +ozog,1 +pacevicius,1 +pacey,19 +pachett,1 +paciorek,1 +packenham,4 +pacor,5 +padas,1 +padbury,3 +paddon,4 +padgham-purich,1 +pados,2 +paduszynski,1 +paepke,1 +paffett,1 +pafumi,1 +pagac,2 +pagden,3 +page-hannaford,1 +pagoda,4 +pahlow,2 +paine,125 +painter,42 +painton,2 +paitaridis,3 +paize,1 +pajer,1 +pajkovski,1 +pajkowski,1 +pajo,1 +pajovic,1 +pak,2 +pakizeh,1 +pakos,2 +pakpoy,1 +pakulis,1 +palachicky,2 +palaktsoglou,2 +palamaris,2 +palasis,2 +palecek,6 +palen,1 +palethorpe,7 +palles,1 +palli,1 +pallot,5 +palmen,2 +palmeri,1 +palumbos,1 +palverso,1 +pamalia,1 +pamnany,3 +pamplin,2 +pampling,2 +panagaris,8 +panagiogivis,1 +panagiotakopolos,1 +panaguiton,1 +panajotovic,1 +pananaki,1 +panchaud,1 +pandouras,1 +panelis,1 +panigiris,1 +panitzki,1 +pannenburg,4 +panquee,1 +pantazopoulos,4 +pantel,1 +pantich,2 +pantos,6 +papacharalambous,1 +papadontas,1 +papageorgiou,37 +papaloukas,1 +papandreou,3 +papanikolopoulos,3 +papanotis,4 +papathomas,3 +papazacharia,1 +papazacharoudakis,2 +papazafiropoulos,3 +paphitis,4 +papij,2 +papoulas,1 +papoutsanis,1 +papoutsis,1 +papp-horvath,1 +paragalli,6 +paraniuk,1 +parashar,1 +parasier,1 +paraskis,1 +pardey,3 +pardy,1 +parer,1 +parfilo,4 +parken,10 +parkitny,3 +parmakli,1 +parodi,3 +parpoulas,1 +parr,88 +parreira,1 +parremore,24 +parsons-lord,1 +partyka,1 +pasalic,7 +pasaricek,1 +pascale,28 +paschalidis,6 +paschalis,2 +pasco,1 +pasco-gilroy,1 +pascoe,208 +pascu,1 +pasieczny,1 +paskins,1 +passalacqua,3 +passari,2 +passell,1 +passera,3 +passmore,41 +passone,2 +pastars,4 +pasternak,2 +pastore,5 +patafta,7 +pateros,3 +paterson,455 +patience,10 +patini,3 +patson,1 +pattichis,1 +pattie,4 +pauch,1 +paukovits,1 +paulit,7 +paulka,3 +paulsen,9 +paulsson,1 +paveley,1 +pavicic,3 +pavin,1 +pavli,8 +pavlick,1 +pavlos,2 +pavlovcic,2 +pawliszyn,1 +pawsey,8 +pazniewski,1 +pcpeake,1 +peacey,1 +peachey,31 +peady,1 +peckett,2 +peddell,1 +peddie,3 +pedersen-jones,1 +pedruco,2 +peeble,1 +peena,1 +pegg,29 +peglidis,3 +pegolo,1 +pegum,1 +pehlivanides,2 +peiker,2 +peitersen,1 +pekarsky,1 +pelchen,1 +pelic,1 +pelikan,2 +pelliccia,2 +pelling,13 +pellos,1 +pelser,1 +pembroke,6 +pemper,2 +penaluna,8 +penberthy,10 +pendergrast,7 +pendes,1 +pendle,10 +pendrill,1 +penelope,3 +pengler,1 +pengryffyn,1 +penhalluriack,1 +penhallurick,1 +penikis,1 +penm,3 +pennell,25 +pennill,3 +penno,28 +pennycuick,6 +penprase,2 +penquitt,1 +penry,1 +penso,1 +penver,1 +peppe,1 +peraic,3 +perdikis,2 +perdriau,1 +perduns,1 +perelaer,1 +pereyra,4 +perfetto,1 +peries,1 +perin,24 +perissini,1 +perl,1 +permyakoff,1 +perner,1 +pernini,3 +peronace,3 +perre,30 +perriam,15 +perroux,1 +perrow,3 +persin,1 +persing,1 +perth,1 +pervical,1 +pesari,1 +pesch,6 +pesec,1 +peshti,1 +pesti,1 +pestka,5 +petchkov,1 +petelski,1 +petersen,191 +petery,1 +pethers,3 +petith,4 +petito,5 +petraschka,1 +petravic,1 +petrian,1 +petricca,1 +petrikas,1 +petrikowski,3 +petrillo,5 +petrinec,1 +petrinolis,1 +petrunic,3 +petruschenko,1 +pettiford,3 +pettigrove,5 +pettingill,31 +pettman-south,1 +pfeffer,4 +pfiefer,1 +phakafy,1 +phanphengdy,2 +phendytsang,1 +phetla,2 +philcox,13 +philipp,2 +philippa,6 +phillbrook,1 +phillpott,3 +philps,23 +phinn,1 +phomson,1 +phoutjanti,1 +piacquadio,4 +pianto,1 +piasecki-jaracz,1 +piazza,8 +piccoli,3 +pichlmann,2 +pichugin,3 +pickel,2 +pickwick,1 +picot,8 +pidcock,4 +piechocki,2 +pieffer,1 +piegza,1 +piening,7 +pieris,1 +pierlot,1 +pieroni,1 +pierri,2 +pierro,1 +piert,1 +pieterek,1 +pietka,1 +pifeas,1 +pighin,3 +pignalosa,4 +piip,2 +pikulic,1 +pikusa,5 +pilan,1 +pilarek,1 +pilavci,1 +piliczky,3 +pilja,3 +pilkinton,7 +pimershofer,1 +pinakas,1 +pindell,1 +pinding,1 +pinheiro,4 +piniros,1 +pinkney,1 +pinnuck,6 +pinny,2 +pinto,15 +pintus,5 +pinzon,3 +piorkowski,1 +pipan,1 +pirnke,1 +pirog,2 +piromanski,1 +piryak,2 +pischettola,1 +pisi,1 +piskavec,1 +piszcyk,2 +pitchon,1 +pitera,1 +pitkethley,2 +pitrans,2 +pitsikas,4 +pitsilidis,1 +pitt-lancaster,1 +pitters,1 +pittock,4 +pittorino,1 +pitzen,1 +pizanias,4 +pizzey,3 +pjevac,3 +pladson,1 +plaetrich,1 +plane,43 +planzano,1 +platteel,1 +players,1 +plaznik,2 +pleeker,1 +plesa,5 +plessnitzer,1 +pleszkun,1 +pleunik,1 +plevin,5 +plews,9 +pleydell,1 +ploegsma,1 +ploesser,1 +ploger,1 +plos,3 +ploughman,14 +plovanic,5 +plumb,31 +plume,6 +plumer,2 +plumley,1 +po chung,1 +pobje,1 +poc,1 +pocaro,1 +pochec,2 +pocklington,1 +poddar,2 +podgorscak,1 +podreka,1 +pogacic,1 +pohrib,1 +pojsl,1 +pokkias,1 +polak,11 +polato,2 +polazer,1 +poliakova,1 +policarpio,1 +polita,1 +poljansek,1 +polles,1 +pollidorou,4 +pollini,3 +polmear,18 +polo,1 +polowy,2 +polsts,1 +pomfret,8 +pomfrett,3 +pondi,1 +pongsupath,1 +ponias,1 +ponomarenko,1 +ponsford,2 +ponter,1 +pontifex,27 +pontt,20 +pooke,2 +poore,7 +pop,3 +popazzi,1 +popelier,2 +popovoc,1 +poppleton,3 +porecki,1 +porizek,1 +porotschnig,3 +porra,2 +porsius,1 +porss,1 +portellos,4 +portlock,24 +portors,7 +porublev,2 +positano,2 +poskey,2 +posloncec,1 +posnakidis,2 +postolovski,1 +pota,2 +potempa,1 +potesky,1 +potoczky,5 +potticary,10 +potuszynski,3 +poulias,1 +pouliotis,2 +poumako,2 +pounder,2 +poupoulas,1 +pour,1 +povel,1 +povey,32 +powderly,4 +powdith,1 +powis,1 +powlay,1 +poyntz,1 +pozdrik,1 +pozium,1 +pozniak,4 +pracy,1 +pradela,3 +pradun,1 +praehofer,1 +praely,1 +praetz,4 +pragasam,1 +pragt,4 +prak,4 +pramudyasmono,1 +pran,1 +prandolini,1 +pratap,5 +pratz,1 +prawoto,1 +predic,1 +preedy,1 +pregarz,2 +prem,1 +premici,1 +preo,3 +preseren,1 +presley,8 +prestia,4 +prestipino,2 +prestly,2 +preston-stanley,3 +presutti,4 +pretreger,1 +preyser,2 +pribac,3 +pribil,1 +price-austin,3 +price-beck,4 +priddin,1 +pride,22 +prideaux,49 +priebe,6 +priesley,2 +priest,160 +primavera,3 +primikyrlidis,1 +primozich,1 +princehorn,1 +princic,1 +pringle,46 +pringle-jones,1 +prmmer,1 +probets,2 +procter,47 +profitlich,1 +prohaska,1 +proks,3 +pronk,6 +prosenica,1 +prosser-cattanach,1 +prostimo,3 +prostin,1 +provan,9 +pruul,1 +pryer,10 +prytula,3 +psaras,2 +psiahos,1 +psorakis,4 +puc,1 +pudovkin luba,1 +puide,1 +pujsza,1 +puksts,1 +pulat,1 +pulford,86 +pulford-clark,1 +pulle,4 +pulvirenti,5 +pun,3 +puolakka,2 +purbell,1 +purdey,11 +purdon,65 +purenins,1 +purich,3 +purkalitis,1 +purma,1 +purseglove,1 +purser,18 +purtell,20 +purus,1 +purvey,1 +puskadija,1 +puspawata,1 +pusser,3 +pustavrh,3 +pusz,3 +puszkar,2 +putans,1 +putrananda,1 +putterill,5 +puttick,1 +puttmer,1 +puttnam,2 +puvan,1 +pwa,1 +pyle,19 +pylypenko,2 +pyper,16 +pyrgos,2 +qail,1 +qua,1 +quack,1 +quagliarella,1 +quan,17 +quast,22 +quatermass,1 +querzoli,2 +quill,28 +quilliam,79 +quilliam-condello,1 +quilty,15 +quinsey,4 +quinteros,1 +quinton,22 +quinzi,9 +quoc,3 +quodling,4 +rabbitt,13 +rabe,20 +raber,1 +rabie,1 +rabski,1 +raccanello,4 +rachid,6 +rachwal,13 +rackemann,1 +rackwell,1 +radespiel,1 +radfed,1 +radic,10 +radinger,3 +radinovic,1 +radjenovich,1 +radmuller,1 +radovic,5 +radulescu,4 +radwell,1 +raethel,12 +rafanelli,17 +raffety,2 +rafii,2 +raftis,1 +raftopoulos,5 +raftovich,1 +rahikainen,1 +raik,1 +raizis,1 +rajapapirana,1 +rajendra,3 +rajkowski,3 +rajopadhyaya,1 +rake,21 +rakesh,1 +ralf,1 +ralston-bryce,1 +ramachandra,3 +ramamoordhy,1 +ramasundara,1 +ramavani,1 +rambow,1 +ramey,1 +ramfos,1 +ramiro,2 +ramly,1 +ramona,1 +ramush,1 +rana,12 +randall-smith,1 +raner,2 +ranjan,2 +rankin-hooper,1 +rankine,98 +rannie,1 +ranson,71 +rapisarda,7 +rapko,3 +rapson,12 +rashley,2 +rasic,7 +rasman,1 +rastar,1 +rasti,1 +ratledge,1 +ratneser,1 +ratsourinh,1 +rattaey,1 +rattur,2 +ratycz,1 +rau,35 +rauch,4 +rauseo,6 +ravek,1 +ravenwood,2 +ravlich,2 +ravnoy,2 +raward,5 +rawle,2 +rawlings,161 +raylene,1 +raymundo,1 +rayski,1 +rayton,1 +razborsek,3 +razon,2 +reaburn,5 +readshow,2 +realubit,1 +rebmann,1 +reckmann,1 +recknell,1 +record,8 +red,1 +reddacliff,1 +redington,4 +redmond,30 +reduch,2 +redzepagic,1 +reece,65 +reed-gilbert,1 +reeh,4 +rees,280 +rees-curwen,1 +reetz,1 +regal,1 +regalado,1 +regej,1 +rehlaender,2 +rehr,1 +reibel,5 +reichardt,3 +reid,1203 +reifferscheidt,2 +reimer,7 +reimers,17 +reinbach,1 +reinhard,5 +reinmuth,14 +reischl,1 +reitler,2 +rekkas,4 +reller,1 +rellos,1 +relota,1 +rembowski,1 +remmington,1 +rendel,1 +render,2 +rendulic,4 +renfrey,71 +reni,5 +rentuza,1 +res,8 +reschke-hockley,1 +resili,2 +restell,3 +reszitnyk,2 +retledge,1 +reuter,26 +revi,3 +revie,4 +rexeis,3 +rezaee,1 +rezaeian,1 +rezaie,1 +rhyne,6 +rial,2 +riardon,1 +ribeiro,7 +ricard,1 +richardon,2 +richie,1 +richmond,112 +rickett,15 +riddei,2 +riddell,48 +riddick,3 +riddoch,13 +rider,23 +riding,19 +riding-williams,1 +ridley-gaze,1 +riebke,8 +riede,7 +riehtering,1 +rielly,8 +rieman,2 +ries,4 +riesner,1 +riezzo,1 +rigby-meths,1 +rigbye,1 +rigley,9 +riglin,1 +rika,1 +rilk,1 +rilley,1 +rimanic,3 +rimsky-korsakov,2 +ringe,1 +ringi,1 +ringland,7 +rinne,2 +rintel,1 +rinymalpuy,1 +rippingille,1 +risa,1 +risbley,1 +ritz,2 +ritzau,5 +ritzberger,1 +ritzkowski,1 +riva,1 +rivadera,1 +rivas,3 +rivaz,1 +rivera,17 +rivers,54 +rizovslu,1 +rizzo,11 +rizzon,1 +roan,2 +roberti,2 +roberts-duffy,1 +roberts-yates,2 +robeson,3 +robison,7 +roblom,1 +robnik,5 +robson,230 +rocca,48 +roccatti,3 +rocha,6 +roche,67 +rocher,3 +rochette,1 +rockcliffe,1 +rockmann,2 +rodaro,2 +roddick,2 +rodney-hanson,1 +rodopoulos,1 +rodriguz,1 +roebuck,19 +roehrich,1 +roelsma,1 +roemisch,1 +roepcke,4 +roets,1 +roex,2 +roff,8 +rogan,20 +rogers-barnden,1 +rohleder,2 +rohrle,1 +rohyaei,1 +roker,1 +rokobaro,1 +rola-wojciechowski,1 +rolan,2 +roles,29 +roling,9 +rolins,2 +rolke,2 +rollands,1 +rollas,2 +roller,7 +rolleston,3 +rollins,60 +rollitt,2 +rologas,4 +rom,1 +roman,9 +romanenko,1 +romanski,1 +romeyn,3 +romkes,2 +ronai,5 +ronan,27 +ronzano,2 +rook,12 +roosli,1 +roppola,3 +rosa,36 +rosada,2 +rosadoni,1 +rosandic,1 +rosano,1 +rosato,4 +rosborough,3 +roschert,1 +roseboom,1 +rosecky,2 +roselli,5 +roseman,1 +rosendale,16 +ross-masters,1 +rossato,3 +rossler,7 +rossomando,1 +rossow,2 +rota,2 +rothe,62 +rotman,8 +rotsey,1 +rotumah,4 +roud,1 +rouhliadeff,3 +roundhill,4 +rounds,1 +rounis,1 +rounsevull,1 +roush,1 +roussianos,1 +roussounis,1 +rovelli,2 +rovira,3 +rovis-hermann,1 +rowan-kelly,1 +rowle,2 +roxburgh,12 +roy-gapper,1 +royans,12 +royle,35 +rozak,1 +rozas,1 +rozerio,1 +rubaszewski,1 +rubendra,1 +rubner,1 +rucci,2 +rudd,98 +rudgley,2 +rudkiewicz,1 +rudzki,2 +ruffy,6 +ruhfus,1 +ruise,1 +rulfs,2 +rumbal,3 +rumbalu,2 +rummuckainen,1 +rump,7 +rumpe,1 +rundle,149 +rungis,1 +runic,3 +runis,1 +runnegar,3 +ruolle-ivanov,1 +rupenovic,1 +rupinskas,1 +rupp,1 +rusack,6 +rushby,11 +rushforth,5 +ruskin,10 +rusling,6 +ruso,1 +russin,3 +rustam,3 +rusu,1 +rutkiewicz,5 +rutkowska,2 +rutte,5 +ruutel,1 +ruwette,1 +ryan,1321 +ryanbakken,1 +rybak,7 +rybarczyk,3 +rybovic,1 +ryker,1 +rylands,10 +rylie,2 +rynhart,1 +ryprych,1 +rysdale,1 +rzesnicki,1 +rzeznik,2 +saade,3 +saar,4 +sabben,1 +sabbith,1 +sabetzad,1 +sabieray,1 +sabila,1 +sabotoc,1 +saccardo,16 +sacchetti,3 +sach,11 +sachsse,1 +sadauskas,7 +sadler-dadge,1 +sadlewski,1 +saengmany,1 +saenz,2 +safai,1 +saffoury,1 +safra,1 +safrazian,3 +sagadewa,1 +sager,11 +sagir,1 +sagrestano,3 +sagrillo,1 +sagucio,1 +sailing,1 +sailsbury,1 +saines,3 +saj-rynes,1 +sakatunoff,2 +salapatis,1 +salas,5 +salcedo,8 +salehi,1 +sallay,1 +salmi,1 +salsbury,1 +salt,53 +salthouse,1 +saltiel,1 +saltiel-mosley,1 +samakovlis,1 +samara-wickrama,1 +samarajeewa,2 +samarelli,2 +samarinoff,1 +samarzia,3 +sambanis,1 +samcewicz,2 +samedani,2 +sami arun,1 +samios,7 +samplton,1 +samprathi,1 +samulewicz,1 +samuniuk,2 +sanakidis,1 +sanby,1 +sandallis,1 +sandham,1 +sandiford,3 +sandifort,1 +sandler,2 +sandman,11 +sandyford,1 +sangfai,1 +sanghera,1 +sangi,1 +sanmugam,1 +sanny,1 +santangelo,1 +santelices,2 +santi,13 +sapa,2 +sapage,1 +saputar,1 +sar,2 +saragas,1 +sarah,16 +saran,1 +sarantopoulos,2 +sarantou,1 +sarfati,1 +sariago,6 +saridakis,2 +sarioglou,2 +sarjeant,2 +sarkissian,1 +sarny,2 +sarnyai,1 +sarossy,5 +sarrant,1 +satay,1 +sathis,1 +satomi,1 +satterley,22 +satterthwaite,4 +sau,3 +saul,16 +saumi,2 +saunders'wise,1 +saunders-sexton,1 +sauzier,2 +savary,1 +savas,9 +saveljevs,1 +savidge,2 +savino,1 +savio,3 +saviska,1 +savutakis,1 +sawbridgeworth,1 +sawczak,3 +sax,10 +saxon-taylor,1 +sayagha,1 +saylor,2 +sayzeff,1 +sazaklidis,1 +sbirakos,1 +sbona,2 +sbordone,1 +scacchitti,2 +scaglia,1 +scalamera,1 +scambler,3 +scamoni,12 +scanlain,1 +scannell,16 +scantlebury,3 +scappatura,4 +scarabotti,4 +scarce,31 +scargill,3 +scarlat,1 +scarles,1 +scassa,2 +scattini,7 +scaturchio,4 +scerri,24 +schaber,4 +schadow,2 +schaedler,1 +schaffarz,2 +schaller,2 +schamschurin,3 +scharling,1 +scharner,4 +schatto,2 +scheckenbach,3 +scheel,3 +scheepens,5 +scheerlinck,2 +scheffel,2 +schekira,1 +schelkis,2 +schelz,1 +schembri,34 +scheper,1 +schepers,1 +scheppers,1 +scherf,1 +scheringer,2 +schiansky,11 +schiemer,2 +schillier,1 +schimleck,2 +schindelhauer,1 +schipani,2 +schjolden,1 +schleider,1 +schleigh,1 +schlezak,2 +schmalscheidt,2 +schmeling,1 +schmelter,1 +schmick,1 +schmitzer,7 +schmocker,3 +schmook,1 +schnackenberg,1 +schnider,1 +schnieder,2 +schnitzerling,1 +schoder,7 +schoebinger,3 +schoenberg,6 +schoettke,3 +scholberg,1 +scholte,2 +schoonwater,1 +schopman,1 +schoppe,3 +schorr,2 +schorta,1 +schottminn,1 +schrepel,1 +schriber,1 +schuddebeurs,1 +schuermann,1 +schuetz,7 +schuh,2 +schultheis,2 +schumann,52 +schupann,1 +schuptar,3 +schuster,68 +schwaz,1 +schwetlik,3 +schwidder,5 +schwinghammer,5 +scime,1 +scollard,7 +scopel,1 +scott-jackson,4 +scotton,1 +scougall,10 +scowcroft,1 +scrbak,2 +scrimgeour,9 +scripps,3 +scriva,3 +scrivanich de ivanov,1 +scrivenor,1 +scudds,11 +sczensny,1 +se,1 +seare,1 +sebastyan,2 +sebregts,2 +secara,2 +sechner,1 +seckar,1 +secomb,41 +secondis,1 +seddon,52 +sedecki,2 +sedelbauer,1 +sederstrom,2 +sedgley,7 +sedgwick,9 +sedoriw,1 +sedunary,25 +seehusen,1 +seelt,1 +seen,37 +seetoh,2 +seevaratnam,1 +seevers,2 +seewraj,1 +segar,2 +segneri,4 +sehneider,1 +sehwarze,1 +seib,9 +seibold,1 +seigneur,2 +seis,1 +seiver,1 +sek-sekalski,2 +sekaran,2 +sekavs,2 +sekhon,3 +sekuless,3 +sekulitch,4 +selamis,1 +seleke,2 +selkirk,6 +sellmann,4 +sells,7 +selth,18 +selvaraj,1 +selvarajan,1 +sembrano,2 +sena,1 +senaka'arachi,1 +senarth,1 +senator,1 +sendoner,1 +senech,1 +seneque,1 +senese,1 +senesi,12 +seng,6 +sengpiel,2 +senic,2 +sennar,3 +sennef,1 +senner,2 +senti,4 +seo,3 +sepiol,1 +sepp,2 +seppelt,21 +seppelt-deakin,1 +serafin,18 +seraglia,1 +serem,1 +sergio,1 +serrels,2 +sertvytis,1 +seselja,13 +seskis,3 +sessle,1 +sethna,1 +setlhong,1 +seto,9 +setright,1 +sette,10 +settembri,1 +sevel,1 +severan,1 +sevi,4 +sevtsenko,1 +sewart,4 +seychell,9 +seyfarth,1 +seymor,1 +seymour-griffin,1 +seymour-walsh,1 +sezun,1 +sferco,4 +sgroi,2 +shack,2 +shadbolt,51 +shady,4 +shaft,1 +shahidimehr,2 +shahnza,1 +shailer,3 +shair,1 +shambrook,5 +shandley,4 +shanis,1 +shank,2 +shapiro,2 +sharkie,1 +sharon,5 +sharpless,1 +shawforth,1 +sheaffer,1 +sheehan-harradine,1 +sheeky,3 +sheens,1 +shehzat,1 +sheldon,46 +shelley,52 +shellshear,1 +shelly,8 +shelvock,3 +shem,1 +shendi,1 +shenman,1 +shepherd,426 +shepherdson,58 +sheremetjev,3 +shereston,2 +sherin,3 +sheringham,1 +sherren,2 +sherriff,167 +sherrington,10 +shevchenko,9 +shevtzoff,1 +shew,1 +shih,5 +shillinton,1 +shilova,1 +shimpf,1 +shinerock,1 +shinnick,15 +shipperd,1 +shirin,1 +shirmer,1 +shirodkar,2 +shiun,1 +shivarev,1 +shivas,4 +shneider,1 +shoben,2 +shoebridge,7 +shoeman,1 +shopen,1 +shorrock,15 +shortman,3 +shorts,1 +shoubridge,3 +shove,1 +shrowder,5 +shuk,1 +shurville,2 +shutlar,2 +shying,2 +siaban-oglou,1 +siaosi,1 +siapantos,1 +siatis,1 +sibbald,2 +sibbritt,2 +sickles,3 +siddans,2 +sideris,10 +sidlauskas,1 +sidlo,2 +sidman,2 +sidney,6 +sieber,8 +siek,2 +siemens,4 +siemers,6 +siemon,3 +sierakowski,1 +sietz,1 +siew,5 +sifkus,2 +sigamoney,1 +siganto,5 +siggins,30 +signorelli,3 +sijacic,1 +sikansari,1 +silcocks,1 +silland,1 +siller,1 +silo,2 +silson,4 +silverton,2 +silvestrino,3 +silvestro,4 +sim-collett,1 +sima,3 +simac,1 +simitsis,2 +simlat,2 +simmonds,127 +simonetti,10 +simonn,1 +simonuik,1 +sincovich,3 +sindicic,2 +sindorff,3 +singhakian,1 +singleton,83 +sinicins,2 +sinikovic,2 +sinnappurajar,1 +sinoch,2 +sinock,1 +sinton,7 +sioson,1 +sipa,2 +sirbu,1 +sires,17 +sirilan,1 +siripong,1 +siroky,1 +siropoulous,1 +sirotic,1 +sitarenos,4 +sitepa,2 +sitko,1 +sivapatham,2 +siviour,90 +siwak,2 +skaife,1 +skailes,1 +skandamis,1 +skarbek,1 +skarmoupsos,1 +skeen,15 +skell,1 +skellern,1 +skellington,1 +skirca,4 +skirton,1 +skitch,1 +skladzien,2 +skliwa,4 +skountzos,2 +skrjanc,1 +skrpan,1 +skubig,1 +skujin,1 +skurr,2 +skvaril,5 +skyes,1 +skyrme,1 +slabbert,1 +slack-smith,7 +slaghuis,1 +slaney,2 +slape,53 +slatcher,1 +slave,1 +slavic,1 +slavica,1 +slavvjevic,1 +slawinski,3 +sleath,13 +sleightholme,3 +sleiters,1 +slicer,3 +sliuzas,1 +sliwakowski,1 +sloniec,4 +slorach,2 +sluga,2 +slunjski,1 +slywka,1 +smagala,1 +smair,1 +smajic,1 +smallacombe,67 +smans,1 +smeaton,22 +smedes,1 +smeenge,1 +smith-roberts,3 +smith-smidmore,1 +smithe,1 +smithen,2 +smithson,31 +smitti,3 +smolka,3 +smolski,4 +snajdar,6 +snale,1 +sneata,1 +sneesby,6 +snell,97 +snelling,35 +snoad,13 +snordawski,1 +snowball-smith,1 +snowling,1 +snuggs,2 +snushall,3 +so,9 +soames,1 +soave,3 +sobczak,9 +soden,26 +soeia,1 +soelkner,1 +soeroes,2 +soetantri,1 +soewandijono,1 +soh,1 +sohkanen,2 +sok,9 +sokic,1 +sokolov,2 +solc,1 +soldic,1 +solente,2 +solis,2 +solito,3 +solman,1 +soloijic,1 +solonimkl,1 +solonsch,2 +solorzano,1 +solty,1 +soltys,4 +soman,3 +somim,1 +somina,1 +sommariva,12 +somozo,2 +son,12 +sondergeld,1 +sones,2 +sonhom,1 +soni,3 +sonnack,4 +sonner,1 +sonsie,3 +soonthornnawaphap,1 +soovoroff,1 +sopharat,1 +sorieno,1 +sorn,1 +soroosh,1 +sorsa,1 +soso,2 +sothman,1 +sotnik,2 +sotomayor,1 +sotutu,1 +souden,1 +souksavat,2 +soule,6 +soulemezis,4 +soulsby,11 +soultan,1 +sounness,1 +southgate,19 +southwood,15 +soward,6 +spaander,1 +spaans,7 +spada,2 +spagnoletti,23 +spagnolo,3 +spahic,2 +spajic,2 +spakianos,2 +spakman,2 +spall,10 +spalvins,4 +spaninks,3 +spanton,6 +spargo,27 +spark,35 +sparta,1 +spate,4 +spawton,1 +spearing,1 +spears,34 +speeles,1 +speight,30 +spendley,1 +sperber,2 +sperrin,2 +speville,1 +spicer,96 +spillings,1 +spinato,4 +spinetti,1 +spiota,1 +spong,22 +sponza,2 +sporn,19 +sporton,4 +spourdos,2 +spradau,1 +spratt,44 +sprenglewski,1 +springthorpe,3 +sprogis,2 +sproles,1 +spromk,1 +sproul,1 +spurden,1 +spurgeon,5 +spuzic,2 +spyridis,1 +spyropoulos,14 +squelch,1 +srapisan,1 +srdic,1 +srdinsek,1 +sreckovic,3 +sreenatha,1 +sribar,3 +sritharan,1 +sroczek,2 +srour,4 +st clair-dixon,1 +st vincent,3 +stacca,1 +stadlmaier,1 +stadthagen,1 +stadtmiller,1 +stafford-lee,1 +staggard,8 +stagoll,10 +staig-hamdorf,1 +staight,2 +stainton,3 +stallion,3 +stamatas,1 +stamboulakis,1 +stamoulos,2 +stampke,3 +stanaway,3 +stanbury,32 +stancliffe,5 +stancombe,9 +stanek,6 +stanesby,2 +stanfield,39 +stangoulis,2 +stanislaus-large,1 +stanley,299 +stanly,1 +stannar,1 +stanojcic,1 +stanton-gillie,1 +stanwick,2 +stapenall,1 +stapenell,5 +stapinski,1 +stapley,6 +staporski,5 +starega,2 +state,1 +statham,16 +staton,2 +statton,27 +staude,41 +staufenbiel,1 +staugas,1 +stauner,1 +staunton-smith,4 +stawicki,1 +steane,11 +stear,3 +stearnes,16 +steart,5 +stech,2 +steed,51 +steele scott,3 +steeles,3 +steers,37 +stefan,3 +stefanicki,2 +stefanidi,1 +stefanocic,1 +stefanovska,2 +stegemann,8 +steinbacher,2 +steinert,49 +steinmetz,2 +stellini,2 +steltenpool,1 +stemper,2 +stencel,3 +stene,1 +stening,6 +stenn,1 +stephanos,4 +stephenson,299 +stephopolous,1 +stepic,4 +stepinski,1 +sterio,1 +sternbeck,1 +sternek,2 +sternizsa,1 +sterpin,3 +sterry,13 +stevanja,3 +stevedore,1 +steviens,1 +stewart-jones,7 +stewen,1 +steyger,3 +stigant,2 +stigis,1 +stinchcombe,1 +stine,1 +stingle,17 +stintin,1 +stirland-mitchell,1 +stirpe,4 +stitz,5 +stivers,1 +stobo-wilson,1 +stockall,4 +stockes,1 +stodart,12 +stoeckeler,1 +stoffels,2 +stogneff,4 +stojak,1 +stojic,2 +stojsic,2 +stoker,19 +stokker,5 +stoksik,1 +stolfa,2 +stolhand,1 +stolica,1 +stolz,16 +stolze,2 +stone murray,1 +stonehaus,1 +stoneman,20 +storken,3 +storozjenko,1 +stosh,2 +stowpiuk,1 +straczek,1 +strainij,1 +stranger,18 +strangway,2 +straub,1 +strazzari,2 +streckfuss,1 +strehovski,2 +streich,3 +strenge,3 +strie,3 +strimpel,1 +strmota,2 +stroeh,5 +stronach,24 +strubbe,1 +struck,12 +strudwick-brown,1 +strungs,2 +struzik,1 +stubbin,2 +stubbs,170 +stuber,3 +studer,2 +studman,1 +stuetz,3 +stumann,3 +stumbles,1 +stuyanaki,1 +stylianopoulos,4 +suang,1 +subacius,3 +subaj,1 +suban,3 +subramaniam,9 +suchar,1 +suckow,1 +sudaj,2 +sudding,1 +sueppel,2 +suffolk,9 +suhan,1 +suine,2 +sukh,3 +sukjit,1 +sukovski,1 +sukwatthananan,1 +sulan-schueler,1 +suleiman,1 +sulich,2 +sulikowski,2 +sulman,4 +summerrell,1 +summers-pullin,2 +sumption,1 +sumsion,12 +sundaralingam,1 +sunderland,26 +sunderman,1 +sundo,1 +supomo,2 +suppinger,1 +suraci,1 +surch,1 +surikow,1 +suringa,2 +surrich,1 +surulo,1 +susana,1 +sushames,24 +suskin,3 +suslin,1 +susta,1 +suth,2 +sutpiah,1 +suttell,2 +suttle,3 +suvailo,1 +suvorova,1 +suyen,1 +suzor,4 +svane,1 +sveli,1 +svenson,6 +svetec,4 +svihla,1 +svircevic,1 +svitlica,1 +swaalf,1 +swarner,1 +swayne,12 +swetnam,4 +swierc,3 +swiggs,23 +swindlehurst,1 +swinney,1 +switalski,7 +swney,1 +swoboda,5 +sworzeniowski,1 +swynczuk,1 +sydenham,7 +syder,1 +sydorenko,2 +sydorowich,1 +sykiotis,2 +symmons,22 +symth,2 +synnet,1 +synusas,1 +synwoldt,1 +syren,1 +syrokos,1 +sytsma,5 +szablinski,1 +szach,3 +szalai,7 +szauer,2 +szczecinski,5 +szecko,1 +szekernyes,1 +szepessy,7 +szeszycki,2 +szilassy,1 +szklarz,1 +szkolik,3 +szlezak,3 +szmeja,1 +sznajder,1 +szocinski,1 +szomorkay,1 +szopko,1 +szpakowska,1 +szprega,2 +sztolc,2 +szumny,1 +szumski,1 +szupan,1 +szwajcer,1 +szymanaski,1 +szymczak,5 +szynkar,3 +szysz,2 +szyszlak,1 +taborsky,1 +tabrett,2 +tadege,1 +tadier,1 +tae-hyun,1 +taglietti,2 +tailor,2 +tainton,2 +taira,1 +tajgi,1 +takafumi,1 +takami,1 +takasuka,1 +takats,5 +takeshi,1 +taladira,1 +talapaneni,1 +talavanic,1 +talay,1 +talberg,4 +talevich,1 +talladira,13 +tallarida,7 +talmet,2 +tamasauskas,1 +tamassy,5 +tammita,2 +tammo,1 +tammpuu,1 +tamura,2 +tan kiang,1 +tanase,1 +tangallpalla,1 +tangorra,2 +taniora,2 +tanks,2 +tant,2 +tants,2 +tantschev,3 +tao,8 +tapper,11 +tara,1 +taranthoiene,1 +taratt,1 +tarczylo,1 +tardrew,6 +tarleton,1 +tarn,4 +tarooki,1 +tarquinio,2 +tarrillo villalobos,1 +tarsissi,1 +tarter,1 +tasevski,3 +taskovic,1 +taslidza,1 +tassis,3 +tatam,1 +tatarovic,1 +tatlock,1 +tatpo,1 +tatto,2 +taube,4 +taubers,4 +taubert,6 +taubman,2 +tauj,1 +taute,3 +tavis,2 +tavoulari,1 +taxi,1 +taylor-cannon,1 +taylor-gordon,1 +tchepak,1 +tchung,1 +te kawau,1 +te namu,1 +teague,81 +teal,5 +teates,1 +teav,3 +tebb,6 +tebbutt,11 +tebby,2 +teear,1 +teeboon,1 +teh,5 +teleki,1 +telese,2 +telleglou,1 +teller,1 +tellis,7 +ten brummelaar,2 +ten hove,1 +ten-tije,1 +tenant,2 +tenbensel,4 +tencic,1 +tengdahl,2 +tenholder,4 +tennent,13 +tenney,4 +tennyson,2 +tenshek,2 +tepohe,2 +terek,3 +terend,2 +terrens,2 +terrey,2 +tertipis,3 +terwey,2 +teteris,4 +teti,3 +tetija,1 +tetrovic,1 +tettmar,2 +tetzsch,1 +teuma,2 +teunissen,6 +thaba,1 +thackeray,3 +thaker,2 +thalmann-mckay,1 +thamotharalingam,1 +thamrongvoratorn,1 +thandi,5 +thanissorn,3 +thavarajadeva,1 +thaxton,1 +theissen,2 +theng,1 +theodorakakis,1 +theodore,14 +theodorsen,1 +theofanous,3 +theoharidou,1 +theologa,3 +theologidis,2 +thibodeau,3 +thick,3 +thier,1 +thiessen,26 +thind,1 +thirgood,4 +thiry,4 +thistlethwaite,2 +thiveos,1 +tholen,1 +thollar,2 +thomsom,1 +thonan,1 +thoonen,1 +thornquest,2 +thorold,4 +thorpe,323 +thost,1 +thredgold,56 +thrift,9 +thrussell,6 +thulasidharan,1 +thurlow,42 +thwaite,8 +thygesen,2 +tiah,1 +tiboldo,3 +tibury,1 +tichelaar,1 +ticknell,1 +tidenann,1 +tidey,15 +tieck,1 +tiede,2 +tiedemann,6 +tiefenbach,1 +tien,6 +tientjes,1 +tieppo,4 +tiesler,1 +tiestel,1 +tiffin,19 +tiggeman,7 +tilakaratne,2 +tilker,7 +tiller,128 +tilliard,2 +tiltman,2 +tim,5 +timbrell,5 +timmermans,5 +timmiss,4 +timoshanko,1 +timperon,12 +timpson,2 +tims,11 +tina,1 +tinari,1 +tinfina,2 +ting,29 +tinggee,1 +tinsley,11 +tinson,5 +tinus,1 +tip,1 +tippel,1 +tippins,43 +tiptaft,1 +tipunewuti,1 +tirilis,1 +tirimona,1 +titmarsh,3 +tittoto,5 +tiu,1 +tkachuk,3 +tlauka,1 +tlenys,1 +todhill,1 +toeta,1 +toews,1 +tognella,3 +tognolini,1 +tokar,1 +tokareu,1 +toker,3 +toleman,3 +tolfts,6 +tollner,9 +tolovae,1 +tomadini,1 +tomasevic,2 +tombleson,3 +tomich,5 +toming,1 +tomkin,5 +tomli,1 +tomney,41 +tompai,2 +tompkin,1 +tompsitt,1 +toms,40 +tones,1 +toneva,1 +tonge,11 +tongyode,1 +tonta,2 +toohill,3 +tootell,15 +toothill,2 +toplass,1 +toporowski,1 +toralis,1 +torni,1 +torop,1 +torquati,4 +torster,1 +torzillo,3 +toscano,6 +tose,2 +toseland,14 +toso,6 +tossani,1 +tossell,10 +tostervin,1 +totagi,2 +totonidis,3 +tourlis,2 +tourmaline,1 +tow,6 +towey,4 +townsend-evans,1 +townsly,1 +towstyi,2 +toyama,1 +trace,3 +trad,1 +traforti,5 +trainor,24 +trait,3 +tram,4 +tramaglino,2 +trampenau,1 +trankle,2 +tranthem,5 +traplin,1 +trapnell,5 +trappitt,1 +trathen,3 +trauntvein,1 +travar,4 +travini,1 +treager,2 +tregloan,15 +tregoning,20 +treherne,2 +treilibs,2 +trelbby,2 +tremellen,14 +trenchard,1 +trenchuk,3 +trenerry,31 +trenery,4 +trenow,1 +trent,7 +trenter,1 +trepka,2 +treplin,3 +tressider,2 +treumer,2 +treutler,1 +trevan,6 +trevarrow,3 +trever,1 +trevorrow,15 +tri,2 +triandafyllidis,2 +triantafyllakis,1 +triat,1 +tribbeck,5 +tridgell,3 +trigwell,2 +trimbell,4 +trimble,18 +trimbole,1 +trimmer,13 +tring,1 +tripley,1 +trivett,5 +trivic,2 +trninic,1 +troisi,2 +tromp,10 +tronc,1 +trondl,1 +tronina,2 +trooper,1 +troubridge,1 +trowse,19 +troxell,1 +trpkovski,1 +trubee,5 +trubik,1 +trukhanov,1 +truman,32 +trumbull-ward,1 +trunks,2 +trusiewicz,2 +truslove,6 +tryfonos,1 +trzcinski,5 +tsakiridis,5 +tsakmakis,1 +tsamandanis,1 +tsamtsikas,1 +tsang,11 +tsaousi,1 +tsavtaridis,1 +tsaxirlis,1 +tschernykow,1 +tschirn,6 +tschirpig,21 +tsegas,2 +tselepis,1 +tsermentselis,1 +tsialafos,2 +tsiamas,2 +tsikmis,1 +tsimpinos,1 +tsinivits,1 +tsiokantis,1 +tsiopilas,1 +tsiounis,1 +tsipenyuk,1 +tsokas,1 +tsolakakis,1 +tsolakis,2 +tsonis,6 +tsoubarakis,3 +tsouris,7 +tsoutas,3 +tsujimoto,1 +tsumchai,1 +tsun,2 +tu,33 +tuckwell,48 +tuendemann,5 +tuft,3 +tuikaba,1 +tuit,15 +tuk,2 +tuke,1 +tulla,5 +tulysewski,1 +tunevitsch,1 +tunner,1 +tunstall,10 +tupai,1 +tuppini,1 +turakulov,1 +turale,12 +turbitt,4 +turco,5 +turel,1 +turelli,2 +turkalj,1 +turkentine,4 +turnagic,1 +turnball,3 +turnor,3 +turtur,14 +tusel,1 +tuting,6 +tuttleby,2 +tuza,2 +twang,1 +tweedie,18 +tweedle,1 +twelves,1 +twemlow,1 +twigg-patterson,2 +twigger,4 +twin,2 +twizell,1 +tyack,5 +tyczenko,2 +tyerman,9 +tylkowski,3 +tymczyszyn,1 +tyminski,2 +tyndale-biscoe,1 +tyner,8 +tzannes,2 +tzeegankoss,1 +tziolis,1 +tzousmas,1 +ubelhor,1 +udina,2 +udovcic,3 +udovicic,4 +ueberall,1 +uffelmann,4 +uhlik,1 +uhr,4 +ukleja,3 +ukota,2 +ulanowicz,1 +ulbrich,5 +uldum,2 +ulrick,7 +umbrasas,1 +unetta,2 +ung hang,1 +uniya,1 +unver,1 +unyland,1 +urenda,1 +urh,3 +urmonas,3 +uroaevic,1 +uroda,2 +urosevic,5 +urqhart,1 +urquhart-fisher,1 +urvet,4 +usikovia,1 +usmiani,2 +uszynski,3 +uteza,1 +uthenwoldt,1 +utten,2 +utterson,1 +uu,1 +uyttenhove,2 +uzubalis,1 +vaccaro,13 +vacchiani,2 +vagner,1 +vah,1 +vahldick,1 +vaile,2 +vainui,1 +vaisey,3 +vakos,1 +vaks,1 +vakulin,1 +valadares,4 +valaris,1 +valasakis,1 +valdivia,3 +valena,2 +valentijn,1 +valentini,6 +valeriano,1 +valesic,2 +valetti,1 +valiyff,4 +valkenburg,1 +valles,1 +vallesi,1 +valmorbida,1 +valters,1 +van aardt,1 +van abkoude,1 +van acker,3 +van akker,1 +van balen,8 +van beeck,1 +van beek,5 +van ben hoogen,1 +van ben wildenderg,1 +van benpen,1 +van boekel,4 +van broekhoven,2 +van caspel,4 +van commenee,1 +van de graaff,1 +van de kamp,9 +van de maele,2 +van de rhee,1 +van de steeg,2 +van de water,9 +van den acker,1 +van den biggelaar,1 +van den boogaard,1 +van den elzen,1 +van den hoogen,7 +van den huvel,1 +van der berg,1 +van der biezen,4 +van der brink,1 +van der eyk,1 +van der hoek,16 +van der klaauw,2 +van der kloes,1 +van der klugt,2 +van der kolk,7 +van der kraan,3 +van der linde,2 +van der steege,1 +van der vlies,2 +van der vliet,2 +van dereerden,1 +van dok,5 +van doren,2 +van engelenhoven,2 +van eysden,1 +van galen,11 +van geel,3 +van gent,1 +van grinsven,1 +van groesen,4 +van hees,14 +van heythuysen,5 +van hoof,6 +van huynh,1 +van kalker,2 +van kerkwyk,1 +van kessel,4 +van keulen,7 +van konkelenberg,1 +van langenberg,1 +van lien,1 +van limbeek,4 +van lingen,1 +van maamen,1 +van maurik,1 +van meer,1 +van neutegem,3 +van niel,1 +van oostrum,3 +van poeteren,1 +van putten,2 +van reesch,3 +van reesema,1 +van reeuwyk,1 +van rensburg,2 +van roden,1 +van rossen,4 +van schie,6 +van someren graver,1 +van tholen,2 +van tuil,2 +van waardhuizen,1 +van wensveen,1 +van wijk,4 +van zalen,1 +van zanden,1 +van't hof,3 +van't hoff,1 +vanagas,2 +vanbelkom,1 +vanbrecht,1 +vande weyer,1 +vandekamp,4 +vandelaar,4 +vandelay,1 +vandenbosch,2 +vandenbroucke,1 +vandenburg,1 +vander neut,2 +vanderlink,1 +vandermolen,1 +vandersman,3 +vanderwesten,2 +vanderzwan,2 +vandevelde,1 +vandonderen,2 +vandoorn,1 +vandulkan,1 +vaneldik,1 +vanern,1 +vangelov,1 +vangils,2 +vangorp,1 +vanhaasteren,1 +vanhees,1 +vanic,1 +vaninetti,5 +vanlaatum,2 +vanmeerendonk,1 +vannarath,1 +vannetiello,1 +vanniasingham,1 +vanree,2 +vanrijthoven,1 +vanschieveen,2 +vansetten,1 +vansyl,1 +vantatenhove,2 +vanzanten,1 +varano,5 +varcoe,52 +varey,2 +varma,3 +vasilakis,2 +vasile,2 +vasilevskis,1 +vasiliev,2 +vasilj,1 +vasios,1 +vaso,1 +vass mcmaster,1 +vassal,1 +vassarotti,4 +vassiliotis,1 +vaszocz,4 +vatavuk,4 +vatchenko,2 +vatcky,1 +vatskalis,1 +vaudrey,1 +vaughan-williams,4 +vaughen,1 +vavic,4 +vaziri,1 +vazquez,2 +vearing,15 +vedigs,1 +veerhuis,5 +vegvoda,1 +vehlow,1 +veis,1 +veit,4 +velaitis,1 +veld,3 +velebit,1 +veleski,2 +velkovska,1 +vellenoweth,1 +velnaar,1 +velzeboer,1 +venable,3 +vendel,1 +venes,1 +vennus,1 +verco,74 +verdicchio,2 +verdins,1 +vereb,1 +veremchuk,1 +verhelst,1 +verho,1 +verilli,1 +verkouter,1 +vermeesch,1 +verner,21 +vernik,3 +vernis,2 +verrion,3 +verschoor,7 +versluys,2 +versteeg,18 +versteegen,5 +vesco,1 +veshner,1 +veszpeller,2 +veteri,1 +vett,3 +vettese,2 +viale,1 +viart,1 +vichie,2 +vick,17 +vickary,1 +vidakovic,5 +vidlov,1 +viec,1 +vieraitis,2 +vietmeyer,1 +viezzi,4 +viffer,1 +vig,3 +vigenser,1 +vigliotti,1 +vigneswaran,2 +vignoni-squire,1 +viira,1 +vijiaraj,2 +vikor,4 +viksna,2 +villafuerte,3 +villapini,1 +villavelez,1 +villeseche,1 +villiers,6 +vilums,1 +vimpany,10 +vinaev,5 +vincenc,1 +vincent,298 +vinten,1 +virag,11 +virant,1 +virgen,3 +virleux,1 +viro,1 +visirmidis,1 +vitarana,1 +vitasz,1 +vitkunas,4 +vitti,1 +vixon,1 +vizer,3 +vlach,1 +vlahodimos,1 +vlamos,1 +vlasich,2 +vlassopoulos,4 +vlavogelakas,1 +vlismas,1 +vlitsis,1 +voarino,1 +vodden,2 +vodic,4 +voevodov,1 +vogelpoel,3 +vogiatzi,1 +voglino,3 +voivodich,5 +vojvodic,1 +volframs,3 +volkmar,1 +vollbrecht,1 +volle,1 +volpato,6 +von blunendals,1 +von hoist,1 +von holst,1 +von krusenstierna,1 +von wasserling,1 +vonbibra,3 +voorendt,2 +vorakoumame,1 +voroniansky,3 +vorrasi,19 +vorstenbosch,3 +voskulen,3 +vosper,3 +vostatek,2 +voulgarakis,3 +voulgaridis,1 +vounasis,2 +vown,1 +voy,4 +vrettis,4 +vreugdemburg,1 +vreugdenburg,8 +vreugdenhil,3 +vrlic,3 +vroegop,2 +vrolyks,1 +vujicic,1 +vukelic,2 +vultiani,1 +vurneski,1 +vurovecz,1 +vyden,2 +waal,2 +wable,1 +wache,2 +wachla,4 +wackrow,1 +wagenknetht,1 +wagley,1 +wagnitz,12 +wah,3 +wahlstedt,9 +waianga,1 +wairoa,1 +wajcman,1 +wakerell,3 +walch,24 +waldhauser,3 +waldhein,1 +walhane,1 +walkenhorst,1 +walkey,2 +walkington,21 +walkley,71 +walla,2 +wallace-carter,1 +wallbridge-yost,1 +wallent,9 +waller,163 +walley,10 +wallin,6 +walls,41 +wallworth,1 +walpole,23 +walraven,3 +waltke,4 +waltrowicz,2 +wanago,1 +wanambi,8 +wanatjura,1 +wandell,4 +wanders,10 +wane,1 +wang,115 +wangel,3 +wangka,1 +wapper,13 +wapshot,1 +warboys,2 +warbroek,5 +ward-lohmeyer,1 +warde,8 +wardle,84 +warendorf,3 +warjo,1 +warmingham,1 +warneke,23 +warnett,7 +warnock,42 +warrior,15 +warsap,1 +warth,2 +warusevitane,3 +warzoniski,1 +washbrook,1 +wasley,44 +wasser,5 +wasserfall,1 +wassmann,1 +wassom,1 +wasson,7 +wastell,24 +wasteneys,1 +watanabe,2 +watanaverapong,1 +waterfall,1 +waterlander,1 +waterlow,2 +waterston,2 +watkin,12 +watkinf,1 +watkins-lyall,2 +watmough,3 +watts-endresz,1 +wauchop,3 +wauhop,1 +wawrzycki,1 +wayehill,1 +waygood,1 +wazlawek,2 +wearden,1 +weare,6 +weate,5 +weatherhill,1 +weavell,7 +weaver,152 +webb,1047 +webester,1 +weckenmann,1 +wedmaier,2 +weedar,1 +weelius,2 +weerakkody,3 +weetra,25 +wegemer,1 +wegman,14 +wehner,3 +wehr,36 +wehrmuller,1 +weidenbach,15 +weidenhofer,27 +weidenhoffer,2 +weiller,2 +wein-smith,1 +weir-modem,1 +weiser,2 +welks,1 +wellburn,1 +weller,95 +weltman,6 +weluk,1 +weniton,5 +wenitong,1 +wenmam,1 +went,17 +werk,1 +werneburg,2 +werrey,4 +werts,2 +wesener,1 +wesley-smith,6 +wesney,3 +wessel,4 +wessthorp,1 +westacott,4 +westbrook,70 +westenraad,1 +westerbeek,3 +westergaard,3 +westerholm,4 +westermann,3 +westfield,1 +westhorp,3 +westlry,1 +westte,2 +wetherington,1 +wettels,1 +wetzel,2 +wevill,4 +wewzow,1 +wex,3 +weymar,2 +whaipe,1 +whait,9 +whale,11 +whallin,4 +whamond,4 +wharmby,4 +whatford,1 +whatling,7 +whatman,13 +whatmore,1 +whatt,1 +wheatley,130 +wheldale,2 +whetham,3 +whetstone,14 +whetton,4 +whillas,34 +whinfield,3 +whishaw,3 +whisson,16 +whitbourne,2 +whitbrerd,1 +white,2399 +whiteley,84 +whiteread,2 +whiterod,1 +whitesman,3 +whiteway,17 +whithear,3 +whitsitt,5 +whitters,14 +whittlesis,1 +whorlow,1 +whymark,1 +wiaczek,1 +wickel,3 +wickramanayake,1 +wickramasinghe,1 +widdowson,38 +widdup,3 +widera,2 +widerkehr,1 +wiechec,5 +wieffering,1 +wiegold,4 +wieloch,3 +wiemann,4 +wiemers,3 +wierda,5 +wiggan,1 +wijedasa,1 +wijeratne,3 +wijesurendre,1 +wijesuriya,1 +wilcockson,3 +wilczek,14 +wilde,79 +wiley-smith,1 +wilfredo,1 +wilgar,1 +wilhelmsson,2 +wilkey,49 +wilkie-snow,1 +wilkins,255 +wilkonson,1 +willanski,2 +willding,2 +willering,5 +willes,12 +williamson-cameron,3 +willing,55 +willmot,14 +willmoth,3 +willoughby-smith,1 +willowhite,2 +willsford,2 +wilshire,4 +wilson-haffenden,3 +wilson-wheeler,2 +wilzen,1 +wimbush,4 +wimmer,14 +wimmler,1 +wimpenny,3 +win,2 +winckle,1 +windmill,2 +windross,3 +windus,1 +windy,1 +winem,1 +winfield,34 +wingate,12 +winger,2 +winiarz,1 +winnall,10 +winnel,1 +winnett,6 +winny,1 +winsome,1 +winterlich,1 +winterton,5 +wintrop,1 +wintulich,7 +winwood-smith,2 +wirsu,3 +wirthersohn,1 +wisby,27 +wiseman,139 +wisowaty,2 +wisterand,1 +wiszniak,1 +witehira,1 +witherington,5 +withinshaw,1 +withrington,2 +witkin,5 +wittchen,4 +wittern,2 +witthoeft,4 +wittrock,1 +witty,20 +woffenden,1 +wogandt,2 +wohltmann,3 +wojciak,2 +wojciechowski,11 +wojtal,1 +wojtyna,2 +wolfenden,13 +wolffs,1 +wolms,1 +woloczij,1 +wolss,1 +womack,3 +wonderley,1 +wood-bradley,2 +woodbury,19 +woodford-smith,1 +woodlock,7 +woodmansee,2 +woods-trezise,1 +woodstock,3 +woofe,2 +wooldridge-curtis,1 +wooley,33 +woolger,3 +woollaston,3 +woolrich,1 +worgan,5 +worm,4 +worony,2 +worre,1 +worsey,1 +worsley,49 +worthington-eyre,6 +wortlehock,2 +wortmeyer,5 +wottke,1 +wotton,37 +woulman,1 +wraight,14 +wreford,17 +wressell,2 +wrighte,1 +writer,6 +wrobiewski,1 +wrzosek,1 +wsolak,1 +wuchatsch,1 +wucherpfenning,1 +wujda,3 +wur,1 +wurlod,2 +wurm,13 +wurmburdang,1 +wurranwilya,1 +wydra,1 +wyeth,5 +wykmans,2 +wylder,1 +wyllie,62 +wynne,54 +wyskamp,2 +wytkin,10 +xepapas,4 +xerri,3 +xiaodong,1 +xie,6 +xiong,11 +xoing,1 +yacoub,2 +yakubu,1 +yallop,6 +yalumul,1 +yanagawa,1 +yani,1 +yannakoudis,1 +yannelis,2 +yannopoulos,3 +yanny,3 +yappa,1 +yaroslavseff,2 +yaser,2 +yassine,1 +yasuta,1 +yatarrnta,1 +yeap,2 +yeatmin,1 +yee,18 +yelds,3 +yellup,1 +yen,16 +yenni,1 +yeoman,19 +yerrell,3 +yialas,3 +yiannoulis,3 +ylor,1 +yoder,1 +yogarajan,1 +yoon,9 +yoshimura,1 +yost,27 +yotong,1 +youay,1 +youde,2 +youngs,7 +yrdaw,1 +yu,34 +yun,4 +yunupingu,6 +yusoph,2 +yvanovich,4 +zabel,2 +zabiegala,1 +zablocki,1 +zaborowski,1 +zacharioglou,1 +zaffina,1 +zaffino,1 +zafiropoulos,4 +zagal,1 +zaganjori,1 +zagar,8 +zagorski,1 +zaharogiannis,3 +zaikos,1 +zaimis,1 +zajaczkowski,3 +zajkovic,1 +zakharchenko,1 +zalan,1 +zalotockyj,1 +zaltron,13 +zaluski,9 +zamaro,1 +zandstra,1 +zanelli,2 +zanesco,2 +zaneti,2 +zangl,2 +zani,3 +zank,1 +zapotocky,2 +zappulla,2 +zarei bashnian,1 +zaremba,2 +zarevac,3 +zaric,2 +zarka,1 +zarkovic,5 +zarney,1 +zaroufis,1 +zarrinkalam,2 +zatorski,5 +zawadzki,4 +zawistowski,1 +zazula,1 +zbierski,27 +zbucki,1 +zdanowicz,4 +zdebelak,1 +zdziarski,1 +zealley,4 +zecchini,6 +zeck,2 +zehetner,1 +zeicnan,1 +zeitzen-van der burg,1 +zejfert,2 +zejnic,2 +zelesco,3 +zelisko,2 +zell,1 +zellmer,2 +zemanovic,1 +zemlicka,1 +zendili,1 +zenkteller,1 +zepina,2 +zerjal-mellor,2 +zessack,1 +zhang-hu,1 +zhe,2 +zheng,19 +zia,1 +ziaian,1 +zibar,6 +ziedas,2 +zielinsaki,1 +zierholz,3 +ziersch,50 +zilifian,1 +zilm,66 +zimic,1 +zimmermann,86 +zimon,2 +zingarelli,1 +ziomek,2 +zirkzee,1 +ziswiler,1 +zivkov,3 +zlatkovic,2 +zlotkowski,1 +zoanetti,18 +zobonos,1 +zoch,1 +zogopoulos,6 +zokalj,3 +zolotariova,1 +zolotic,1 +zolyniak,5 +zomer,3 +zong,1 +zoontjens,7 +zordan,5 +zorin,2 +zosnes,1 +zou,1 +zoughi,1 +zubreckyj,3 +zubrinick,1 +zubrzycki,2 +zulkefli,1 +zur,1 +zuraszek,1 +zurawell,1 +zutaut,1 +zwald,1 +zwanns,1 +zweifel,1 +zwick,2 +zwillenberg,1 +zyczko,1 +zyga,1 diff --git a/geco_data_generator/data/surname-misspell-japanese.csv b/geco_data_generator/data/surname-misspell-japanese.csv new file mode 100644 index 0000000000000000000000000000000000000000..894f339997664accce0bbbd1ef0fd7485e10fde2 --- /dev/null +++ b/geco_data_generator/data/surname-misspell-japanese.csv @@ -0,0 +1,14 @@ +‘Šì,‘Š‰Í +ˆäo,ˆäŽè +ˆÉ“¡,ˆÉ“Œ +Ä“¡,âV“¡ +Ä“¡,Ö“¡ +‘¾“c,‘å“c +Ž™“‡,™Z“‡ +ú±ŽR,èŽR +‘L,š œA +‘L,š L +‘L,‘œA +L“c,œA“c +“n•Ó,“nç² +“n•Ó,“nç³ diff --git a/geco_data_generator/data/surname-misspell.csv b/geco_data_generator/data/surname-misspell.csv new file mode 100644 index 0000000000000000000000000000000000000000..523eaf984faced1016ad3eddc6de92532d8f7bad --- /dev/null +++ b/geco_data_generator/data/surname-misspell.csv @@ -0,0 +1,443 @@ +# ============================================================================= +# surname-misspell.csv - Lookup-table for surname misspellings used for the +# database generator +# +# - The word left of the comma is the correct spelling, right of the comma is +# the corresponding misspelling +# - Several misspellings can be given fir the same correct spelling +# +# Last update: 18/03/2012, Peter Christen +# ============================================================================= + +aitchison,acheson +aitken,aiken +aldis,aldous +almond,allmond +althea,thea +arden,ardie +arland,arley +arland,arlie +arland,arly +armen,armand +arnoud,arnout +avice,avis +avice,awis + +barclay,berkeley +baxter,bax +blythe,blithe +boleslaw,bolestlaw +bowden,bowen +boyle,oboyle +bree,obree +brice,bryce +brian,brien +brian,briant +brian,bryan +brian,bryant +brian,obrian +brian,obrien +brian,obryan +brinley,brindley +bruckner,brukner +burl,burlie +burrows,burroughs +bush,busch +byers,byas +byers,byass +byrne,byrnes + +cain,caine +cain,cane +cain,conn +cain,kain +cain,kahn +cain,kon +cain,okane +cain,okeane +callaghan,callahan +callaghan,ocallaghan +calvert,calvat +campbell,cambell +car,kaare +carlisle,carlile +carlisle,carlyle +castle,cassel +castle,cassell +castle,kassel +chapman,chap +cletus,clete +cleveland,cleave +cleveland,cleve +clyne,klein +coldbeck,colbeck +coleman,colman +concepcion,conchita +connell,oconnell +connor,conner +connor,oconner +connor,oconnor +corbett,corby +cosh,koch +cramer,kramer +cramer,kraymer +cramer,kremer +creighton,crichton +crowe,krogh +cruise,crews +cruise,kruse +cummins,cummings +cyrus,cy + +davidson,davison +davidson,davissen +davina,davida +dea,odea +dell,odell +denbeigh,denby +denholm,denham +dennis,dennys +desmond,desmon +dickson,dixon +dinh,din +dinh,dingh +dinning,dinnin +doherty,docherty +doherty,dougherty +doherty,odoherty +dolman,dollman +donaghue,odonaghue +donaghue,odonahoo +donaghue,odonahue +donnell,odonnell +donohoe,donoghue +donovan,odonovan +dowd,odowd +driscoll,odriscill +driscoll,odriscoll +dudley,dud +dudley,dudleigh +duff,duffy +duke,dukes +dwyer,odwyer + +eames,ames +eames,amies +elder,elde +elms,elemes +engle,engel +engle,ingle +english,inglish +english,ingliss +eyres,ayers +eyres,ayres +ezekiel,zech +ezekiel,zeke + +farrell,ofarrell +faulkner,falc +faulkner,falcon +faulkner,falconer +faulkner,falk +faulkner,falkiner +faulkner,fawkner +finlay,findlay +finlay,findley +fitzner,pfitzner +flaherty,oflaherty +flanagan,oflanagan +flynn,oflynn +ford,forde +forster,foster +freeman,freedman +french,ffrench +frost,ffrost + +gallagher,ogallagher +gara,ogara +gaven,gavin +geraghty,garretty +geraghty,garrety +geraghty,garrity +gillman,gilman +gordon,gordie +gordon,gordy +gorman,ogorman +gough,goff +gower,ogower +grady,ogrady + +hadleigh,hadley +hagan,ohagan +hallor,ohallor +halloran,ohalloran +han,ohan +hanaffian,ohanaffian +hancock,handcock +hanes,ohanes +hanessian,ohanessian +hanian,ohanian +hanley,hambley +hanley,hamley +hanley,handley +hanlon,ohanlon +hannes,ohannes +hannessian,ohannessian +har,ohar +hara,ohara +hara,oharae +hare,ohaiher +hare,ohaire +hare,ohare +hare,ohegir +hare,ohehar +hare,ohehier +hare,ohehir +hare,oheir +harford,hartford +harris,oharris +hart,ohart +hawkyard,halkyard +hayon,ohayon +hayward,haywood +hayward,heyward +hayward,heywood +hayward,howard +hazy,ohazy +hea,ohea +hearn,ohearn +hodgson,hodson +horton,hawtin +horton,houghton +hough,hoff +hudson,housten +hudson,houston +hudson,huston +hughes,hewes +humphrey,humfrey +humphrey,onofredo + +irving,ervy +irving,irvin +irving,irvine +islay,isles + +johnson,johnston +johnson,johnstone +junior,jnr +juris,yuris + +kantor,cantor +karlsen,carlson +kavanagh,cavanagh +kavanagh,cavanough +kavanagh,cavenagh +kealley,keighley +kearney,carney +kearney,carnie +kearney,okearney +keefe,okeefe +keese,okeese +keil,okeil +keith,okeith +kel,okel +kennely,kennerley +kenneth,ken +kenneth,keneth +kenneth,kenethe +kenneth,kenith +kenneth,kennith +kenneth,kenny +kirby,kirkby +klap,clap +klap,clapp +kohen,coen +kohen,cohen +kohen,cohn +koster,costa +koster,coster + +laco,olaco +langford,langsford +laslo,laszlo +laughton,lawton +leach,leitch +leary,oleary +lennox,leannox +lisle,lyal +lisle,lydall +lisle,lyle +lloyd,floyd +loan,oloan +lachlan,loughlin +lachlan,olachlan +lachlan,olaughlan +lachlan,ologhlin +lachlan,oloughlan +lynam,olynam +lyndon,lindon + +mace,maze +maddock,maddocks +maher,maier +maher,mayar +maher,meagher +maher,omeagher +mahon,mann +mahony,mahoney +mahony,omahoney +mahony,omahony +mai,may +malley,omalley +malley,omally +malley,omeley +mara,omara +mara,omeara +mara,omera +marsh,march +massey,massie +matheson,matherson +mavis,mab +mervyn,merv +mervyn,mervin +meyer,myer +miles,myles +millicent,mildred +millie,milli +millie,milly +mitchell,michaal +mitchell,michaele +mitchell,michaell +mitchell,micheal +mitchell,michell +mitchell,mick +mitchell,micky +mitchell,mikcos +mitchell,mike +mitchell,mitch +montague,monty +mosley,morsley +mullane,omullane + +nada,nadine +nains,onains +nevern,nevin +newbury,newby +norton,naughton +norton,naunton +nosworthy,norsworthy + +ogden,oddie +ogden,oddy + +panagiotis,panayotis +patterson,pattison +pearce,pearse +powers,powys +prendergast,pendergast +price,preiss +pritchard,prichard + +quinton,quentin + +raleigh,rawleigh +raleigh,rawley +raleigh,rowley +redman,redmond +reece,rees +regan,oregan +reilly,oreilly +reilly,orielly +reuben,rube +reuben,ruben +reynard,reyner +reynolds,reynol +reynolds,reynold +roach,roache +roach,roatch +roach,roche +robertson,roberson +robertson,robieson +robertson,robinson +roer,ruggiero +rogers,rodgers +rourke,orourke +ruthen,ruthven + +sampson,samson +sanderson,sandison +sandford,sanford +schultz,scholz +schultz,schulz +schultz,schulze +schultz,shultz +schultz,shultze +schwartz,schwarz +seaton,seton +shana,oshana +shana,oshanna +shannessy,oshanassy +shannessy,oshanesy +shannessy,oshannessy +shannessy,oshaughnessy +shea,oshae +shea,oshea +sheehy,osheehy +sheils,shields +sheils,shiels +shell,schell +simmons,simmins +simmons,simmonds +simmons,simons +simmons,symanns +simmons,symonds +slavomir,slawomir +solomon,sol +solomon,saul +spiro,spiros +staughton,staunton +stbaker,saintbaker +stclair,saintclair +stclair,saintclaire +stclair,saintclare +stclair,stclaire +stclair,stclare +stcloud,saintcloud +stdenis,saintdenis +stdenis,saintdennis +stdenis,stdennis +stephens,stevens +stgeorge,saintgeorge +stjack,saintjack +stjohn,saintjohn +stjohnwood,saintjohnwood +stjulian,saintjulian +stlaurence,saintlaurence +stleon,saintleon +sullivan,osullivan + +thompson,thomsen +thompson,thomson +toole,otoole + +vaughn,vaughan + +warner,warnie +weiner,wiener +weiner,wierner +weston,western +white,wight +whiteman,whitmann +whiteman,wightman +whitman,whit +wilmot,willmott +wiltshire,willshire +windsor,winsor + +young,oyoung + +zadie,zaidie +zbigneif,zbignev +zbigneif,zbignief +zbigneif,zbigniew +zdislaw,zdzislaw diff --git a/geco_data_generator/generator.py b/geco_data_generator/generator.py new file mode 100644 index 0000000000000000000000000000000000000000..402fa1ac8239b535c7b197f42c0e792c41f40841 --- /dev/null +++ b/geco_data_generator/generator.py @@ -0,0 +1,2067 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Main classes to generate records and the data set +import random + +from geco_data_generator import basefunctions + + +# ============================================================================= +# Classes for generating a single attribute (field) of the data set +# ============================================================================= + + +class GenerateAttribute: + """Base class for the definition of a single attribute (field) to be + generated. + + This class and all of its derived classes provide methods that allow the + definition of a single attribute and the parameters necessary for its + generation. + + The following variables need to be set when a GenerateAttribute instance + is initialised (with further parameters listed in the derived classes): + + attribute_name The name of this attribute, which will be used in the + header line to be written into the output file. + + Ideally, this attribute name should be short, not contain + spaces and it must not contain any quote or punctuation + characters. + """ + + # --------------------------------------------------------------------------- + + def __init__(self, base_kwargs): + """Constructor, set general attributes.""" + + # General attributes for all attribute generators + # + self.attribute_name = None + + # Process the keyword argument (all keywords specific to a certain data + # generator type were processed in the derived class constructor) + # + for (keyword, value) in base_kwargs.items(): + + if keyword.startswith('attribute'): + basefunctions.check_is_non_empty_string('attribute_name', value) + self.attribute_name = value + + else: + raise Exception( + 'Illegal constructor argument keyword: "%s"' % (str(keyword)) + ) + + basefunctions.check_is_non_empty_string('attribute_name', self.attribute_name) + + # Check the content of the attribute name string for certain characters + # that would pose problems when generating comma separated values (CSV) + # files. + # + if ( + ("'" in self.attribute_name) + or ('"' in self.attribute_name) + or ("`" in self.attribute_name) + or (',' in self.attribute_name) + or (";" in self.attribute_name) + or ('\t' in self.attribute_name) + ): + raise Exception( + 'Illegal character (such as comma, semi-colon or' + + 'quote in attribute name' + ) + + # --------------------------------------------------------------------------- + + def create_attribute_value(self): + """Method which creates and returns one attribute value. + See implementations in derived classes for details. + """ + + raise Exception('Override abstract method in derived class') + + +# ============================================================================= + + +class GenerateFreqAttribute(GenerateAttribute): + """Generate an attribute where values are retrieved from a lookup table that + contains categorical attribute values and their frequencies. + + The additional argument (besides the base class argument 'attribute_name') + that has to be set when this attribute type is initialised are: + + freq_file_name The name of the file which contains the attribute values + and their frequencies. + + This file must be in comma separated values (CSV) format + with the first column being the attribute values and the + second column their counts (positive integer numbers). + + Each attribute value must only occur once in the + frequency file. + + has_header_line A flag, set to True or False, that has to be set + according to if the frequency file starts with a header + line or not. + + unicode_encoding The Unicode encoding (a string name) of the file. + """ + + # --------------------------------------------------------------------------- + + def __init__(self, **kwargs): + """Constructor. Process the derived keywords first, then call the base + class constructor. + """ + + self.attribute_type = 'Frequency' + self.freq_file_name = None + self.has_header_line = None + self.unicode_encoding = None + self.attr_value_list = [] # The list of attribute values to be loaded + + # Process all keyword arguments + # + base_kwargs = {} # Dictionary, will contain unprocessed arguments + + for (keyword, value) in kwargs.items(): + + if keyword.startswith('freq'): + basefunctions.check_is_non_empty_string('freq_file_name', value) + self.freq_file_name = value + + elif keyword.startswith('has'): + basefunctions.check_is_flag('has_header_line', value) + self.has_header_line = value + + elif keyword.startswith('unicode'): + basefunctions.check_is_non_empty_string('unicode_encoding', value) + self.unicode_encoding = value + + else: + base_kwargs[keyword] = value + + GenerateAttribute.__init__(self, base_kwargs) # Process base arguments + + # Check if the necessary variables have been set + # + basefunctions.check_is_non_empty_string('freq_file_name', self.freq_file_name) + basefunctions.check_is_flag('has_header_line', self.has_header_line) + basefunctions.check_is_non_empty_string('unicode_encoding', self.unicode_encoding) + + # Load the frequency file - - - - - - - - - - - - - - - - - - - - - - - - + # + header_list, freq_file_data = basefunctions.read_csv_file( + self.freq_file_name, self.unicode_encoding, self.has_header_line + ) + + val_dict = {} # The attribute values to be loaded from file and their + # counts or frequencies + + # Process values from file and their frequencies + # + for line, rec_list in enumerate(freq_file_data): + if len(rec_list) != 2: + raise Exception( + 'Illegal format in frequency file %s: %s' % (self.freq_file_name, line) + ) + line_val = rec_list[0].strip() + try: + line_count = int(rec_list[1]) + except: + raise Exception( + 'Value count given is not an integer number: %s' % (rec_list[1]) + ) + + if line_val == '': + raise Exception( + 'Empty attribute value in frequency file %s' % (self.freq_file_name) + ) + basefunctions.check_is_positive('line_count', line_count) + + if line_val in val_dict: + raise Exception( + 'Attribute values "%s" occurs twice in ' % (line_val) + + 'frequency file %s' % (self.freq_file_name) + ) + + val_dict[line_val] = line_count + + val_list = [] # The list of attribute values, with values repeated + # according to their frequencies + + # Generate a list of values according to their counts + # + for (attr_val, val_count) in val_dict.items(): + + # Append value as many times as given in their counts + # + new_list = [attr_val] * val_count + val_list += new_list + + random.shuffle(val_list) # Randomly shuffle the list of values + + self.attr_value_list = val_list + + # --------------------------------------------------------------------------- + + def create_attribute_value(self): + """Method which creates and returns one attribute value randomly selected + from the attribute value lookup table. + """ + + assert self.attr_value_list != [] + + return random.choice(self.attr_value_list) + + +# ============================================================================= + + +class GenerateFuncAttribute(GenerateAttribute): + """Generate an attribute where values are retrieved from a function that + creates values according to some specification. + + Such functions include creating telephone numbers or social security + numbers with a certain structure, or numerical values normally or + uniformly distributed according to some parameter setting. + + The additional argument (besides the base class argument 'attribute_name') + that has to be set when this attribute type is initialised are: + + function A Python function that, when called, has to return a string + value that is created according to some specification. + + parameters A list of one or more parameters (maximum 5) passed to the + function when it is called. + """ + + # --------------------------------------------------------------------------- + + def __init__(self, **kwargs): + """Constructor. Process the derived keywords first, then call the base + class constructor. + """ + + self.attribute_type = 'Function' + self.function = None + self.parameters = None + + # Process all keyword arguments + # + base_kwargs = {} # Dictionary, will contain unprocessed arguments + + for (keyword, value) in kwargs.items(): + + if keyword.startswith('funct'): + basefunctions.check_is_function_or_method('function', value) + self.function = value + + elif keyword.startswith('para'): + basefunctions.check_is_list('parameters', value) + if len(value) > 5: + raise Exception('Maximum five parameters allowed for function call') + self.parameters = value + + else: + base_kwargs[keyword] = value + + GenerateAttribute.__init__(self, base_kwargs) # Process base arguments + + # Check if the necessary variables have been set + # + basefunctions.check_is_function_or_method('function', self.function) + + # Check if the function does return a string (five different possibilities, + # depending upon number of parameters) + # + if (self.parameters == None) or (len(self.parameters) == 0): + funct_ret = self.function() + elif len(self.parameters) == 1: + funct_ret = self.function(self.parameters[0]) + elif len(self.parameters) == 2: + funct_ret = self.function(self.parameters[0], self.parameters[1]) + elif len(self.parameters) == 3: + funct_ret = self.function( + self.parameters[0], self.parameters[1], self.parameters[2] + ) + elif len(self.parameters) == 4: + funct_ret = self.function( + self.parameters[0], + self.parameters[1], + self.parameters[2], + self.parameters[3], + ) + else: + funct_ret = self.function( + self.parameters[0], + self.parameters[1], + self.parameters[2], + self.parameters[3], + self.parameters[4], + ) + + if not isinstance(funct_ret, str): + raise Exception( + ( + 'Function provided does not return a string value:', + self.function, + type(funct_ret), + ) + ) + + # --------------------------------------------------------------------------- + + def create_attribute_value(self): + """Method which creates and returns one attribute value generated by the + function provided. + """ + + if self.parameters == None: + funct_ret = self.function() + elif len(self.parameters) == 1: + funct_ret = self.function(self.parameters[0]) + elif len(self.parameters) == 2: + funct_ret = self.function(self.parameters[0], self.parameters[1]) + elif len(self.parameters) == 3: + funct_ret = self.function( + self.parameters[0], self.parameters[1], self.parameters[2] + ) + elif len(self.parameters) == 4: + funct_ret = self.function( + self.parameters[0], + self.parameters[1], + self.parameters[2], + self.parameters[3], + ) + else: + funct_ret = self.function( + self.parameters[0], + self.parameters[1], + self.parameters[2], + self.parameters[3], + self.parameters[4], + ) + return funct_ret + + +# ============================================================================= +# Classes for generating compound attributes (fields) of the data set +# ============================================================================= + + +class GenerateCompoundAttribute: + """Base class for the definition of compound attributes (fields) to be + generated. + + This class and all of its derived classes provide methods that allow the + definition of several (are least two) attributes and the parameters + necessary for their generation. + + This base class does not have any generic variables that need to be set. + """ + + # --------------------------------------------------------------------------- + + def __init__(self, base_kwargs): + """Constructor. See implementations in derived classes for details.""" + + raise Exception('Override abstract method in derived class') + + # --------------------------------------------------------------------------- + + def create_attribute_value(self): + """Method which creates and returns several (compound) attribute values. + See implementations in derived classes for details. + """ + + raise Exception('Override abstract method in derived class') + + +# ============================================================================= + + +class GenerateCateCateCompoundAttribute(GenerateCompoundAttribute): + """Generate two attributes, both containing categorical values, where the + values of the second attribute depend upon the values in the first + attribute. + + This for example allows the modelling of: + - city location values that depend upon gender values, or + - medication name values that depend upon gender values. + + The arguments that have to be set when this attribute type is initialised + are: + + categorical1_attribute_name The name of the first categorical attribute + that will be generated. This name will be + used in the header line to be written into + the output file. + + categorical2_attribute_name The name of the second categorical attribute + that will be generated. This name will be + used in the header line to be written into + the output file. + + lookup_file_name Name of the file which contains the values of + the first categorical attribute, and for each + of these values the names of the categories + and their counts of the second categorical + attribute. This file format is further + explained below. + + has_header_line A flag, set to True or False, that has to be + set according to if the look-up file starts + with a header line or not. + + unicode_encoding The Unicode encoding (a string name) of the + file. + + The format of the look-up file is: + + # Comment lines start with the # character + cate_attr1_val,count,cate_attr2_val1,count1,cate_attr2_val2,count2, \ + cate_attr2_val3,count3,cate_attr2_val4,count4, ... + + The look-up file is a comma separated values (CSV) file which contains + two types of rows: + A) The first type of row contains the following columns: + 1) A categorical value. For all possible values of the first + categorical attribute, one row must be specified in this look-up + file. + 2) Count of this categorical value (a positive integer number). This + determines the likelihood of how often a certain categorical value + will be chosen. This count must be a positive integer number. + 3) The first categorical value of the second attribute. + 4) The count (positive integer number) of this first categorical + value. + 5) The second categorical value of the second attribute. + 6) The count of this second categorical value. + + ... + + X) A '\' character, which indicates that the following line (row) + contains further categorical values and their counts from the + second attribute. + + B) The second type of row contains the following columns: + 1) A categorical value of the second attribute. + 2) The count of this categorical value. + 3) Another categorical value of the second attribute. + 4) The count of this categorical value. + + ... + + Example: + male,60,canberra,7, \ + sydney,30,melbourne,45, \ + perth,18 + female,40,canberra,10,sydney,40, \ + melbourne,20,brisbane,30,hobart,5,\ + perth,20 + """ + + # --------------------------------------------------------------------------- + + def __init__(self, **kwargs): + """Constructor. Process the derived keywords first, then call the base + class constructor. + """ + + # General attributes for all data set generators + # + self.number_of_atttributes = 2 + self.attribute_type = 'Compound-Categorical-Categorical' + + for (keyword, value) in kwargs.items(): + + if keyword.startswith('categorical1'): + basefunctions.check_is_non_empty_string( + 'categorical1_attribute_name', value + ) + self.categorical1_attribute_name = value + + elif keyword.startswith('categorical2'): + basefunctions.check_is_non_empty_string( + 'categorical2_attribute_name', value + ) + self.categorical2_attribute_name = value + + elif keyword.startswith('look'): + basefunctions.check_is_non_empty_string('lookup_file_name', value) + self.lookup_file_name = value + + elif keyword.startswith('has'): + basefunctions.check_is_flag('has_header_line', value) + self.has_header_line = value + + elif keyword.startswith('unicode'): + basefunctions.check_is_non_empty_string('unicode_encoding', value) + self.unicode_encoding = value + + else: + raise ( + Exception, + 'Illegal constructor argument keyword: "%s"' % (str(keyword)), + ) + + # Check if the necessary variables have been set + # + basefunctions.check_is_non_empty_string( + 'categorical1_attribute_name', self.categorical1_attribute_name + ) + basefunctions.check_is_non_empty_string( + 'categorical2_attribute_name', self.categorical2_attribute_name + ) + basefunctions.check_is_non_empty_string('lookup_file_name', self.lookup_file_name) + basefunctions.check_is_flag('has_header_line', self.has_header_line) + basefunctions.check_is_non_empty_string('unicode_encoding', self.unicode_encoding) + + if self.categorical1_attribute_name == self.categorical2_attribute_name: + raise Exception('Both attribute names are the same') + + # Load the lookup file - - - - - - - - - - - - - - - - - - - - - - - - - - + # + header_list, lookup_file_data = basefunctions.read_csv_file( + self.lookup_file_name, self.unicode_encoding, self.has_header_line + ) + + cate_val1_dict = {} # The categorical values from attribute 1 to be loaded + # from file and their counts. + + cate_val2_dict = {} # The categorical values from attribute 1 to be loaded + # as keys and lists of categorical values (according + # to their counts) from attribute 2 as values. + + # Process attribute values from file and their details + # + i = 0 # Line counter in file data + + while i < len(lookup_file_data): + rec_list = lookup_file_data[i] + + # First line must contain categorical value of the first attribute + # + if len(rec_list) < 2: # Need at least two values in each line + raise Exception( + 'Illegal format in lookup file %s: %s' + % (self.freq_file_name, str(rec_list)) + ) + cate_attr1_val = rec_list[0].strip() + try: + cate_attr1_count = int(rec_list[1]) + except: + raise Exception( + 'Value count given for attribute 1 is not an ' + + 'integer number: %s' % (rec_list[1]) + ) + + if cate_attr1_val == '': + raise Exception( + 'Empty categorical attribute 1 value in lookup ' + + 'file %s' % (self.lookup_file_name) + ) + basefunctions.check_is_positive('cate_attr1_count', cate_attr1_count) + + if cate_attr1_val in cate_val1_dict: + raise Exception( + 'Attribute 1 value "%s" occurs twice in ' % (cate_attr1_val) + + 'lookup file %s' % (self.lookup_file_name) + ) + + cate_val1_dict[cate_attr1_val] = cate_attr1_count + + # Process values for second categorical attribute in this line + # + cate_attr2_data = rec_list[2:] # All values and counts of attribute 2 + + this_cate_val2_dict = {} # Values in second categorical attribute for + # this categorical value from first attribute + + while cate_attr2_data != []: + if len(cate_attr2_data) == 1: + if cate_attr2_data[0] != '\\': + raise Exception( + 'Line in categorical look-up file has illegal' + 'format.' + ) + # Get the next record from file data with a continuation of the + # categorical values from the second attribute + # + i += 1 + cate_attr2_data = lookup_file_data[i] + if len(cate_attr2_data) < 2: + raise Exception( + 'Illegal format in lookup file %s: %s' + % (self.freq_file_name, str(cate_attr2_data)) + ) + + cate_attr2_val = cate_attr2_data[0] + try: + cate_attr2_count = int(cate_attr2_data[1]) + except: + raise Exception( + 'Value count given for attribute 2 is not an ' + + 'integer number: %s' % (cate_attr2_data[1]) + ) + + if cate_attr2_val == '': + raise Exception( + 'Empty categorical attribute 2 value in lookup' + + ' file %s' % (self.lookup_file_name) + ) + basefunctions.check_is_positive('cate_attr2_count', cate_attr2_count) + + if cate_attr2_val in cate_val2_dict: + raise Exception( + 'Attribute 2 value "%s" occurs twice in ' % (cate_attr2_val) + + 'lookup file %s' % (self.lookup_file_name) + ) + + this_cate_val2_dict[cate_attr2_val] = cate_attr2_count + + cate_attr2_data = cate_attr2_data[2:] + + # Generate a list of values according to their counts + # + cate_attr2_val_list = [] + + for (cate_attr2_val, val2_count) in this_cate_val2_dict.items(): + + # Append value as many times as given in their counts + # + new_list = [cate_attr2_val] * val2_count + cate_attr2_val_list += new_list + + random.shuffle(cate_attr2_val_list) # Randomly shuffle the list of values + + cate_val2_dict[cate_attr1_val] = cate_attr2_val_list + + # Go to next line in file data + # + i += 1 + + # Generate a list of values according to their counts + # + cate_attr1_val_list = [] + + for (cate_attr1_val, val1_count) in cate_val1_dict.items(): + + # Append value as many times as given in their counts + # + new_list = [cate_attr1_val] * val1_count + cate_attr1_val_list += new_list + + random.shuffle(cate_attr1_val_list) # Randomly shuffle the list of values + + self.cate_attr1_val_list = cate_attr1_val_list + self.cate_val2_dict = cate_val2_dict + + # --------------------------------------------------------------------------- + + def create_attribute_values(self): + """Method which creates and returns two categorical attribute values, where + the second value depends upon the first value. Both categorical values + are randomly selected according to the provided frequency distributions. + """ + + assert self.cate_attr1_val_list != [] + assert self.cate_val2_dict != {} + + cate_attr1_val = random.choice(self.cate_attr1_val_list) + + cate_attr2_list = self.cate_val2_dict[cate_attr1_val] + + cate_attr2_val = random.choice(cate_attr2_list) + + return cate_attr1_val, cate_attr2_val + + +# ============================================================================= + + +class GenerateCateContCompoundAttribute(GenerateCompoundAttribute): + """Generate two attributes, one containing categorical values and the other + continuous values, where the continuous values depend upon the categorical + values. + + This for example allows the modelling of: + - salary values that depend upon gender values, or + - blood pressure values that depend upon age values. + + The arguments that have to be set when this attribute type is initialised + are: + + categorical_attribute_name The name of the categorical attribute that + will be generated. This name will be used in + the header line to be written into the output + file. + + continuous_attribute_name The name of the continuous attribute that will + be generated. This name will be used in the + header line to be written into the output + file. + + lookup_file_name Name of the file which contains the values of + the continuous attribute, and for each of these + values the name of a function (and its + parameters) that is used to generate the + continuous values. This file format is further + explained below. + + has_header_line A flag, set to True or False, that has to be + set according to if the look-up file starts + with a header line or not. + + unicode_encoding The Unicode encoding (a string name) of the + file. + + continuous_value_type The format of how continuous values are + returned when they are generated. Possible + values are 'int', so integer values are + returned; or 'float1', 'float2', to 'float9', + in which case floating-point values with the + specified number of digits behind the comma + are returned. + + The format of the look-up file is: + + # Comment lines start with the # character + cate_val,count,funct_name,funct_param_1,...,funct_param_N + + The look-up file is a comma separated values (CSV) file with the following + columns: + 1) A categorical value. For all possible categorical values of an + attribute, one row must be specified in this look-up file. + + 2) Count of this categorical value (a positive integer number). This + determines the likelihood of how often a certain categorical value will + be chosen. + + 3) A function which generates the continuous value for this categorical + value. Implemented functions currently are: + - uniform + - normal + + 4) The parameters required for the function that generates the continuous + values. They are: + - uniform: min_val, max_val + - normal: mu, sigma, min_val, max_val + (min_val and max_val can be set to None in which case no + minimum or maximum is enforced) + + Example: + male,60,uniform,20000,100000 + female,40,normal,35000,100000,10000,None + """ + + # --------------------------------------------------------------------------- + + def __init__(self, **kwargs): + """Constructor. Process the derived keywords first, then call the base + class constructor. + """ + + # General attributes for all data set generators + # + self.number_of_atttributes = 2 + self.attribute_type = 'Compound-Categorical-Continuous' + + for (keyword, value) in kwargs.items(): + + if keyword.startswith('cate'): + basefunctions.check_is_non_empty_string( + 'categorical_attribute_name', value + ) + self.categorical_attribute_name = value + + elif keyword.startswith('continuous_a'): + basefunctions.check_is_non_empty_string('continuous_attribute_name', value) + self.continuous_attribute_name = value + + elif keyword.startswith('continuous_v'): + basefunctions.check_is_non_empty_string('continuous_value_type', value) + basefunctions.check_is_valid_format_str('continuous_value_type', value) + self.continuous_value_type = value + + elif keyword.startswith('look'): + basefunctions.check_is_non_empty_string('lookup_file_name', value) + self.lookup_file_name = value + + elif keyword.startswith('has'): + basefunctions.check_is_flag('has_header_line', value) + self.has_header_line = value + + elif keyword.startswith('unicode'): + basefunctions.check_is_non_empty_string('unicode_encoding', value) + self.unicode_encoding = value + + else: + raise Exception( + 'Illegal constructor argument keyword: "%s"' % (str(keyword)) + ) + + # Check if the necessary variables have been set + # + basefunctions.check_is_non_empty_string( + 'categorical_attribute_name', self.categorical_attribute_name + ) + basefunctions.check_is_non_empty_string( + 'continuous_attribute_name', self.continuous_attribute_name + ) + basefunctions.check_is_non_empty_string('lookup_file_name', self.lookup_file_name) + basefunctions.check_is_flag('has_header_line', self.has_header_line) + basefunctions.check_is_non_empty_string('unicode_encoding', self.unicode_encoding) + + if self.categorical_attribute_name == self.continuous_attribute_name: + raise Exception('Both attribute names are the same') + + basefunctions.check_is_valid_format_str( + 'continuous_value_type', self.continuous_value_type + ) + + # Load the lookup file - - - - - - - - - - - - - - - - - - - - - - - - - - + # + header_list, lookup_file_data = basefunctions.read_csv_file( + self.lookup_file_name, self.unicode_encoding, self.has_header_line + ) + + cate_val_dict = {} # The categorical attribute values to be loaded from + # file and their counts. + cont_funct_dict = {} # For each categorical attribute value the details of + # the function used for the continuous attribute. + + # Process attribute values from file and their details + # + for rec_list in lookup_file_data: + if len(rec_list) not in [5, 7]: + raise Exception( + 'Illegal format in lookup file %s: %s' + % (self.lookup_file_name, str(rec_list)) + ) + cate_attr_val = rec_list[0].strip() + try: + cate_attr_count = int(rec_list[1]) + except: + raise Exception( + 'Value count given for categorical attribute is ' + + 'not an integer number: %s' % (rec_list[1]) + ) + cont_attr_funct = rec_list[2].strip() + + if cate_attr_val == '': + raise Exception( + 'Empty categorical attribute value in lookup file %s' + % (self.lookup_file_name) + ) + if cate_attr_count <= 0: + raise Exception( + 'Count given for categorical attribute is not ' + + 'positive for value "%s" in lookup ' % (cate_attr_val) + + 'file %s' % (self.lookup_file_name) + ) + + if cate_attr_val in cate_val_dict: + raise Exception( + 'Attribute values "%s" occurs twice in ' % (cate_attr_val) + + 'lookup file %s' % (self.lookup_file_name) + ) + + if cont_attr_funct not in ['uniform', 'normal']: + raise Exception( + 'Illegal continuous attribute function given: "%s"' % (cont_attr_funct) + + ' in lookup file %s' % (self.lookup_file_name) + ) + + cate_val_dict[cate_attr_val] = cate_attr_count + + # Get function parameters from file data + # + if cont_attr_funct == 'uniform': + cont_attr_funct_min_val = float(rec_list[3]) + basefunctions.check_is_number( + 'cont_attr_funct_min_val', cont_attr_funct_min_val + ) + + cont_attr_funct_max_val = float(rec_list[4]) + basefunctions.check_is_number( + 'cont_attr_funct_max_val', cont_attr_funct_max_val + ) + + cont_funct_dict[cate_attr_val] = [ + cont_attr_funct, + cont_attr_funct_min_val, + cont_attr_funct_max_val, + ] + + elif cont_attr_funct == 'normal': + cont_attr_funct_mu = float(rec_list[3]) + basefunctions.check_is_number('cont_attr_funct_mu', cont_attr_funct_mu) + + cont_attr_funct_sigma = float(rec_list[4]) + basefunctions.check_is_number( + 'cont_attr_funct_sigma', cont_attr_funct_sigma + ) + try: + cont_attr_funct_min_val = float(rec_list[5]) + except: + cont_attr_funct_min_val = None + if cont_attr_funct_min_val != None: + basefunctions.check_is_number( + 'cont_attr_funct_min_val', cont_attr_funct_min_val + ) + try: + cont_attr_funct_max_val = float(rec_list[6]) + except: + cont_attr_funct_max_val = None + if cont_attr_funct_max_val != None: + basefunctions.check_is_number( + 'cont_attr_funct_max_val', cont_attr_funct_max_val + ) + + cont_funct_dict[cate_attr_val] = [ + cont_attr_funct, + cont_attr_funct_mu, + cont_attr_funct_sigma, + cont_attr_funct_min_val, + cont_attr_funct_max_val, + ] + + # Generate a list of values according to their counts + # + cate_attr_val_list = [] + + for (cate_attr_val, val_count) in cate_val_dict.items(): + + # Append value as many times as given in their counts + # + new_list = [cate_attr_val] * val_count + cate_attr_val_list += new_list + + random.shuffle(cate_attr_val_list) # Randomly shuffle the list of values + + self.cate_attr_val_list = cate_attr_val_list + self.cont_funct_dict = cont_funct_dict + + # --------------------------------------------------------------------------- + + def create_attribute_values(self): + """Method which creates and returns two attribute values, one categorical + and one continuous, with the categorical value randomly selected + according to the provided frequency distribution, and the continuous + value according to the selected function and its parameters. + """ + + assert self.cate_attr_val_list != [] + + cate_attr_val = random.choice(self.cate_attr_val_list) + + # Get the details of the function and generate the continuous value + # + funct_details = self.cont_funct_dict[cate_attr_val] + funct_name = funct_details[0] + + if funct_name == 'uniform': + cont_attr_val = random.uniform(funct_details[1], funct_details[2]) + + elif funct_name == 'normal': + mu = funct_details[1] + sigma = funct_details[2] + min_val = funct_details[3] + max_val = funct_details[4] + in_range = False + + cont_attr_val = random.normalvariate(mu, sigma) + + while in_range == False: + if ((min_val != None) and (cont_attr_val < min_val)) or ( + (max_val != None) and (cont_attr_val > max_val) + ): + in_range = False + cont_attr_val = random.normalvariate(mu, sigma) + else: + in_range = True + + if min_val != None: + assert cont_attr_val >= min_val + if max_val != None: + assert cont_attr_val <= max_val + + else: + raise Exception(('Illegal continuous function given:', funct_name)) + + cont_attr_val_str = basefunctions.float_to_str( + cont_attr_val, self.continuous_value_type + ) + + return cate_attr_val, cont_attr_val_str + + +# ============================================================================= + + +class GenerateCateCateContCompoundAttribute(GenerateCompoundAttribute): + """Generate three attributes, thefirst two containing categorical values and + the third containing continuous values, where the values of the second + attribute depend upon the values in the first attribute, and the values + of the third attribute depend upon both the values of the first and second + attribute. + + This for example allows the modelling of: + - blood pressure depending upon gender and city of residence values, or + - salary depending upon gender and profession values. + + The arguments that have to be set when this attribute type is initialised + are: + + categorical1_attribute_name The name of the first categorical attribute + that will be generated. This name will be + used in the header line to be written into + the output file. + + categorical2_attribute_name The name of the second categorical attribute + that will be generated. This name will be + used in the header line to be written into + the output file. + + continuous_attribute_name The name of the continuous attribute that + will be generated. This name will be used in + the header line to be written into the output + file. + + lookup_file_name Name of the file which contains the values + of the first categorical attribute, and for + each of these values the names of the + categories and their counts of the second + categorical attribute, and for each of these + values the name of a function (and its + parameters) that is used to generate the + continuous values. This file format is + further explained below. + + has_header_line A flag, set to True or False, that has to be + set according to if the look-up file starts + with a header line or not. + + unicode_encoding The Unicode encoding (a string name) of the + file. + + continuous_value_type The format of how continuous values are + returned when they are generated. Possible + values are 'int', so integer values are + returned; or 'float1', 'float2', to + 'float9', in which case floating-point + values with the specified number of digits + behind the comma are returned. + + The format of the look-up file is: + + # Comment lines start with the # character + cate_attr1_val1,count + cate_attr2_val1,count,funct_name,funct_param_1,...,funct_param_N + cate_attr2_val2,count,funct_name,funct_param_1,...,funct_param_N + cate_attr2_val3,count,funct_name,funct_param_1,...,funct_param_N + ... + cate_attr2_valX,count,funct_name,funct_param_1,...,funct_param_N + cate_attr1_val2,count + cate_attr2_val1,count,funct_name,funct_param_1,...,funct_param_N + cate_attr2_val2,count,funct_name,funct_param_1,...,funct_param_N + cate_attr2_val3,count,funct_name,funct_param_1,...,funct_param_N + ... + cate_attr2_valX,count,funct_name,funct_param_1,...,funct_param_N + cate_attr1_val3,count + ... + + + The look-up file is a comma separated values (CSV) file with the following + structure: + + A) One row that contains two values: + 1) A categorical value of the first attribute. For all possible values + of the first categorical attribute, one row must be specified in + this look-up file. + 2) The count of this categorical value (a positive integer number). + This determines the likelihood of how often a certain categorical + value will be chosen. + + B) After a row with two values, as described under A), one or more rows + containing the following values in columns must be given: + 1) A categorical value from the second categorical attribute. + 2) The count of this categorical value (a positive integer number). + This determines the likelihood of how often a certain categorical + value will be chosen. + 3) A function which generates the continuous value for this categorical + value. Implemented functions currently are: + - uniform + - normal + 4) The parameters required for the function that generates the + continuous values. They are: + - uniform: min_val, max_val + - normal: mu, sigma, min_val, max_val + (min_val and max_val can be set to None in which case no + minimum or maximum is enforced) + + Example: + male,60 + canberra,20,uniform,50000,90000 + sydney,30,normal,75000,50000,20000,None + melbourne,30,uniform,35000,200000 + perth,20,normal,55000,250000,15000,None + female,40 + canberra,10,normal,45000,10000,None,150000 + sydney,40,uniform,60000,200000 + melbourne,20,uniform,50000,1750000 + brisbane,30,normal,55000,20000,20000,100000 + """ + + # --------------------------------------------------------------------------- + + def __init__(self, **kwargs): + """Constructor. Process the derived keywords first, then call the base + class constructor. + """ + + # General attributes for all data set generators + # + self.number_of_atttributes = 3 + self.attribute_type = 'Compound-Categorical-Categorical-Continuous' + + for (keyword, value) in kwargs.items(): + + if keyword.startswith('categorical1'): + basefunctions.check_is_non_empty_string( + 'categorical1_attribute_name', value + ) + self.categorical1_attribute_name = value + + elif keyword.startswith('categorical2'): + basefunctions.check_is_non_empty_string( + 'categorical2_attribute_name', value + ) + self.categorical2_attribute_name = value + + elif keyword.startswith('continuous_a'): + basefunctions.check_is_non_empty_string('continuous_attribute_name', value) + self.continuous_attribute_name = value + + elif keyword.startswith('continuous_v'): + basefunctions.check_is_non_empty_string('continuous_value_type', value) + basefunctions.check_is_valid_format_str('continuous_value_type', value) + self.continuous_value_type = value + + elif keyword.startswith('look'): + basefunctions.check_is_non_empty_string('lookup_file_name', value) + self.lookup_file_name = value + + elif keyword.startswith('has'): + basefunctions.check_is_flag('has_header_line', value) + self.has_header_line = value + + elif keyword.startswith('unicode'): + basefunctions.check_is_non_empty_string('unicode_encoding', value) + self.unicode_encoding = value + + else: + raise Exception( + 'Illegal constructor argument keyword: "%s"' % (str(keyword)) + ) + + # Check if the necessary variables have been set + # + basefunctions.check_is_non_empty_string( + 'categorical1_attribute_name', self.categorical1_attribute_name + ) + basefunctions.check_is_non_empty_string( + 'categorical2_attribute_name', self.categorical2_attribute_name + ) + basefunctions.check_is_non_empty_string( + 'continuous_attribute_name', self.continuous_attribute_name + ) + basefunctions.check_is_non_empty_string('lookup_file_name', self.lookup_file_name) + basefunctions.check_is_flag('has_header_line', self.has_header_line) + basefunctions.check_is_non_empty_string('unicode_encoding', self.unicode_encoding) + + if ( + (self.categorical1_attribute_name == self.categorical2_attribute_name) + or (self.categorical1_attribute_name == self.continuous_attribute_name) + or (self.categorical2_attribute_name == self.continuous_attribute_name) + ): + raise Exception('Not all attribute names are different.') + + basefunctions.check_is_valid_format_str( + 'continuous_value_type', self.continuous_value_type + ) + + # Load the lookup file - - - - - - - - - - - - - - - - - - - - - - - - - - + # + header_list, lookup_file_data = basefunctions.read_csv_file( + self.lookup_file_name, self.unicode_encoding, self.has_header_line + ) + + cate_val1_dict = {} # The categorical values from attribute 1 to be + # loaded from file, and their counts. + + cate_val2_dict = {} # The categorical values from attribute 1 as keys + # and lists of categorical values (according to their + # counts) from attribute 2 as values. + + cont_funct_dict = {} # For each pair of categorical attribute values the + # details of the function used for the continuous + # attribute. + + # Process attribute values from file and their details + # + list_counter = 0 # Counter in the list of lookup file data + num_file_rows = len(lookup_file_data) + rec_list = lookup_file_data[list_counter] + + while list_counter < num_file_rows: # Process one row after another + + if len(rec_list) < 2: # Need at least one categorical value and count + raise Exception( + 'Illegal format in lookup file %s: %s' + % (self.lookup_file_name, str(rec_list)) + ) + cate_attr1_val = rec_list[0].strip() + try: + cate_attr1_count = int(rec_list[1]) + except: + raise Exception( + 'Value count given for attribute 1 is not an ' + + 'integer number: %s' % (rec_list[1]) + ) + + if cate_attr1_val == '': + raise Exception( + 'Empty categorical attribute value 1 in lookup ' + + 'file %s' % (self.lookup_file_name) + ) + basefunctions.check_is_positive('cate_attr1_count', cate_attr1_count) + + if cate_attr1_val in cate_val1_dict: + raise Exception( + 'Attribute value "%s" occurs twice in ' % (cate_attr1_val) + + 'lookup file %s' % (self.lookup_file_name) + ) + + cate_val1_dict[cate_attr1_val] = cate_attr1_count + + # Loop to process values of the second categorical attribute and the + # corresponding continuous functions + # + list_counter += 1 + rec_list = lookup_file_data[list_counter] # Get values from next line + + this_cate_val2_dict = {} # Values of categorical attribute 2 + this_cont_funct_dict = {} + + # As long as there are data from the second categorical attribute + # + while len(rec_list) > 2: + cate_attr2_val = rec_list[0].strip() + try: + cate_attr2_count = int(rec_list[1]) + except: + raise Exception( + 'Value count given for categorical attribute 2 ' + + 'is not an integer number: %s' % (rec_list[1]) + ) + cont_attr_funct = rec_list[2].strip() + + if cate_attr2_val == '': + raise Exception( + 'Empty categorical attribute 2 value in lookup ' + + 'file %s' % (self.lookup_file_name) + ) + basefunctions.check_is_positive('cate_attr2_count', cate_attr2_count) + + if cate_attr2_val in this_cate_val2_dict: + raise Exception( + 'Attribute value "%s" occurs twice in ' % (cate_attr2_val) + + 'lookup file %s' % (self.lookup_file_name) + ) + + if cont_attr_funct not in ['uniform', 'normal']: + raise Exception( + 'Illegal continuous attribute function ' + + 'given: "%s"' % (cont_attr_funct) + + ' in lookup file %s' % (self.lookup_file_name) + ) + + this_cate_val2_dict[cate_attr2_val] = cate_attr2_count + + # Get function parameters from file data + # + if cont_attr_funct == 'uniform': + cont_attr_funct_min_val = float(rec_list[3]) + basefunctions.check_is_number( + 'cont_attr_funct_min_val', cont_attr_funct_min_val + ) + cont_attr_funct_max_val = float(rec_list[4]) + basefunctions.check_is_number( + 'cont_attr_funct_max_val', cont_attr_funct_max_val + ) + + this_cont_funct_dict[cate_attr2_val] = [ + cont_attr_funct, + cont_attr_funct_min_val, + cont_attr_funct_max_val, + ] + elif cont_attr_funct == 'normal': + cont_attr_funct_mu = float(rec_list[3]) + cont_attr_funct_sigma = float(rec_list[4]) + try: + cont_attr_funct_min_val = float(rec_list[5]) + except: + cont_attr_funct_min_val = None + if cont_attr_funct_min_val != None: + basefunctions.check_is_number( + 'cont_attr_funct_min_val', cont_attr_funct_min_val + ) + try: + cont_attr_funct_max_val = float(rec_list[6]) + except: + cont_attr_funct_max_val = None + if cont_attr_funct_max_val != None: + basefunctions.check_is_number( + 'cont_attr_funct_max_val', cont_attr_funct_max_val + ) + this_cont_funct_dict[cate_attr2_val] = [ + cont_attr_funct, + cont_attr_funct_mu, + cont_attr_funct_sigma, + cont_attr_funct_min_val, + cont_attr_funct_max_val, + ] + + list_counter += 1 + if list_counter < num_file_rows: + rec_list = lookup_file_data[list_counter] + else: + rec_list = [] + + # Generate a list of categorical 2 values according to their counts + # + cate_attr2_val_list = [] + + for (cate_attr2_val, val2_count) in this_cate_val2_dict.items(): + + # Append value as many times as given in their counts + # + new_list = [cate_attr2_val] * val2_count + cate_attr2_val_list += new_list + + random.shuffle(cate_attr2_val_list) # Randomly shuffle the list of values + + cate_val2_dict[cate_attr1_val] = cate_attr2_val_list + + # Store function data for each combination of categorial values + # + for cate_attr2_val in this_cont_funct_dict: + cont_dict_key = cate_attr1_val + '-' + cate_attr2_val + cont_funct_dict[cont_dict_key] = this_cont_funct_dict[cate_attr2_val] + + # Generate a list of values according to their counts for attribute 1 + # + cate_attr1_val_list = [] + + for (cate_attr1_val, val1_count) in cate_val1_dict.items(): + + # Append value as many times as given in their counts + # + new_list = [cate_attr1_val] * val1_count + cate_attr1_val_list += new_list + + random.shuffle(cate_attr1_val_list) # Randomly shuffle the list of values + + self.cate_attr1_val_list = cate_attr1_val_list + self.cate_val2_dict = cate_val2_dict + self.cont_funct_dict = cont_funct_dict + + # --------------------------------------------------------------------------- + + def create_attribute_values(self): + """Method which creates and returns two categorical attribute values and + one continuous value, where the second categorical value depends upon + the first value, andthe continuous value depends on both categorical + values. The two categorical values are randomly selected according to + the provided frequency distributions, while the continuous value is + generated according to the selected function and its parameters. + """ + + assert self.cate_attr1_val_list != [] + assert self.cate_val2_dict != {} + assert self.cont_funct_dict != {} + + cate_attr1_val = random.choice(self.cate_attr1_val_list) + + cate_attr2_list = self.cate_val2_dict[cate_attr1_val] + + cate_attr2_val = random.choice(cate_attr2_list) + + # Get the details of the function and generate the continuous value + # + cont_dict_key = cate_attr1_val + '-' + cate_attr2_val + funct_details = self.cont_funct_dict[cont_dict_key] + funct_name = funct_details[0] + + if funct_name == 'uniform': + cont_attr_val = random.uniform(funct_details[1], funct_details[2]) + + elif funct_name == 'normal': + mu = funct_details[1] + sigma = funct_details[2] + min_val = funct_details[3] + max_val = funct_details[4] + in_range = False + + cont_attr_val = random.normalvariate(mu, sigma) + + while in_range == False: + if ((min_val != None) and (cont_attr_val < min_val)) or ( + (max_val != None) and (cont_attr_val > max_val) + ): + in_range = False + cont_attr_val = random.normalvariate(mu, sigma) + else: + in_range = True + + if min_val != None: + assert cont_attr_val >= min_val + if max_val != None: + assert cont_attr_val <= max_val + + else: + raise Exception(('Illegal continuous function given:', funct_name)) + + cont_attr_val_str = basefunctions.float_to_str( + cont_attr_val, self.continuous_value_type + ) + + return cate_attr1_val, cate_attr2_val, cont_attr_val_str + + +# ============================================================================= + + +class GenerateContContCompoundAttribute(GenerateCompoundAttribute): + """Generate two continuous attribute values, where the value of the second + attribute depends upon the value of the first attribute. + + This for example allows the modelling of: + - salary values that depend upon age values, or + - blood pressure values that depend upon age values. + + The arguments that have to be set when this attribute type is initialised + are: + + continuous1_attribute_name The name of the first continuous attribute + that will be generated. This name will be + used in the header line to be written into + the output file. + + continuous2_attribute_name The name of the second continuous attribute + that will be generated. This name will be + used in the header line to be written into + the output file. + + continuous1_funct_name The name of the function that is used to + randomly generate the values of the first + attribute. Implemented functions currently + are: + - uniform + - normal + + continuous1_funct_param A list with the parameters required for the + function that generates the continuous values + in the first attribute. They are: + - uniform: [min_val, max_val] + - normal: [mu, sigma, min_val, max_val] + (min_val and max_val can be set + to None in which case no minimum + or maximum is enforced) + + continuous2_function A Python function that has a floating-point + value as input (assumed to be a value + generated for the first attribute) and that + returns a floating-point value (assumed to be + the value of the second attribute). + + continuous1_value_type The format of how the continuous values in + the first attribute are returned when they + are generated. Possible values are 'int', so + integer values are generated; or 'float1', + 'float2', to 'float9', in which case + floating-point values with the specified + number of digits behind the comma are + generated. + + continuous2_value_type The same as for the first attribute. + """ + + # --------------------------------------------------------------------------- + + def __init__(self, **kwargs): + """Constructor. Process the derived keywords first, then call the base + class constructor. + """ + + # General attributes for all data set generators + # + self.number_of_atttributes = 2 + self.attribute_type = 'Compound-Continuous-Continuous' + + for (keyword, value) in kwargs.items(): + + if keyword.startswith('continuous1_a'): + basefunctions.check_is_non_empty_string( + 'continuous1_attribute_name', value + ) + self.continuous1_attribute_name = value + + elif keyword.startswith('continuous2_a'): + basefunctions.check_is_non_empty_string( + 'continuous2_attribute_name', value + ) + self.continuous2_attribute_name = value + + elif keyword.startswith('continuous1_funct_n'): + basefunctions.check_is_non_empty_string('continuous1_funct_name', value) + self.continuous1_funct_name = value + + elif keyword.startswith('continuous1_funct_p'): + basefunctions.check_is_list('continuous1_funct_param', value) + self.continuous1_funct_param = value + + elif keyword.startswith('continuous2_f'): + basefunctions.check_is_function_or_method('continuous2_function', value) + self.continuous2_function = value + + elif keyword.startswith('continuous1_v'): + basefunctions.check_is_non_empty_string('continuous1_value_type', value) + basefunctions.check_is_valid_format_str('continuous1_value_type', value) + self.continuous1_value_type = value + + elif keyword.startswith('continuous2_v'): + basefunctions.check_is_non_empty_string('continuous2_value_type', value) + basefunctions.check_is_valid_format_str('continuous2_value_type', value) + self.continuous2_value_type = value + + else: + raise Exception( + 'Illegal constructor argument keyword: "%s"' % (str(keyword)) + ) + + # Check if the necessary variables have been set + # + basefunctions.check_is_non_empty_string( + 'continuous1_attribute_name', self.continuous1_attribute_name + ) + basefunctions.check_is_non_empty_string( + 'continuous2_attribute_name', self.continuous2_attribute_name + ) + basefunctions.check_is_non_empty_string( + 'continuous1_funct_name', self.continuous1_funct_name + ) + basefunctions.check_is_list( + 'continuous1_funct_param', self.continuous1_funct_param + ) + basefunctions.check_is_function_or_method( + 'continuous2_function', self.continuous2_function + ) + basefunctions.check_is_non_empty_string( + 'continuous1_value_type', self.continuous1_value_type + ) + basefunctions.check_is_non_empty_string( + 'continuous2_value_type', self.continuous2_value_type + ) + + if self.continuous1_attribute_name == self.continuous2_attribute_name: + raise Exception('Both attribute names are the same') + + basefunctions.check_is_valid_format_str( + 'continuous1_value_type', self.continuous1_value_type + ) + basefunctions.check_is_valid_format_str( + 'continuous2_value_type', self.continuous2_value_type + ) + + # Check that the function for attribute 2 does return a float value + # + funct_ret = self.continuous2_function(1.0) + if not isinstance(funct_ret, float): + raise Exception( + ( + 'Function provided for attribute 2 does not return' + + ' a floating-point value:', + type(funct_ret), + ) + ) + + # Check type and number of parameters given for attribute 1 functions + # + if self.continuous1_funct_name not in ['uniform', 'normal']: + raise Exception( + 'Illegal continuous attribute 1 function given: "%s"' + % (self.continuous1_funct_name) + ) + + # Get function parameters from file data + # + if self.continuous1_funct_name == 'uniform': + assert len(self.continuous1_funct_param) == 2 + + cont_attr1_funct_min_val = self.continuous1_funct_param[0] + cont_attr1_funct_max_val = self.continuous1_funct_param[1] + basefunctions.check_is_number( + 'cont_attr1_funct_min_val', cont_attr1_funct_min_val + ) + basefunctions.check_is_number( + 'cont_attr1_funct_max_val', cont_attr1_funct_max_val + ) + + assert cont_attr1_funct_min_val < cont_attr1_funct_max_val + + self.attr1_funct_param = [cont_attr1_funct_min_val, cont_attr1_funct_max_val] + + elif self.continuous1_funct_name == 'normal': + assert len(self.continuous1_funct_param) == 4 + + cont_attr1_funct_mu = self.continuous1_funct_param[0] + cont_attr1_funct_sigma = self.continuous1_funct_param[1] + cont_attr1_funct_min_val = self.continuous1_funct_param[2] + cont_attr1_funct_max_val = self.continuous1_funct_param[3] + + basefunctions.check_is_number('cont_attr1_funct_mu', cont_attr1_funct_mu) + basefunctions.check_is_number('cont_attr1_funct_sigma', cont_attr1_funct_sigma) + + basefunctions.check_is_positive( + 'cont_attr1_funct_sigma', cont_attr1_funct_sigma + ) + + if cont_attr1_funct_min_val != None: + basefunctions.check_is_number( + 'cont_attr1_funct_min_val', cont_attr1_funct_min_val + ) + assert cont_attr1_funct_min_val <= cont_attr1_funct_mu + + if cont_attr1_funct_max_val != None: + basefunctions.check_is_number( + 'cont_attr1_funct_max_val', cont_attr1_funct_max_val + ) + assert cont_attr1_funct_max_val >= cont_attr1_funct_mu + + if (cont_attr1_funct_min_val != None) and (cont_attr1_funct_max_val) != None: + assert cont_attr1_funct_min_val < cont_attr1_funct_max_val + + self.attr1_funct_param = [ + cont_attr1_funct_mu, + cont_attr1_funct_sigma, + cont_attr1_funct_min_val, + cont_attr1_funct_max_val, + ] + + # --------------------------------------------------------------------------- + + def create_attribute_values(self): + """Method which creates and returns two continuous attribute values, with + the the first continuous value according to the selected function and + its parameters, and the second value depending upon the first value. + """ + + # Get the details of the function and generate the first continuous value + # + funct_name = self.continuous1_funct_name + funct_details = self.attr1_funct_param + + if funct_name == 'uniform': + cont_attr1_val = random.uniform(funct_details[0], funct_details[1]) + + elif funct_name == 'normal': + mu = funct_details[0] + sigma = funct_details[1] + min_val = funct_details[2] + max_val = funct_details[3] + in_range = False + + cont_attr1_val = random.normalvariate(mu, sigma) + + while in_range == False: + if ((min_val != None) and (cont_attr1_val < min_val)) or ( + (max_val != None) and (cont_attr1_val > max_val) + ): + in_range = False + cont_attr1_val = random.normalvariate(mu, sigma) + else: + in_range = True + + if min_val != None: + assert cont_attr1_val >= min_val + if max_val != None: + assert cont_attr1_val <= max_val + + else: + raise Exception(('Illegal continuous function given:', funct_name)) + + # Generate the second attribute value + # + cont_attr2_val = self.continuous2_function(cont_attr1_val) + + cont_attr1_val_str = basefunctions.float_to_str( + cont_attr1_val, self.continuous1_value_type + ) + cont_attr2_val_str = basefunctions.float_to_str( + cont_attr2_val, self.continuous2_value_type + ) + + return cont_attr1_val_str, cont_attr2_val_str + + +# ============================================================================= +# Classes for generating a data set +# ============================================================================= + + +class GenerateDataSet: + """Base class for data set generation. + + This class and all of its derived classes provide methods that allow the + generation of a synthetic data set according to user specifications. + + The following arguments need to be set when a GenerateDataSet instance is + initialised: + + output_file_name The name of the file that will be generated. This + will be a comma separated values (CSV) file. If the + file name given does not end with the extension + '.csv' then this extension will be added. + + write_header_line A flag (True or false) indicating if a header line + with the attribute (field) names is to be written at + the beginning of the output file or not. The default + for this argument is True. + + rec_id_attr_name The name of the record identifier attribute. This + name must be different from the names of all other + generated attributes. Record identifiers will be + unique values for each generated record. + + number_of_records The number of records that are to be generated. This + will correspond to the number of 'original' records + that are generated. + + attribute_name_list The list of attributes (fields) that are to be + generated for each record, and the sequence how they + are to be written into the output file. Each element + in this list must be an attribute name. These names + will become the header line of the output file (if + a header line is to be written). + + attribute_data_list A list which contains the actual attribute objects + (from the classes GenerateAttribute and + GenerateCompoundAttribute and their respective + derived classes). + + unicode_encoding The Unicode encoding (a string name) of the file. + """ + + # --------------------------------------------------------------------------- + def __init__(self, **kwargs): + """Constructor, set general attributes.""" + + # General attributes for all data set generators + # + self.output_file_name = None + self.write_header_line = True + self.rec_id_attr_name = None + self.number_of_records = 0 + self.attribute_name_list = None + self.attribute_data_list = None + self.unicode_encoding = None + self.missing_val_str = '' + + # The following dictionary will contain the generated records, with the + # dictionary keys being the record identifiers (unique for each record), + # while the dictionary values will be lists containing the actual attribute + # values of these generated records. + # + self.rec_dict = {} + + for (keyword, value) in kwargs.items(): # Process keyword arguments + + if keyword.startswith('output'): + basefunctions.check_is_non_empty_string('output_file_name', value) + + # Make sure the file extension is correct + # + if value.endswith('.csv') == False: + value = value + '.csv' + self.output_file_name = value + + elif keyword.startswith('write'): + basefunctions.check_is_flag('write_header_line', value) + self.write_header_line = value + + elif keyword.startswith('rec'): + basefunctions.check_is_non_empty_string('rec_id_attr_name', value) + self.rec_id_attr_name = value + + elif keyword.startswith('number'): + basefunctions.check_is_integer('number_of_records', value) + basefunctions.check_is_positive('number_of_records', value) + self.number_of_records = value + + elif keyword.startswith('attribute_name'): + basefunctions.check_is_list('attribute_name_list', value) + if not value: + raise Exception('attribute_name_list is empty: %s' % (type(value))) + self.attribute_name_list = value + + elif keyword.startswith('attribute_data'): + basefunctions.check_is_list('attribute_data_list', value) + self.attribute_data_list = value + + elif keyword.startswith('unicode'): + basefunctions.check_unicode_encoding_exists(value) + self.unicode_encoding = value + + else: + raise Exception( + 'Illegal constructor argument keyword: "%s"' % (str(keyword)) + ) + + # Check if the necessary variables have been set + # + basefunctions.check_is_non_empty_string('output_file_name', self.output_file_name) + basefunctions.check_is_non_empty_string('rec_id_attr_name', self.rec_id_attr_name) + basefunctions.check_is_integer('number_of_records', self.number_of_records) + basefunctions.check_is_positive('number_of_records', self.number_of_records) + basefunctions.check_is_list('attribute_name_list', self.attribute_name_list) + basefunctions.check_is_list('attribute_data_list', self.attribute_data_list) + basefunctions.check_unicode_encoding_exists(self.unicode_encoding) + + # Remove potential duplicate entries in the attribute data list + # + attr_data_set = set() + new_attr_data_list = [] + for attr_data in self.attribute_data_list: + if attr_data not in attr_data_set: + attr_data_set.add(attr_data) + new_attr_data_list.append(attr_data) + self.attribute_data_list = new_attr_data_list + + # Check if the attributes listed in the attribute name list are all + # different, i.e. no attribute is listed twice, that their names are all + # different from the record identifier attribute name. + # + attr_name_set = set() + for attr_name in self.attribute_name_list: + if attr_name == self.rec_id_attr_name: + raise Exception( + 'Attribute given has the same name as the record ' + + 'identifier attribute' + ) + if attr_name in attr_name_set: + raise Exception('Attribute name "%s" is given twice' % (attr_name)) + attr_name_set.add(attr_name) + assert len(attr_name_set) == len(self.attribute_name_list) + + # Check if the attribute names listed in the attribute data list are all + # different, i.e. no attribute is listed twice, that their names are all + # different from the record identifier attribute name. + # + attr_name_set = set() + for attr_data in self.attribute_data_list: + + if attr_data.attribute_type == 'Compound-Categorical-Categorical': + attr1_name = attr_data.categorical1_attribute_name + attr2_name = attr_data.categorical2_attribute_name + attr3_name = '' + + elif attr_data.attribute_type == 'Compound-Categorical-Continuous': + attr1_name = attr_data.categorical_attribute_name + attr2_name = attr_data.continuous_attribute_name + attr3_name = '' + + elif attr_data.attribute_type == 'Compound-Continuous-Continuous': + attr1_name = attr_data.continuous1_attribute_name + attr2_name = attr_data.continuous2_attribute_name + attr3_name = '' + + elif attr_data.attribute_type == 'Compound-Categorical-Categorical-Continuous': + attr1_name = attr_data.categorical1_attribute_name + attr2_name = attr_data.categorical2_attribute_name + attr3_name = attr_data.continuous_attribute_name + + else: # A single attribute + attr1_name = attr_data.attribute_name + attr2_name = '' + attr3_name = '' + + for attr_name in [attr1_name, attr2_name, attr3_name]: + if attr_name != '': + if attr_name == self.rec_id_attr_name: + raise Exception( + 'Attribute given has the same name as the ' + + 'record identifier attribute' + ) + if attr_name in attr_name_set: + raise Exception( + 'Attribute name "%s" is given twice' % (attr_name) + + ' in attribute data definitions' + ) + attr_name_set.add(attr_name) + + # Check that there is an attribute definition provided for each attribute + # listed in the attribute name list. + # + for attr_name in self.attribute_name_list: + found_attr_name = False + for attr_data in self.attribute_data_list: + + # Get names from attribute data + # + if attr_data.attribute_type == 'Compound-Categorical-Categorical': + if (attr_name == attr_data.categorical1_attribute_name) or ( + attr_name == attr_data.categorical2_attribute_name + ): + found_attr_name = True + elif attr_data.attribute_type == 'Compound-Categorical-Continuous': + if (attr_name == attr_data.categorical_attribute_name) or ( + attr_name == attr_data.continuous_attribute_name + ): + found_attr_name = True + elif attr_data.attribute_type == 'Compound-Continuous-Continuous': + if (attr_name == attr_data.continuous1_attribute_name) or ( + attr_name == attr_data.continuous2_attribute_name + ): + found_attr_name = True + elif ( + attr_data.attribute_type + == 'Compound-Categorical-Categorical-Continuous' + ): + if ( + (attr_name == attr_data.categorical1_attribute_name) + or (attr_name == attr_data.categorical2_attribute_name) + or (attr_name == attr_data.continuous_attribute_name) + ): + found_attr_name = True + else: # A single attribute + if attr_name == attr_data.attribute_name: + found_attr_name = True + + if found_attr_name == False: + raise Exception( + 'No attribute data available for attribute "%s"' % (attr_name) + ) + + # --------------------------------------------------------------------------- + + def generate(self): + """Method which runs the generation process and generates the specified + number of records. + + This method return a list containing the 'number_of_records' generated + records, each being a dictionary with the keys being attribute names and + values the corresponding attribute values. + """ + + attr_name_list = self.attribute_name_list # Short-hands to increase speed + rec_dict = self.rec_dict + miss_val_str = self.missing_val_str + + num_rec_num_digit = len(str(self.number_of_records)) - 1 # For digit padding + + print() + print('Generate records with attributes:') + print(' ', attr_name_list) + print() + + for rec_id in range(self.number_of_records): + rec_id_str = 'rec-%s-org' % (str(rec_id).zfill(num_rec_num_digit)) + + this_rec_dict = {} # The generated attribute values (attribute names as + # keys, attribute values as values) + this_rec_list = [] # List of attribute values of the generated data set + + for attr_data in self.attribute_data_list: + + if attr_data.attribute_type == 'Compound-Categorical-Categorical': + attr1_name = attr_data.categorical1_attribute_name + attr2_name = attr_data.categorical2_attribute_name + attr1_val, attr2_val = attr_data.create_attribute_values() + this_rec_dict[attr1_name] = attr1_val + this_rec_dict[attr2_name] = attr2_val + + elif attr_data.attribute_type == 'Compound-Categorical-Continuous': + attr1_name = attr_data.categorical_attribute_name + attr2_name = attr_data.continuous_attribute_name + attr1_val, attr2_val = attr_data.create_attribute_values() + this_rec_dict[attr1_name] = attr1_val + this_rec_dict[attr2_name] = attr2_val + + elif attr_data.attribute_type == 'Compound-Continuous-Continuous': + attr1_name = attr_data.continuous1_attribute_name + attr2_name = attr_data.continuous2_attribute_name + attr1_val, attr2_val = attr_data.create_attribute_values() + this_rec_dict[attr1_name] = attr1_val + this_rec_dict[attr2_name] = attr2_val + + elif ( + attr_data.attribute_type + == 'Compound-Categorical-Categorical-Continuous' + ): + attr1_name = attr_data.categorical1_attribute_name + attr2_name = attr_data.categorical2_attribute_name + attr3_name = attr_data.continuous_attribute_name + attr1_val, attr2_val, attr3_val = attr_data.create_attribute_values() + this_rec_dict[attr1_name] = attr1_val + this_rec_dict[attr2_name] = attr2_val + this_rec_dict[attr3_name] = attr3_val + + else: # A single attribute + attr_name = attr_data.attribute_name + attr_val = attr_data.create_attribute_value() + this_rec_dict[attr_name] = attr_val + + # Compile output record + # + for attr_name in attr_name_list: + attr_val = this_rec_dict.get(attr_name, miss_val_str) + assert isinstance(attr_val, str), attr_val + this_rec_list.append(attr_val) + + rec_dict[rec_id_str] = this_rec_list + + print('Generated record with ID: %s' % (rec_id_str)) + print(' %s' % (str(this_rec_list))) + print() + + print('Generated %d records' % (self.number_of_records)) + print() + print('------------------------------------------------------------------') + print() + + return rec_dict + + # --------------------------------------------------------------------------- + + def write(self): + """Write the generated records into the defined output file.""" + + rec_id_list = list(self.rec_dict.keys()) + rec_id_list.sort() + + # Convert record dictionary into a list, with record identifier added + # + rec_list = [] + + for rec_id in rec_id_list: + this_rec_list = [rec_id] + self.rec_dict[rec_id] + rec_list.append(this_rec_list) + + header_list = [self.rec_id_attr_name] + self.attribute_name_list + basefunctions.write_csv_file( + self.output_file_name, self.unicode_encoding, header_list, rec_list + ) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000000000000000000000000000000000000..887c9831cc8eb3d7151c96ef1b389f8435b84036 --- /dev/null +++ b/setup.py @@ -0,0 +1,36 @@ +import pathlib +from setuptools import setup, find_packages + +HERE = pathlib.Path(__file__).parent +README = (HERE / 'README.md').read_text() + + +def read_requirements(reqs_path): + with open(reqs_path, encoding='utf8') as f: + reqs = [ + line.strip() + for line in f + if not line.strip().startswith('#') and not line.strip().startswith('--') + ] + return reqs + + +setup( + name="geco_data_generator", + version="0.0.1", + description="kg-geco_data_generator", + long_description=README, + long_description_content_type='text/markdown', + url='https://dmm.anu.edu.au/geco/', + author='', + author_email='', + python_requires='>=3.7', + classifiers=[ + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.7', + 'Topic :: Scientific/Engineering', + ], + packages=find_packages(exclude=['tests*', 'scripts', 'utils']), + include_package_data=True, + install_requires=read_requirements(HERE / 'requirements.txt'), +) diff --git a/tests/attrgenfunct_test.py b/tests/attrgenfunct_test.py new file mode 100644 index 0000000000000000000000000000000000000000..faa85b3efb4c13f62ddd7e8cd2e553b27fef9602 --- /dev/null +++ b/tests/attrgenfunct_test.py @@ -0,0 +1,922 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +import os +import random +import time +import unittest + +from geco_data_generator import attrgenfunct + +random.seed(42) + +# Define the number of tests to be done for the functionality tests +num_tests = 10000 + +# Define argument test cases here +test_argument_data_dict = { + ('attrgenfunct', 'n/a', 'generate_uniform_value'): { + 'min_val': [ + [ + [-10, 10, 'int'], + [10, 110, 'float1'], + [1110.0, 11011.9, 'float2'], + [-1110.0, -11.9, 'float9'], + [-51110, 1247, 'float7'], + ], + [ + ['-10', 10, 'int'], + [None, 10, 'float1'], + [{}, 11011.9, 'float2'], + ["-1110.0", -11.9, 'float9'], + ['int', 1247, 'float7'], + ], + ], + 'max_val': [ + [ + [-10, 10, 'int'], + [10, 110, 'float1'], + [1110.0, 11011.9, 'float2'], + [-1110.0, -11.9, 'float9'], + [-51110, 1247, 'float7'], + ], + [ + [-10, '10', 'int'], + [10, None, 'float1'], + [1110.0, {}, 'float2'], + [-1110.0, "-11.9", 'float9'], + [-51110, 'int', 'float7'], + ], + ], + 'val_type': [ + [ + [-10, 10, 'int'], + [10, 110, 'float1'], + [1110.0, 11011.9, 'float2'], + [1.0, 9.9, 'float3'], + [1.0, 2.9, 'float4'], + [1.0, 11.9, 'float5'], + [1.0, 9.9, 'float6'], + [1.0, 2.9, 'float7'], + [1.0, 11.9, 'float8'], + [-1110.0, -11.9, 'float9'], + ], + [ + [-10, 10, 'int2'], + [10, 110, 'float0'], + [1110.0, 11011.9, 'float-'], + [1.0, 9.9, 'test'], + [1.0, 2.9, {}], + [1.0, 11.9, ''], + [1.0, 9.9, 42], + [1.0, 2.9, -42.42], + [1.0, 11.9, []], + ], + ], + }, + # + ('attrgenfunct', 'n/a', 'generate_uniform_age'): { + 'min_val': [ + [[0, 120], [10, 100], [25.0, 76.9], [55, 56], [55.0, 57.9]], + [[-1, 120], [210, 100], ['25.0', 76.9], [{}, 56], [-55.0, 57.9]], + ], + 'max_val': [ + [[0, 120], [10, 100], [25.0, 76.9], [55, 56], [55.0, 57.9]], + [[0, 140], [10, -100], [25.0, '76.9'], [55, {}], [55.0, -57.9]], + ], + }, + # + ('attrgenfunct', 'n/a', 'generate_normal_value'): { + 'mu': [ + [ + [1.0, 1.0, -10, 10, 'int'], + [-5, 25, -10, 110, 'float1'], + [100.42, 2000, -1110.0, 11011.9, 'float2'], + [24.24, 5.5, None, 30.0, 'float9'], + [24.24, 5.5, 10.0, None, 'float7'], + ], + [ + ['1.0', 1.0, -10, 10, 'int'], + [-55, 25, -10, 110, 'float1'], + [255, 25, -10, 110, 'float1'], + [None, 2000, -1110.0, 11011.9, 'float2'], + [[], 5.5, None, 30.0, 'float9'], + [{}, 5.5, 10.0, None, 'float7'], + ], + ], + 'sigma': [ + [ + [1.0, 1.0, -10, 10, 'int'], + [-5, 25, -10, 110, 'float1'], + [100.42, 2000, -1110.0, 11011.9, 'float2'], + [24.24, 5.5, None, 30.0, 'float9'], + [24.24, 5.5, 10.0, None, 'float7'], + ], + [ + [1.0, '1.0', -10, 10, 'int'], + [-5, -25, -10, 110, 'float1'], + [100.42, None, -1110.0, 11011.9, 'float2'], + [24.24, {}, None, 30.0, 'float9'], + [24.24, [], 10.0, None, 'float7'], + ], + ], + 'min_val': [ + [ + [1.0, 1.0, -10, 10, 'int'], + [-5, 25, -10, 110, 'float1'], + [100.42, 2000, -1110.0, 11011.9, 'float2'], + [24.24, 5.5, None, 30.0, 'float9'], + [24.24, 5.5, 10.0, None, 'float7'], + ], + [ + [1.0, 1.0, '-10', 10, 'int'], + [-5, 25, 120, 110, 'float1'], + [100.42, 2000, {}, 11011.9, 'float2'], + [24.24, 5.5, 'None', 30.0, 'float9'], + [24.24, 5.5, 120.0, None, 'float7'], + ], + ], + 'max_val': [ + [ + [1.0, 1.0, -10, 10, 'int'], + [-5, 25, -10, 110, 'float1'], + [100.42, 2000, -1110.0, 11011.9, 'float2'], + [24.24, 5.5, None, 30.0, 'float9'], + [24.24, 5.5, 10.0, None, 'float7'], + ], + [ + [1.0, 1.0, -10, '10', 'int'], + [-5, 25, -10, -110, 'float1'], + [100.42, 2000, -1110.0, {}, 'float2'], + [24.24, 5.5, None, -30.0, 'float9'], + [24.24, 5.5, 10.0, [], 'float7'], + ], + ], + 'val_type': [ + [ + [1.0, 1.0, -10, 10, 'int'], + [-5, 25, -10, 110, 'float1'], + [100.42, 2000, -1110.0, 11011.9, 'float2'], + [24.24, 5.5, None, 30.0, 'float9'], + [24.24, 5.5, 10.0, None, 'float7'], + ], + [ + [1.0, 1.0, -10, 10, 'int2'], + [-5, 25, -10, 110, 'float21'], + [100.42, 2000, -1110.0, 11011.9, None], + [24.24, 5.5, None, 30.0, 42.42], + [24.24, 5.5, 10.0, None, {}], + ], + ], + }, + # + ('attrgenfunct', 'n/a', 'generate_normal_age'): { + 'mu': [ + [ + [51.0, 1.0, 0, 110], + [45, 25, 4, 110], + [50.42, 50, 5, 77], + [24.24, 5.5, 1, 50.0], + [24.24, 5.5, 10.0, 99], + ], + [ + ['51.0', 1.0, 0, 110], + [-45, 25, 4, 110], + [223, 25, 4, 110], + [None, 50, 5, 77], + [30, 20, 40, 110], + [70, 20, 10, 60], + [{}, 5.5, 1, 50.0], + ['', 5.5, 10.0, 99], + ], + ], + 'sigma': [ + [ + [51.0, 1.0, 0, 110], + [45, 25, 4, 110], + [50.42, 50, 5, 77], + [24.24, 5.5, 1, 50.0], + [24.24, 5.5, 10.0, 99], + ], + [ + [51.0, -1.0, 0, 110], + [45, '25', 4, 110], + [50.42, None, 5, 77], + [24.24, {}, 1, 50.0], + [24.24, [], 10.0, 99], + ], + ], + 'min_val': [ + [ + [51.0, 1.0, 0, 110], + [45, 25, 4, 110], + [50.42, 50, 5, 77], + [24.24, 5.5, 1, 50.0], + [24.24, 5.5, 10.0, 99], + ], + [ + [51.0, 1.0, -10, 110], + [45, 25, 134, 110], + [50.42, 50, 'None', 77], + [24.24, 5.5, {}, 50.0], + [24.24, 5.5, [], 99], + ], + ], + 'max_val': [ + [ + [51.0, 1.0, 0, 110], + [45, 25, 4, 110], + [50.42, 50, 5, 77], + [24.24, 5.5, 1, 50.0], + [24.24, 5.5, 10.0, 99], + ], + [ + [51.0, 1.0, 0, '110'], + [45, 25, 4, -110], + [50.42, 50, 5, 'None'], + [24.24, 5.5, 1, {}], + [24.24, 5.5, 10.0, []], + ], + ], + }, + # add tests for generate_normal_value, generate_normal_age +} + +# ============================================================================= + + +class TestCase(unittest.TestCase): + + # Initialise test case - - - - - - - - - - - - - - - - - - - - - - - - - - - + # + def setUp(self): + pass # Nothing to initialize + + # Clean up test case - - - - - - - - - - - - - - - - - - - - - - - - - - - - + # + def tearDown(self): + pass # Nothing to clean up + + # --------------------------------------------------------------------------- + # Start test cases + + def testArguments(self, test_data): + """Test if a function or method can be called or initialised correctly with + different values for their input arguments (parameters). + + The argument 'test_data' must be a dictionary with the following + structure: + + - Keys are tuples consisting of three strings: + (module_name, class_name, function_or_method_name) + - Values are dictionaries where the keys are the names of the input + argument that is being tested, and the values of these dictionaries + are a list that contains two lists. The first list contains valid + input arguments ('normal' argument tests) that should pass the test, + while the second list contains illegal input arguments ('exception' + argument tests) that should raise an exception. + + The lists of test cases are itself lists, each containing a number of + input argument values, as many as are expected by the function or + method that is being tested. + + This function returns a list containing the test results, where each + list element is a string with comma separated values (CSV) which are to + be written into the testing log file. + """ + + test_res_list = [] # The test results, one element per element in the test + # data dictionary + + for (test_method_names, test_method_data) in test_data.iteritems(): + test_method_name = test_method_names[2] + print('Testing arguments for method/function:', test_method_name) + + for argument_name in test_method_data: + print(' Testing input argument:', argument_name) + + norm_test_data = test_method_data[argument_name][0] + exce_test_data = test_method_data[argument_name][1] + print(' Normal test cases: ', norm_test_data) + print(' Exception test cases:', exce_test_data) + + # Conduct normal tests - - - - - - - - - - - - - - - - - - - - - - - - + # + num_norm_test_cases = len(norm_test_data) + num_norm_test_passed = 0 + num_norm_test_failed = 0 + norm_failed_desc_str = '' + + for test_input in norm_test_data: + passed = True # Assume the test will pass :-) + + if len(test_input) == 0: # Method has no input argument + try: + getattr(attrgenfunct, test_method_name)() + except: + passed = False + + elif len(test_input) == 1: # Method has one input argument + try: + getattr(attrgenfunct, test_method_name)(test_input[0]) + except: + passed = False + + elif len(test_input) == 2: # Method has two input arguments + try: + getattr(attrgenfunct, test_method_name)( + test_input[0], test_input[1] + ) + except: + passed = False + + elif len(test_input) == 3: # Method has three input arguments + try: + getattr(attrgenfunct, test_method_name)( + test_input[0], test_input[1], test_input[2] + ) + except: + passed = False + + elif len(test_input) == 4: # Method has four input arguments + try: + getattr(attrgenfunct, test_method_name)( + test_input[0], test_input[1], test_input[2], test_input[3] + ) + except: + passed = False + + elif len(test_input) == 5: # Method has five input arguments + try: + getattr(attrgenfunct, test_method_name)( + test_input[0], + test_input[1], + test_input[2], + test_input[3], + test_input[4], + ) + except: + passed = False + + else: + raise Exception('Illegal number of input arguments') + + # Now process test results + # + if passed == False: + num_norm_test_failed += 1 + norm_failed_desc_str += 'Failed test for input ' + "'%s'; " % ( + str(test_input) + ) + else: + num_norm_test_passed += 1 + + assert num_norm_test_failed + num_norm_test_passed == num_norm_test_cases + + norm_test_result_str = ( + test_method_names[0] + + ',' + + test_method_names[1] + + ',' + + test_method_names[2] + + ',' + + argument_name + + ',normal,' + + '%d,' % (num_norm_test_cases) + ) + if num_norm_test_failed == 0: + norm_test_result_str += 'all tests passed' + else: + norm_test_result_str += '%d tests failed,' % (num_norm_test_failed) + norm_test_result_str += '"' + norm_failed_desc_str[:-2] + '"' + + test_res_list.append(norm_test_result_str) + + # Conduct exception tests - - - - - - - - - - - - - - - - - - - - - - - + # + num_exce_test_cases = len(exce_test_data) + num_exce_test_passed = 0 + num_exce_test_failed = 0 + exce_failed_desc_str = '' + + for test_input in exce_test_data: + passed = True # Assume the test will pass (i.e. raise an exception) + + if len(test_input) == 0: # Method has no input argument + try: + self.assertRaises( + Exception, getattr(attrgenfunct, test_method_name) + ) + except: + passed = False + + elif len(test_input) == 1: # Method has one input argument + try: + self.assertRaises( + Exception, + getattr(attrgenfunct, test_method_name), + test_input[0], + ) + except: + passed = False + + elif len(test_input) == 2: # Method has two input arguments + try: + self.assertRaises( + Exception, + getattr(attrgenfunct, test_method_name), + test_input[0], + test_input[1], + ) + except: + passed = False + + elif len(test_input) == 3: # Method has three input arguments + try: + self.assertRaises( + Exception, + getattr(attrgenfunct, test_method_name), + test_input[0], + test_input[1], + test_input[2], + ) + except: + passed = False + + elif len(test_input) == 4: # Method has four input arguments + try: + self.assertRaises( + Exception, + getattr(attrgenfunct, test_method_name), + test_input[0], + test_input[1], + test_input[2], + test_input[3], + ) + except: + passed = False + + elif len(test_input) == 5: # Method has five input arguments + try: + self.assertRaises( + Exception, + getattr(attrgenfunct, test_method_name), + test_input[0], + test_input[1], + test_input[2], + test_input[3], + test_input[4], + ) + except: + passed = False + + else: + raise Exception('Illegal number of input arguments') + + # Now process test results + # + if passed == False: + num_exce_test_failed += 1 + exce_failed_desc_str += 'Failed test for input ' + "'%s'; " % ( + str(test_input) + ) + else: + num_exce_test_passed += 1 + + assert num_exce_test_failed + num_exce_test_passed == num_exce_test_cases + + exce_test_result_str = ( + test_method_names[0] + + ',' + + test_method_names[1] + + ',' + + test_method_names[2] + + ',' + + argument_name + + ',exception,' + + '%d,' % (num_exce_test_cases) + ) + if num_exce_test_failed == 0: + exce_test_result_str += 'all tests passed' + else: + exce_test_result_str += '%d tests failed,' % (num_exce_test_failed) + exce_test_result_str += '"' + exce_failed_desc_str[:-2] + '"' + + test_res_list.append(exce_test_result_str) + + test_res_list.append('') # Empty line between tests of methods + + return test_res_list + + # --------------------------------------------------------------------------- + + def testFunct_generate_phone_number_australia(self, num_tests): + """Test the functionality of 'generate_phone_number_australia', making + sure this function returns strings of consisting only of digits, with + the first digit being 0, and two whitespaces at specific positions. + """ + + print('Testing functionality of "generate_phone_number_australia"') + + num_passed = 0 + num_failed = 0 + + for i in range(num_tests): + + oz_phone_num = attrgenfunct.generate_phone_number_australia() + + passed = True + + if len(oz_phone_num) != 12: + passed = False + if oz_phone_num[0] != '0': + passed = False + if oz_phone_num[2] != ' ': + passed = False + if oz_phone_num[7] != ' ': + passed = False + oz_phone_num_no_space = oz_phone_num.replace(' ', '') # Remove spaces + if not oz_phone_num_no_space.isdigit(): + passed = False + + if passed == True: + num_passed += 1 + else: + num_failed += 1 + + assert num_passed + num_failed == num_tests + + test_result_str = ( + 'attrgenfunct,n/a,generate_phone_number_australia,' + + 'n/a,funct,%d,' % (num_tests) + ) + if num_failed == 0: + test_result_str += 'all tests passed' + else: + test_result_str += '%d tests failed' % (num_failed) + + return [test_result_str, ''] + + # --------------------------------------------------------------------------- + + def testFunct_generate_credit_card_number(self, num_tests): + """Test the functionality of 'generate_credit_card_number', making sure + this function returns strings of consisting only of four groups of + digits, eac hwith 4 digits, and three whitespaces at specific positions. + """ + + print('Testing functionality of "generate_credit_card_number"') + + num_passed = 0 + num_failed = 0 + + for i in range(num_tests): + + cc_num = attrgenfunct.generate_credit_card_number() + + passed = True + + if len(cc_num) != 19: + passed = False + if cc_num[4] != ' ': + passed = False + if cc_num[9] != ' ': + passed = False + if cc_num[14] != ' ': + passed = False + cc_num_no_space = cc_num.replace(' ', '') # Remove spaces + if not cc_num_no_space.isdigit(): + passed = False + + if passed == True: + num_passed += 1 + else: + num_failed += 1 + + assert num_passed + num_failed == num_tests + + test_result_str = ( + 'attrgenfunct,n/a,generate_credit_card_number,' + 'n/a,funct,%d,' % (num_tests) + ) + if num_failed == 0: + test_result_str += 'all tests passed' + else: + test_result_str += '%d tests failed' % (num_failed) + + return [test_result_str, ''] + + # --------------------------------------------------------------------------- + + def testFunct_generate_uniform_value(self, num_tests): + """Test the functionality of 'generate_uniform_value', making sure + this function returns a string according to the given value type in + the range between the minimum and maximum value specified. + """ + + print('Testing functionality of "generate_uniform_value"') + + num_passed = 0 + num_failed = 0 + + for i in range(num_tests): + + for val_type in [ + 'int', + 'float1', + 'float2', + 'float3', + 'float4', + 'float5', + 'float6', + 'float7', + 'float8', + 'float9', + ]: + + for min_val in [-100.0, -42, 0, 10, 100.0]: + for max_val in [200.0, 242, 10000.01]: + + norm_val = attrgenfunct.generate_uniform_value( + min_val, max_val, val_type + ) + passed = True + + if float(norm_val) < min_val: + passed = False + if float(norm_val) > max_val: + passed = False + if (val_type == 'int') and ('.' in norm_val): + passed = False + if val_type != 'int': + num_digit = int(val_type[-1]) + norm_val_list = norm_val.split('.') + if len(norm_val_list[1]) > num_digit: + passed = ( + False # Only larger, because for example 100.0 will + ) + # only return with 1 digit after comma + + if passed == True: + num_passed += 1 + else: + num_failed += 1 + + assert num_passed + num_failed == (15 * 10 * num_tests) + + test_result_str = 'attrgenfunct,n/a,generate_uniform_value,' + 'n/a,funct,%d,' % ( + 15 * 10 * num_tests + ) + if num_failed == 0: + test_result_str += 'all tests passed' + else: + test_result_str += '%d tests failed' % (num_failed) + + return [test_result_str, ''] + + # --------------------------------------------------------------------------- + + def testFunct_generate_uniform_age(self, num_tests): + """Test the functionality of 'generate_uniform_age', making sure this + function returns a string with an integer value between 0 and 130. + """ + + print('Testing functionality of "generate_uniform_age"') + + num_passed = 0 + num_failed = 0 + + for i in range(num_tests): + + for (min_val, max_val) in [(0, 10), (0, 120), (0, 45), (42, 48), (40, 120)]: + + age_val = attrgenfunct.generate_uniform_age(min_val, max_val) + + passed = True + + if float(age_val) < min_val: + passed = False + if float(age_val) > max_val: + passed = False + if '.' in age_val: + passed = False + + if passed == True: + num_passed += 1 + else: + num_failed += 1 + + assert num_passed + num_failed == num_tests * 5 + + test_result_str = 'attrgenfunct,n/a,generate_uniform_age,' + 'n/a,funct,%d,' % ( + num_tests * 5 + ) + if num_failed == 0: + test_result_str += 'all tests passed' + else: + test_result_str += '%d tests failed' % (num_failed) + + return [test_result_str, ''] + + # --------------------------------------------------------------------------- + + def testFunct_generate_normal_value(self, num_tests): + """Test the functionality of 'generate_normal_value', making sure this + function returns a string according to the given value type in the + range between the minimum and maximum value specified. + """ + + print('Testing functionality of "generate_normal_value"') + + num_passed = 0 + num_failed = 0 + + for i in range(num_tests): + + for val_type in [ + 'int', + 'float1', + 'float2', + 'float3', + 'float4', + 'float5', + 'float6', + 'float7', + 'float8', + 'float9', + ]: + + for (mu, sigma, min_val, max_val) in [ + (0, 1, -10, 10), + (0, 1, -1, 1), + (-100.5, 123.45, -1010.7, -10.11), + (12345.87, 54875.1, -400532, 96344), + (0, 1, None, 10), + (0, 1, None, 1), + (-100.5, 123.45, None, -10.11), + (12345.87, 54875.1, None, 96344), + (0, 1, -10, None), + (0, 1, -1, None), + (-100.5, 123.45, -1010.7, None), + (12345.87, 54875.1, -400532, None), + (0, 1, None, None), + (0, 1, None, None), + (-100.5, 123.45, None, None), + (12345.87, 54875.1, None, None), + ]: + + norm_val = attrgenfunct.generate_normal_value( + mu, sigma, min_val, max_val, val_type + ) + passed = True + + if (min_val != None) and (float(norm_val) < min_val): + print('1:', norm_val, min_val) + passed = False + if (max_val != None) and (float(norm_val) > max_val): + print('2:', norm_val, max_val) + passed = False + if (val_type == 'int') and ('.' in norm_val): + print('3:', norm_val) + passed = False + if val_type != 'int': + num_digit = int(val_type[-1]) + norm_val_list = norm_val.split('.') + + if len(norm_val_list[1]) > num_digit: + print('4:', norm_val, val_type) + passed = False # Only larger, because for example 100.0 will + # only return with 1 digit after comma + + if passed == True: + num_passed += 1 + else: + num_failed += 1 + + assert num_passed + num_failed == (16 * 10 * num_tests) + + test_result_str = 'attrgenfunct,n/a,generate_normal_value,' + 'n/a,funct,%d,' % ( + 16 * 10 * num_tests + ) + if num_failed == 0: + test_result_str += 'all tests passed' + else: + test_result_str += '%d tests failed' % (num_failed) + + return [test_result_str, ''] + + # --------------------------------------------------------------------------- + + def testFunct_generate_normal_age(self, num_tests): + """Test the functionality of 'generate_normal_age', making sure this + function returns a string with an integer value between 0 and 130. + """ + + print('Testing functionality of "generate_normal_age"') + + num_passed = 0 + num_failed = 0 + + for i in range(num_tests): + + for (mu, sigma, min_val, max_val) in [ + (50, 100, 0, 130), + (25, 20, 5, 55), + (65, 10, 60, 130), + (85, 20, 0, 95), + ]: + + age_val = attrgenfunct.generate_normal_age(mu, sigma, min_val, max_val) + + passed = True + + if float(age_val) < min_val: + passed = False + if float(age_val) > max_val: + passed = False + if '.' in age_val: + passed = False + + if passed == True: + num_passed += 1 + else: + num_failed += 1 + + assert num_passed + num_failed == num_tests * 4 + + test_result_str = 'attrgenfunct,n/a,generate_normal_age,' + 'n/a,funct,%d,' % ( + num_tests * 4 + ) + if num_failed == 0: + test_result_str += 'all tests passed' + else: + test_result_str += '%d tests failed' % (num_failed) + + return [test_result_str, ''] + + +# ============================================================================= +# Generate a time string to be used for the log file +# +curr_time_tuple = time.localtime() +curr_time_str = ( + str(curr_time_tuple[0]) + + str(curr_time_tuple[1]).zfill(2) + + str(curr_time_tuple[2]).zfill(2) + + '-' + + str(curr_time_tuple[3]).zfill(2) + + str(curr_time_tuple[4]).zfill(2) +) + +# Write test output header line into the log file +# +out_file_name = './logs/attrgenfunctTest-%s.csv' % (curr_time_str) + +out_file = open(out_file_name, 'w') + +out_file.write('Test results generated by attrgenfunctTest.py' + os.linesep) + +out_file.write('Test started: ' + curr_time_str + os.linesep) + +out_file.write(os.linesep) + +out_file.write( + 'Module name,Class name,Method name,Arguments,Test_type,' + + 'Patterns tested,Summary,Failure description' + + os.linesep +) +out_file.write(os.linesep) + +# Create instances for the testcase class that calls all tests +# +test_res_list = [] +test_case_ins = TestCase('testArguments') +test_res_list += test_case_ins.testArguments(test_argument_data_dict) + +test_case_ins = TestCase('testFunct_generate_phone_number_australia') +test_res_list += test_case_ins.testFunct_generate_phone_number_australia(num_tests) + +test_case_ins = TestCase('testFunct_generate_credit_card_number') +test_res_list += test_case_ins.testFunct_generate_credit_card_number(num_tests) + +test_case_ins = TestCase('testFunct_generate_uniform_value') +test_res_list += test_case_ins.testFunct_generate_uniform_value(num_tests) + +test_case_ins = TestCase('testFunct_generate_uniform_age') +test_res_list += test_case_ins.testFunct_generate_uniform_age(num_tests) + +test_case_ins = TestCase('testFunct_generate_normal_value') +test_res_list += test_case_ins.testFunct_generate_normal_value(num_tests) + +test_case_ins = TestCase('testFunct_generate_normal_age') +test_res_list += test_case_ins.testFunct_generate_normal_age(num_tests) + +# Write test output results into the log file +# +for line in test_res_list: + out_file.write(line + os.linesep) + +out_file.close() + +print('Test results are written to', out_file_name) + +for line in test_res_list: + print(line) diff --git a/tests/basefunctions_test.py b/tests/basefunctions_test.py new file mode 100644 index 0000000000000000000000000000000000000000..bd7fd1872be35962c0f9370e05ce6c4158446ab0 --- /dev/null +++ b/tests/basefunctions_test.py @@ -0,0 +1,1475 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +import os +import random +from pathlib import Path + +random.seed(42) +import time +import unittest + +from geco_data_generator import basefunctions + + +def f1(x): + print(x) + + +def f2(): + print('hello') + + +# Define argument test cases here +# +test_argument_data_dict = { + ('basefunctions', 'n/a', 'check_is_not_none'): { + 'variable': [ + [['testArgument', 'test'], ['hello', 'test'], ['1.0', 'test']], + [ + [None, 'test'], + ['', 'test'], + [123, 'test'], + [0.234, 'test'], + [{}, 'test'], + [[], 'test'], + ], + ], + 'value': [ + [ + ['testArgument', 'hello'], + ['testArgument', 123], + ['testArgument', 0.234], + ['testArgument', []], + ['testArgument', {}], + ], + [['testArgument', None]], + ], + }, + ('basefunctions', 'n/a', 'check_is_string'): { + 'variable': [ + [['testArgument', 'hello'], ['test', 'hello'], ['1.0', 'hello']], + [ + [None, 'hello'], + ['', 'hello'], + [123, 'hello'], + [0.234, 'hello'], + [{}, 'hello'], + [[], 'hello'], + ], + ], + 'value': [ + [ + ['testArgument', 'hello'], + ['testArgument', ''], + ['testArgument', '123'], + ['testArgument', '-1.23'], + ['testArgument', "'!?!'"], + ['testArgument', "HELlo"], + ['testArgument', "[..]"], + ], + [ + ['testArgument', None], + ['testArgument', 123], + ['testArgument', 1.87], + ['testArgument', -75], + ], + ], + }, + ('basefunctions', 'n/a', 'check_is_unicode_string'): { + 'variable': [ + [['testArgument', u'hello'], ['test', u'hello'], ['1.0', u'hello']], + [ + [None, u'hello'], + ['', u'hello'], + [123, u'hello'], + [0.234, u'hello'], + [{}, u'hello'], + [[], u'hello'], + ], + ], + 'value': [ + [ + ['testArgument', u'hello'], + ['testArgument', u'text'], + ['testArgument', u''], + ['testArgument', u'123'], + ], + [ + ['testArgument', None], + ['testArgument', ''], + ['testArgument', -123], + ['testArgument', 123], + ['testArgument', 1.87], + ['testArgument', 'ascii'], + ], + ], + }, + ('basefunctions', 'n/a', 'check_is_string_or_unicode_string'): { + 'variable': [ + [ + ['testArgument', 'hello'], + ['test', u'hello'], + ['1.0', 'hello2'], + ['1.0', u'hello'], + ], + [ + [None, u'hello'], + ['', 'hello'], + [123, u'hello'], + [0.234, 'hello'], + [{}, u'hello'], + [[], u'hello'], + ], + ], + 'value': [ + [ + ['testArgument', u'hello'], + ['testArgument', 'text'], + ['testArgument', u''], + ['testArgument', u'123'], + ['testArgument', ''], + ['testArgument', '123'], + ], + [ + ['testArgument', None], + ['testArgument', 123.45], + ['testArgument', -123], + ['testArgument', -123.65], + ['testArgument', {}], + ['testArgument', []], + ], + ], + }, + ('basefunctions', 'n/a', 'check_is_non_empty_string'): { + 'variable': [ + [['testArgument', 'hello'], ['test', 'hello'], ['1.0', 'hello']], + [ + [None, 'hello'], + ['', 'hello'], + [123, 'hello'], + [0.234, 'hello'], + [{}, 'hello'], + [[], 'hello'], + ], + ], + 'value': [ + [ + ['testArgument', 'hello'], + ['testArgument', '123'], + ['testArgument', '-1.23'], + ['testArgument', 'HELlo'], + ['testArgument', "'!?!'"], + ['testArgument', "[..]"], + ], + [ + ['testArgument', None], + ['testArgument', 123], + ['testArgument', 1.87], + ['testArgument', -75], + ['testArgument', ''], + ['testArgument', []], + ['testArgument', {}], + ], + ], + }, # , ['testArgument','hello'] + ('basefunctions', 'n/a', 'check_is_number'): { + 'variable': [ + [['testArgument', 123], ['test', 123], ['1.0', 123]], + [[None, 123], ['', 123], [123, 123], [0.234, 123], [{}, 123], [[], 123]], + ], + 'value': [ + [ + ['testArgument', 0], + ['testArgument', -0], + ['testArgument', 1.23], + ['testArgument', -24.41], + ['testArgument', 1289837], + ['testArgument', -973293], + ], + [ + ['testArgument', None], + ['testArgument', 'hello'], + ['testArgument', '123'], + ['testArgument', '[]'], + ['testArgument', '-123.34'], + ['testArgument', ''], + ['testArgument', []], + ['testArgument', {}], + ], + ], + }, + ('basefunctions', 'n/a', 'check_is_positive'): { + 'variable': [ + [['testArgument', 1.0], ['test', 1.0], ['1.0', 1.0]], + [[None, 1.0], ['', 1.0], [123, 1.0], [0.234, 1.0], [{}, 1.0], [[], 1.0]], + ], + 'value': [ + [ + ['testArgument', 1.0], + ['testArgument', 0.001], + ['testArgument', 0.0000001], + ['testArgument', 1], + ['testArgument', 1.474], + ['testArgument', 1236967], + ['testArgument', 17676.474], + ], + [ + ['testArgument', None], + ['testArgument', -1.23], + ['testArgument', -123], + ['testArgument', -100000000], + ['testArgument', 'hello'], + ['testArgument', '123'], + ['testArgument', []], + ['testArgument', {}], + ], + ], + }, + ('basefunctions', 'n/a', 'check_is_not_negative'): { + 'variable': [ + [['testArgument', 1.0], ['test', 1.0], ['1.0', 1.0]], + [[None, 1.0], ['', 1.0], [123, 1.0], [0.234, 1.0], [{}, 1.0], [[], 1.0]], + ], + 'value': [ + [ + ['testArgument', 0], + ['testArgument', -0], + ['testArgument', 1.0], + ['testArgument', 0.00], + ['testArgument', -0.000], + ['testArgument', 1], + ['testArgument', 1.474], + ['testArgument', 1236987], + ['testArgument', 17676.474], + ], + [ + ['testArgument', None], + ['testArgument', -1.23], + ['testArgument', -123], + ['testArgument', -100000000], + ['testArgument', 'hello'], + ['testArgument', '123'], + ['testArgument', []], + ['testArgument', {}], + ], + ], + }, + ('basefunctions', 'n/a', 'check_is_normalised'): { + 'variable': [ + [['testArgument', 1.0], ['test', 1.0], ['1.0', 1.0]], + [[None, 1.0], ['', 1.0], [123, 1.0], [0.234, 1.0], [{}, 1.0], [[], 1.0]], + ], + 'value': [ + [ + ['testArgument', 0], + ['testArgument', -0], + ['testArgument', 0.00], + ['testArgument', -0.0], + ['testArgument', 1], + ['testArgument', 1.0], + ['testArgument', 0.0001], + ['testArgument', 1.00000], + ['testArgument', 0.5], + ['testArgument', 0.9999], + ], + [ + ['testArgument', None], + ['testArgument', -1.23], + ['testArgument', -123], + ['testArgument', 100], + ['testArgument', 1.0001], + ['testArgument', -1.0], + ['testArgument', 'hello'], + ['testArgument', '0.7'], + ['testArgument', []], + ['testArgument', {}], + ], + ], + }, + ('basefunctions', 'n/a', 'check_is_percentage'): { + 'variable': [ + [['testArgument', 10.0], ['test', 10.0], ['1.0', 10.0]], + [[None, 10.0], ['', 10.0], [123, 10.0], [0.234, 10.0], [{}, 10.0], [[], 10.0]], + ], + 'value': [ + [ + ['testArgument', 0], + ['testArgument', -0], + ['testArgument', 0.00], + ['testArgument', -0.0], + ['testArgument', 1], + ['testArgument', 1.0], + ['testArgument', 0.0001], + ['testArgument', 99.000], + ['testArgument', 100], + ['testArgument', 0.5], + ['testArgument', 50], + ['testArgument', 50.001], + ['testArgument', 100.0], + ['testArgument', 0.9999], + ], + [ + ['testArgument', None], + ['testArgument', -1.23], + ['testArgument', -123], + ['testArgument', 100.001], + ['testArgument', -0.0001], + ['testArgument', 'hello'], + ['testArgument', '85'], + ['testArgument', '45%'], + ['testArgument', []], + ['testArgument', {}], + ], + ], + }, + ('basefunctions', 'n/a', 'check_is_integer'): { + 'variable': [ + [['testArgument', 10], ['test', 10], ['1.0', 10]], + [[None, 10], ['', 10], [123, 10], [0.234, 10], [{}, 10], [[], 10]], + ], + 'value': [ + [ + ['testArgument', 0], + ['testArgument', 1], + ['testArgument', 10], + ['testArgument', 1234], + ['testArgument', -1], + ['testArgument', -96234], + ['testArgument', -100], + ['testArgument', -0], + ], + [ + ['testArgument', None], + ['testArgument', -1.23], + ['testArgument', 1.23], + ['testArgument', -0.0001], + ['testArgument', 0.001], + ['testArgument', 'hello'], + ['testArgument', '85'], + ['testArgument', 10000.0], + ['testArgument', []], + ['testArgument', {}], + ], + ], + }, + ('basefunctions', 'n/a', 'check_is_float'): { + 'variable': [ + [['testArgument', 1.0], ['test', 1.0], ['1.0', 1.0]], + [[None, 1.0], ['', 1.0], [123, 1.0], [0.234, 1.0], [{}, 1.0], [[], 1.0]], + ], + 'value': [ + [ + ['testArgument', 0.0], + ['testArgument', -0.0], + ['testArgument', 0.123], + ['testArgument', -65.9203], + ['testArgument', 42.123], + ['testArgument', -10000.0], + ], + [ + ['testArgument', None], + ['testArgument', -123], + ['testArgument', 123], + ['testArgument', 0], + ['testArgument', 100000], + ['testArgument', 'hello'], + ['testArgument', '8.5'], + ['testArgument', -0], + ['testArgument', []], + ['testArgument', {}], + ], + ], + }, + ('basefunctions', 'n/a', 'check_is_dictionary'): { + 'variable': [ + [['testArgument', {}], ['test', {}], ['1.0', {}]], + [[None, {}], ['', {}], [123, {}], [0.234, {}], [{}, {}], [[], {}]], + ], + 'value': [ + [ + ['testArgument', {}], + ['testArgument', {1: 2, 6: 0}], + ['testArgument', {'a': 4, 't': 1, (1, 4, 6): 'tr'}], + ], + [ + ['testArgument', None], + ['testArgument', "{1:2,3:4}"], + ['testArgument', []], + ['testArgument', set()], + ], + ], + }, + ('basefunctions', 'n/a', 'check_is_list'): { + 'variable': [ + [['testArgument', []], ['test', []], ['1.0', []]], + [[None, []], ['', []], [123, []], [0.234, []], [{}, []], [[], []]], + ], + 'value': [ + [ + ['testArgument', []], + ['testArgument', [1, 3, 5]], + ['testArgument', [-1, -3, -5]], + ['testArgument', ['a', '56', 1, {}]], + ], + [ + ['testArgument', None], + ['testArgument', "[1,2,3,4]"], + ['testArgument', {}], + ['testArgument', set()], + ], + ], + }, + ('basefunctions', 'n/a', 'check_is_set'): { + 'variable': [ + [['testArgument', set()], ['test', set()], ['1.0', set()]], + [ + [None, set()], + ['', set()], + [123, set()], + [0.234, set()], + [{}, set()], + [[], set()], + ], + ], + 'value': [ + [ + ['testArgument', set()], + ['testArgument', set([1, 2, 3])], + ['testArgument', set(['a', 'a'])], + ['testArgument', set(['a', '56', 1, 100.345])], + ], + [ + ['testArgument', None], + ['testArgument', "set([1,2,3])"], + ['testArgument', [1, 2, 3, 4]], + ['testArgument', {1: 2, 5: 6}], + ['testArgument', {}], + ['testArgument', []], + ], + ], + }, + ('basefunctions', 'n/a', 'check_is_tuple'): { + 'variable': [ + [['testArgument', ()], ['test', ()], ['1.0', ()]], + [[None, ()], ['', ()], [123, ()], [0.234, ()], [{}, ()], [[], ()]], + ], + 'value': [ + [ + ['testArgument', ()], + ['testArgument', ('a', 'b')], + ['testArgument', (42, 'b')], + ['testArgument', (1, 100)], + ['testArgument', ('a', 'b', 'c', 1, 2, 3)], + ], + [ + ['testArgument', None], + ['testArgument', [1, 2, 3, 4]], + ['testArgument', {1: 2, 5: 6}], + ['testArgument', set([1, 2, 3])], + ['testArgument', "(1,2,3)"], + ['testArgument', []], + ['testArgument', {}], + ['testArgument', set()], + ], + ], + }, + ('basefunctions', 'n/a', 'check_is_flag'): { + 'variable': [ + [['testArgument', True], ['test', True], ['1.0', True]], + [[None, True], ['', True], [123, True], [0.234, True], [{}, True], [[], True]], + ], + 'value': [ + [ + ['testArgument', True], + ['testArgument', False], + ['testArgument', 0], + ['testArgument', 1], + ['testArgument', 0.0], + ['testArgument', 1.0], + ], + [ + ['testArgument', None], + ['testArgument', 'True'], + ['testArgument', 'False'], + ['testArgument', 0.01], + ['testArgument', 1.01], + ['testArgument', '1.0'], + ], + ], + }, + ('basefunctions', 'n/a', 'check_unicode_encoding_exists'): { + 'unicode_encoding_string': [ + [["ascii"], ["iso-8859-1"], ["ASCII"]], + [[None], ["asciii"], [123], ['']], + ] + }, + ('basefunctions', 'n/a', 'check_is_function_or_method'): { + 'variable': [ + [['testArgument', f1], ['test', f1], ['1.0', f1]], + [[None, f1], ['', f1], [123, f1], [0.234, f1], [{}, f1], [[], f1]], + ], + 'value': [ + [ + ['testArgument', f1], + ['testArgument', f2], + ['testArgument', basefunctions.check_is_not_none], + ['testArgument', basefunctions.check_is_function_or_method], + ], + [ + ['testArgument', None], + ['testArgument', 'f1'], + ['testArgument', 'f2'], + ['testArgument', 0.0], + ['testArgument', []], + ['testArgument', {}], + ], + ], + }, + ('basefunctions', 'n/a', 'char_set_ascii'): { + 'string_variable': [ + [ + ["hello"], + ["1256783"], + ["hello1234test5678"], + ["hello 1234 test 5678"], + [' 1 a 2 b '], + ], + [[None], [0.2345], [123], [[]], [{}], [-5434.6]], + ] + }, + ('basefunctions', 'n/a', 'check_is_valid_format_str'): { + 'variable': [ + [['testArgument', 'int'], ['test', 'int'], ['1.0', 'int']], + [ + [None, 'int'], + ['', 'int'], + [123, 'int'], + [0.234, 'int'], + [{}, 'int'], + [[], 'int'], + ], + ], + 'value': [ + [ + ['testArgument', 'int'], + ['testArgument', 'float1'], + ['testArgument', 'float2'], + ['testArgument', 'float3'], + ['testArgument', 'float4'], + ['testArgument', 'float5'], + ['testArgument', 'float6'], + ['testArgument', 'float7'], + ['testArgument', 'float8'], + ['testArgument', 'float9'], + ], + [ + ['testArgument', None], + ['testArgument', ''], + ['testArgument', 'float10'], + ['testArgument', 'int1'], + ['testArgument', 'floet1'], + ['testArgument', 1], + ['testArgument', []], + ['testArgument', {}], + ], + ], + }, + ('basefunctions', 'n/a', 'float_to_str'): { + 'number_variable': [ + [ + [1234, 'int'], + [123.4, 'int'], + [1.0004, 'int'], + [1000000000, 'int'], + [-12345.678, 'int'], + ], + [ + [None, 'int'], + ['', 'int'], + ['123', 'int'], + ['456.98', 'int'], + [{}, 'int'], + [[], 'int'], + ], + ], + 'format_string': [ + [ + [100, 'int'], + [100, 'float1'], + [100, 'float2'], + [100, 'float3'], + [100, 'float4'], + [100, 'float5'], + [100, 'float6'], + [100, 'float7'], + [100, 'float8'], + [100, 'float9'], + ], + [ + [100, None], + [100, ''], + [100, 'float10'], + [100, 'int1'], + [100, 'floet1'], + [100, 1], + [100, []], + [100, {}], + ], + ], + }, + ('basefunctions', 'n/a', 'str2comma_separated_list'): { + 'string_variable': [ + [ + [u"ab,cd,ef"], + [u"12,567,83"], + [u"hello,1234,test,5678"], + [u"hello ,1234 ,test ,5678"], + [u' 1 a, 2 b '], + [u'as$,bc#'], + [u'abcdef'], + [u' , '], + ], + [[None], [0.2345], [123], [''], [], {}], + ] + }, + ('basefunctions', 'n/a', 'read_csv_file'): { + 'file_name': [ + [ + ['test1.csv', "ascii", False], # Assume these test files exist + ['test3.csv', "ascii", False], + ['test2.txt', "ascii", False], + ], + [ + [None, "ascii", False], + ['', "ascii", False], + ['test3.csvv', "ascii", False], + [234, "ascii", False], + [{}, "ascii", False], + [[], "ascii", False], + ], + ], + 'encoding': [ + [ + ['test1.csv', "ascii", False], + ['test1.csv', "iso-8859-1", False], + ['test1.csv', "ASCII", False], + ['test1.csv', None, False], + ], + [ + ['test1.csv', '', False], + ['test1.csv', 'asciii', False], + ['test1.csv', 'ascii encode', False], + ['test1.csv', 123, False], + ['test1.csv', [], False], + ['test1.csv', {}, False], + ], + ], + 'header_line': [ + [ + ['test1.csv', "ascii", True], + ['test1.csv', "ascii", False], + ['test1.csv', "ascii", 1.0], + ['test1.csv', "ascii", 1], + ['test1.csv', "ascii", 0], + ['test1.csv', "ascii", 0.0], + ], + [ + ['test1.csv', "ascii", None], + ['test1.csv', "ascii", 'True'], + ['test1.csv', "ascii", '1.0'], + ['test1.csv', "ascii", 1.01], + ['test1.csv', "ascii", 0.01], + ['test1.csv', "ascii", ''], + ], + ], + }, + ('basefunctions', 'n/a', 'write_csv_file'): { + 'file_name': [ + [ + ['test.csv', "ascii", None, []], + ['test.csv', "ascii", None, []], + ['test.txt', "ascii", None, []], + ['test.csv', "ascii", None, []], + ], + [ + [None, "ascii", None, []], + ['', "ascii", None, []], + ['test-3/csvv', "ascii", None, []], + [234, "ascii", None, []], + [{}, "ascii", None, []], + [[], "ascii", None, []], + ], + ], + 'encoding': [ + [ + ['test.csv', "ascii", None, []], + ['test.csv', "iso-8859-1", None, []], + ['test.csv', "ASCII", None, []], + ['test.csv', None, None, []], + ], + [ + ['test.csv', '', None, []], + ['test.csv', 'asciii', None, []], + ['test.csv', 'ascii encode', None, []], + ['test.csv', 123, None, []], + ['test.csv', [], None, []], + ['test.csv', {}, None, []], + ], + ], + 'header_list': [ + [ + ['test.csv', "ascii", None, []], + ['test.csv', "ascii", [], []], + ['test.csv', "ascii", ['attr1'], []], + ['test.csv', "ascii", ['attr1', 'attr2'], []], + ['test.csv', "ascii", [' attr1 '], []], + ['test.csv', "ascii", [''], []], + ], + [ + ['test.csv', "ascii", '', []], + ['test.csv', "ascii", 'attr1', []], + ['test.csv', "ascii", 'attr1,attr2', []], + ['test.csv', "ascii", 1, []], + ['test.csv', "ascii", set(['attr1']), []], + ['test.csv', "ascii", {1: 'attr1'}, []], + ], + ], + 'file_data': [ + [ + ['test.csv', "ascii", None, []], + ['test.csv', "ascii", None, [['test']]], + [ + 'test.csv', + "ascii", + None, + [['1'], ['2'], ['3', '4'], ['5', '6', '7'], ['8,9,10']], + ], + ['test.csv', "ascii", None, [['a', 'b'], ['c', 'd', 'e']]], + [ + 'test.csv', + "ascii", + None, + [['a'], ['1', '2'], ['b', '$%'], ['', '10.34']], + ], + ['test.csv', "ascii", None, [['']]], + ], + [ + ['test.csv', "ascii", None, None], + ['test.csv', "ascii", None, 'test'], + ['test.csv', "ascii", None, ['test']], + ['test.csv', "ascii", None, [[1, 2], [3, 4]]], + ['test.csv', "ascii", None, {}], + ['test.csv', "ascii", None, set()], + ['test.csv', "ascii", None, ''], + ], + ], + }, +} + +# ============================================================================= + + +class TestCase(unittest.TestCase): + + # Initialise test case - - - - - - - - - - - - - - - - - - - - - - - - - - - + # + def setUp(self): + pass # Nothing to initialize + + # Clean up test case - - - - - - - - - - - - - - - - - - - - - - - - - - - - + # + def tearDown(self): + pass # Nothing to clean up + + # --------------------------------------------------------------------------- + # Start test cases + + def testArguments(self, test_data): + """Test if a function or method can be called or initialised correctly with + different values for their input arguments (parameters). + + The argument 'test_data' must be a dictionary with the following + structure: + + - Keys are tuples consisting of three strings: + (module_name, class_name, function_or_method_name) + - Values are dictionaries where the keys are the names of the input + argument that is being tested, and the values of these dictionaries + are a list that contains two lists. The first list contains valid + input arguments ('normal' argument tests) that should pass the test, + while the second list contains illegal input arguments ('exception' + argument tests) that should raise an exception. + + The lists of test cases are itself lists, each containing a number of + input argument values, as many as are expected by the function or + method that is being tested. + + This function returns a list containing the test results, where each + list element is a string with comma separated values (CSV) which are to + be written into the testing log file. + """ + + test_res_list = [] # The test results, one element per element in the test + # data dictionary + + for test_method_names, test_method_data in test_data.items(): + test_method_name = test_method_names[2] + print('Testing arguments for method/function:', test_method_name) + + for argument_name in test_method_data: + print(' Testing input argument:', argument_name) + + norm_test_data = test_method_data[argument_name][0] + exce_test_data = test_method_data[argument_name][1] + print(' Normal test cases: ', norm_test_data) + print(' Exception test cases:', exce_test_data) + + # Conduct normal tests - - - - - - - - - - - - - - - - - - - - - - - - + # + num_norm_test_cases = len(norm_test_data) + num_norm_test_passed = 0 + num_norm_test_failed = 0 + norm_failed_desc_str = '' + + for test_input in norm_test_data: + passed = True # Assume the test will pass :-) + + if len(test_input) == 0: # Method has no input argument + try: + getattr(basefunctions, test_method_name)() + except: + passed = False + + elif len(test_input) == 1: # Method has one input argument + try: + getattr(basefunctions, test_method_name)(test_input[0]) + except: + passed = False + + elif len(test_input) == 2: # Method has two input arguments + try: + getattr(basefunctions, test_method_name)( + test_input[0], test_input[1] + ) + except: + passed = False + + elif len(test_input) == 3: # Method has three input arguments + try: + getattr(basefunctions, test_method_name)( + test_input[0], test_input[1], test_input[2] + ) + except: + passed = False + + elif len(test_input) == 4: # Method has four input arguments + try: + getattr(basefunctions, test_method_name)( + test_input[0], test_input[1], test_input[2], test_input[3] + ) + except: + passed = False + + elif len(test_input) == 5: # Method has five input arguments + try: + getattr(basefunctions, test_method_name)( + test_input[0], + test_input[1], + test_input[2], + test_input[3], + test_input[4], + ) + except: + passed = False + + else: + raise Exception('Illegal number of input arguments') + + # Now process test results + # + if passed == False: + num_norm_test_failed += 1 + norm_failed_desc_str += 'Failed test for input ' + "'%s'; " % ( + str(test_input) + ) + else: + num_norm_test_passed += 1 + + assert num_norm_test_failed + num_norm_test_passed == num_norm_test_cases + + norm_test_result_str = ( + test_method_names[0] + + ',' + + test_method_names[1] + + ',' + + test_method_names[2] + + ',' + + argument_name + + ',normal,' + + '%d,' % (num_norm_test_cases) + ) + if num_norm_test_failed == 0: + norm_test_result_str += 'all tests passed' + else: + norm_test_result_str += '%d tests failed,' % (num_norm_test_failed) + norm_test_result_str += '"' + norm_failed_desc_str[:-2] + '"' + + test_res_list.append(norm_test_result_str) + + # Conduct exception tests - - - - - - - - - - - - - - - - - - - - - - - + # + num_exce_test_cases = len(exce_test_data) + num_exce_test_passed = 0 + num_exce_test_failed = 0 + exce_failed_desc_str = '' + + for test_input in exce_test_data: + passed = True # Assume the test will pass (i.e. raise an exception) + + if len(test_input) == 0: # Method has no input argument + try: + self.assertRaises( + Exception, getattr(basefunctions, test_method_name) + ) + except: + passed = False + + elif len(test_input) == 1: # Method has one input argument + try: + self.assertRaises( + Exception, + getattr(basefunctions, test_method_name), + test_input[0], + ) + except: + passed = False + + elif len(test_input) == 2: # Method has two input arguments + try: + self.assertRaises( + Exception, + getattr(basefunctions, test_method_name), + test_input[0], + test_input[1], + ) + except: + passed = False + + elif len(test_input) == 3: # Method has three input arguments + try: + self.assertRaises( + Exception, + getattr(basefunctions, test_method_name), + test_input[0], + test_input[1], + test_input[2], + ) + except: + passed = False + + elif len(test_input) == 4: # Method has four input arguments + try: + self.assertRaises( + Exception, + getattr(basefunctions, test_method_name), + test_input[0], + test_input[1], + test_input[2], + test_input[3], + ) + except: + passed = False + + elif len(test_input) == 5: # Method has five input arguments + try: + self.assertRaises( + Exception, + getattr(basefunctions, test_method_name), + test_input[0], + test_input[1], + test_input[2], + test_input[3], + test_input[4], + ) + except: + passed = False + + else: + raise Exception('Illegal number of input arguments') + + # Now process test results + # + if passed == False: + num_exce_test_failed += 1 + exce_failed_desc_str += 'Failed test for input ' + "'%s'; " % ( + str(test_input) + ) + else: + num_exce_test_passed += 1 + + assert num_exce_test_failed + num_exce_test_passed == num_exce_test_cases + + exce_test_result_str = ( + test_method_names[0] + + ',' + + test_method_names[1] + + ',' + + test_method_names[2] + + ',' + + argument_name + + ',exception,' + + '%d,' % (num_exce_test_cases) + ) + if num_exce_test_failed == 0: + exce_test_result_str += 'all tests passed' + else: + exce_test_result_str += '%d tests failed,' % (num_exce_test_failed) + exce_test_result_str += '"' + exce_failed_desc_str[:-2] + '"' + + test_res_list.append(exce_test_result_str) + + test_res_list.append('') # Empty line between tests of methods + + return test_res_list + + def testFunct_char_set_ascii(self): + """Test the functionality of 'char_set_ascii', making sure this function + returns a correct string containing the set of corresponding characters. + """ + + print('Testing functionality of "char_set_ascii"') + + num_passed = 0 + num_failed = 0 + num_tests = 0 + failed_tests_desc = '' + + test_cases = { + '0123456789': ['1', '234', '9746298136491', '99999999999999999999999999'], + '0123456789 ': [ + '1 2 3', + ' 0 0 0 ', + ' 234' '409324 12430 32578', + '0000000 00000', + ], + 'abcdefghijklmnopqrstuvwxyz': [ + 'abc', + 'aaaaaaaaaaaa', + 'aaabbbccc', + 'cdhiofeakjbdakfhoweuar', + 'ABC', + ], + 'abcdefghijklmnopqrstuvwxyz ': [ + ' a b c ', + 'aaaa aaaa ', + 'aaa bbb ccc', + ' cdhiofeakjbdakfhoweuar', + 'AB C', + ], + 'abcdefghijklmnopqrstuvwxyz0123456789': [ + '1234sdfj12998', + '12345678a', + 'afdadgf34kafh', + '1a2b3c', + ], + 'abcdefghijklmnopqrstuvwxyz0123456789 ': [ + '1234 sdfj 12998', + ' 12345678a ', + 'afdadgf 34 kafh', + ' 1 a 2 b 3 c ', + ], + } + + for char_set_type in test_cases: + + this_type_test_cases = test_cases[char_set_type] + + for test_case in this_type_test_cases: + if basefunctions.char_set_ascii(test_case) == char_set_type: + num_passed += 1 + else: + num_failed += 1 + + failed_tests_desc += "Failed with input string: '%s'; " % (test_case) + num_tests += 1 + + test_result_str = 'basefunctions,n/a,char_set_ascii,' + 'n/a,funct,%d,' % ( + num_tests + ) + + if num_failed == 0: + test_result_str += 'all tests passed' + else: + test_result_str += '%d tests failed,' % (num_failed) + test_result_str += '"' + failed_tests_desc[:-2] + '"' + + return [test_result_str, ''] + + # --------------------------------------------------------------------------- + + def testFunct_float_to_str(self): + """Test the functionality of 'float_to_str', making sure this function + returns a correct string of the number with the specified number of + digits behind the comma. + """ + + print('Testing functionality of "float_to_str"') + + num_passed = 0 + num_failed = 0 + num_tests = 0 + failed_tests_desc = '' + + test_cases = { + 'int': { + 1: '1', + 1.0: '1', + 123.0: '123', + -123: '-123', + 1000.0001: '1000', + 56.7: '57', + }, + 'float1': { + 1: '1.0', + 1.0: '1.0', + -123: '-123.0', + 1000.127: '1000.1', + 56.78: '56.8', + }, + 'float2': { + 1: '1.00', + 1.0: '1.00', + -123: '-123.00', + 1000.127: '1000.13', + 56.78: '56.78', + }, + 'float3': { + 1: '1.000', + -123: '-123.000', + 999.999: '999.999', + 999.99999: '1000.000', + }, + 'float4': { + 1: '1.0000', + -1.0: '-1.0000', + 4.56789: '4.5679', + 999.99999: '1000.0000', + }, + 'float5': { + 1: '1.00000', + -1.0: '-1.00000', + 4.456789: '4.45679', + 999.999999: '1000.00000', + }, + 'float6': { + 1: '1.000000', + -123: '-123.000000', + 4.3456789: '4.345679', + 123.12: '123.120000', + 999.9999999: '1000.000000', + }, + 'float7': { + 1: '1.0000000', + -23.4: '-23.4000000', + 4.23456789: '4.2345679', + 123.12: '123.1200000', + 999.99999999: '1000.0000000', + }, + 'float8': { + 1: '1.00000000', + -1.0: '-1.00000000', + 4.123456789: '4.12345679', + 123.12: '123.12000000', + 999.999999999: '1000.00000000', + }, + 'float9': { + 1: '1.000000000', + -1.0: '-1.000000000', + 4.0123456789: '4.012345679', + 999.9999999999: '1000.000000000', + }, + } + + for format in test_cases: + + this_format_test_cases = test_cases[format] + + for input_num in this_format_test_cases: + if ( + basefunctions.float_to_str(input_num, format) + == this_format_test_cases[input_num] + ): + num_passed += 1 + else: + num_failed += 1 + failed_tests_desc += "Failed with input number: '%s'; " % ( + str(input_num) + ) + num_tests += 1 + + test_result_str = 'basefunctions,n/a,float_to_str,' + 'n/a,funct,%d,' % (num_tests) + + if num_failed == 0: + test_result_str += 'all tests passed' + else: + test_result_str += '%d tests failed,' % (num_failed) + test_result_str += '"' + failed_tests_desc[:-2] + '"' + + return [test_result_str, ''] + + # --------------------------------------------------------------------------- + + def testFunct_str2comma_separated_list(self): + """Test the functionality of 'str2comma_separated_list', making sure this + function returns a correct list of values separated by the comma in the + input string. + """ + + print('Testing functionality of "str2comma_separated_list"') + + num_passed = 0 + num_failed = 0 + num_tests = 0 + + failed_tests_desc = '' + + test_cases = { + u'123,456,789': ['123', '456', '789'], + u'abcd,efgh,ij': ['abcd', 'efgh', 'ij'], + u"abcd,efgh,ij": ['abcd', 'efgh', 'ij'], + u'123,abc,f23': ['123', 'abc', 'f23'], + u'000,000,000': ['000', '000', '000'], + u'#$%,^&*,@?>': ['#$%', '^&*', '@?>'], + u'abcd,123 ': ['abcd', '123'], + u'123,45;6,7;89': ['123', '45;6', '7;89'], + u'fd,g r,er,a w': ['fd', 'g r', 'er', 'a w'], + u' fd,gr,er,aw ': ['fd', 'gr', 'er', 'aw'], + u'123,456,': ['123', '456', ''], + } + + for string_val in test_cases: + + if ( + basefunctions.str2comma_separated_list(string_val) + == test_cases[string_val] + ): + num_passed += 1 + else: + num_failed += 1 + failed_tests_desc += "Failed when string input: '%s'; " % (str(string_val)) + num_tests += 1 + + test_result_str = ( + 'basefunctions,n/a,str2comma_separated_list,' + 'n/a,funct,%d,' % (num_tests) + ) + + if num_failed == 0: + test_result_str += 'all tests passed' + else: + test_result_str += '%d tests failed,' % (num_failed) + test_result_str += '"' + failed_tests_desc[:-2] + '"' + + return [test_result_str, ''] + + # --------------------------------------------------------------------------- + + def testFunct_read_csv_file(self): + """Test the functionality of 'read_csv_file', making sure this function + reads a CSV file and returns the correct content of the file. + + This function assumes there are three small test file available: + test1.csv, test2.txt, test3.csv + + """ + + print('Testing functionality of "read_csv_file"') + + num_passed = 0 + num_failed = 0 + num_tests = 0 + failed_tests_desc = '' + + # For the three test files, give file name, the expected number of records + # (assuming there is no header line) and the expected number of attributes + # in each record + # + test_cases = [('test1.csv', 4, 3), ('test2.txt', 5, 4), ('test3.csv', 0, 1)] + + for test_case in test_cases: + + for header_flag in [True, False]: + passed = True + (header_list, file_data) = basefunctions.read_csv_file( + test_case[0], 'ascii', header_flag + ) + if header_flag == True: + if len(file_data) > 0: + if len(file_data) != test_case[1] - 1: + passed = False + else: # No records in file + if len(file_data) != 0: + passed = False + if len(header_list) != test_case[2]: + passed = False + else: + if header_list != None: + passed = False + if len(file_data) != test_case[1]: + passed = False + + for rec in file_data: + if len(rec) != test_case[2]: + passed = False + + if passed == True: + num_passed += 1 + else: + num_failed += 1 + failed_tests_desc += "Failed reading the file: '%s'; " % (test_case[0]) + num_tests += 1 + + test_result_str = 'basefunctions,n/a,read_csv_file,' + 'n/a,funct,%d,' % ( + num_tests + ) + + if num_failed == 0: + test_result_str += 'all tests passed' + else: + test_result_str += '%d tests failed,' % (num_failed) + test_result_str += '"' + failed_tests_desc[:-2] + '"' + + return [test_result_str, ''] + + # --------------------------------------------------------------------------- + + def testFunct_write_csv_file(self): + """Test the functionality of 'write_csv_file', making sure this function + correctly writes a list of values into a CSV file. To test this + function we assume the read_csv_file() function is correct. + """ + + print('Testing functionality of "write_csv_file"') + + num_passed = 0 + num_failed = 0 + num_tests = 0 + failed_tests_desc = '' + + test_cases = [ + [['test1'], ['test2'], ['test3']], + [['1'], ['2'], ['3']], + [['test 1'], ['test 2'], ['test 3']], + [['%^&'], ['test $#%^'], ['123 @#*(']], + [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']], + [['1', '2', '3'], ['4', '5', '6']], + [['1', '2', '3'], ['4', '5', '6'], ['7', '8']], + [ + ['id1', 'peter', 'lyneham'], + ['id2', 'miller', 'dickson'], + ['id3', 'smith', 'hackett'], + ], + ] + + header_lists = [None, ['attr1', 'attr2', 'attr3']] + + for test_case in test_cases: + + for header_list in header_lists: + basefunctions.write_csv_file('test.csv', 'ascii', header_list, test_case) + + if header_list != None: + (read_header_list, read_file_data) = basefunctions.read_csv_file( + 'test.csv', 'ascii', True + ) + + else: + (read_header_list, read_file_data) = basefunctions.read_csv_file( + 'test.csv', 'ascii', False + ) + + if (read_header_list == header_list) and (read_file_data == test_case): + num_passed += 1 + else: + num_failed += 1 + failed_tests_desc += "Failed writing the data: '%s'; " % (str(test_case)) + num_tests += 1 + + test_result_str = 'basefunctions,n/a,write_csv_file,' + 'n/a,funct,%d,' % ( + num_tests + ) + + if num_failed == 0: + test_result_str += 'all tests passed' + else: + test_result_str += '%d tests failed,' % (num_failed) + test_result_str += '"' + failed_tests_desc[:-2] + '"' + + return [test_result_str, ''] + + +# ============================================================================= +# Generate a time string to be used for the log file +# +curr_time_tuple = time.localtime() +curr_time_str = ( + str(curr_time_tuple[0]) + + str(curr_time_tuple[1]).zfill(2) + + str(curr_time_tuple[2]).zfill(2) + + '-' + + str(curr_time_tuple[3]).zfill(2) + + str(curr_time_tuple[4]).zfill(2) +) + +# Write test output header line into the log file + +Path('logs').mkdir(parents=True, exist_ok=True) +out_file_name = './logs/basefunctionsTest-%s.csv' % (curr_time_str) + +out_file = open(out_file_name, 'w') + +out_file.write("Test results generated by basefunctionsTest.py" + os.linesep) + +out_file.write("Test started: " + curr_time_str + os.linesep) + +out_file.write(os.linesep) + +out_file.write( + 'Module name,Class name,Method name,Arguments,Test_type,' + + 'Patterns tested,Summary,Failure description' + + os.linesep +) + +out_file.write(os.linesep) + +# Create instances for the testcase class that calls all tests +# +test_res_list = [] +test_case_ins = TestCase('testArguments') +test_res_list += test_case_ins.testArguments(test_argument_data_dict) + +test_case_ins = TestCase('testFunct_char_set_ascii') +test_res_list += test_case_ins.testFunct_char_set_ascii() + +test_case_ins = TestCase('testFunct_float_to_str') +test_res_list += test_case_ins.testFunct_float_to_str() + +test_case_ins = TestCase('testFunct_str2comma_separated_list') +test_res_list += test_case_ins.testFunct_str2comma_separated_list() + +test_case_ins = TestCase('testFunct_read_csv_file') +test_res_list += test_case_ins.testFunct_read_csv_file() + +test_case_ins = TestCase('testFunct_write_csv_file') +test_res_list += test_case_ins.testFunct_write_csv_file() + +# Write test output results into the log file +# +for line in test_res_list: + out_file.write(line + os.linesep) + +out_file.close() + +print('Test results are written to', out_file_name) + +for line in test_res_list: + print(line) diff --git a/tests/contdepfunct_test.py b/tests/contdepfunct_test.py new file mode 100644 index 0000000000000000000000000000000000000000..509d373fb05d288206dc27bcf27975c5520730e5 --- /dev/null +++ b/tests/contdepfunct_test.py @@ -0,0 +1,381 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +import os +import random +from pathlib import Path + +random.seed(42) +import time +import unittest + +from geco_data_generator import contdepfunct + + +# Define the number of tests to be done for the functionality tests +# +num_tests = 100000 + +# Define argument test cases here +# +test_argument_data_dict = { + ('contdepfunct','n/a','blood_pressure_depending_on_age'): \ + {'age':[[[1],[2],[3],[77],[8],[9],[3.76],[99.9],[129.65],[42]], + [[None],[''],['test'],[-65],[999],[-0.03],[130.01], + [187.87],[{}],[[]]]]}, + ('contdepfunct','n/a','salary_depending_on_age'): \ + {'age':[[[1],[2],[3],[77],[8],[9],[3.76],[99.9],[129.65],[42]], + [[None],[''],['test'],[-65],[999],[-0.03],[130.01], + [187.87],[{}],[[]]]]} +} + +# ============================================================================= + +class TestCase(unittest.TestCase): + + # Initialise test case - - - - - - - - - - - - - - - - - - - - - - - - - - - + # + def setUp(self): + pass # Nothing to initialize + + # Clean up test case - - - - - - - - - - - - - - - - - - - - - - - - - - - - + # + def tearDown(self): + pass # Nothing to clean up + + # --------------------------------------------------------------------------- + # Start test cases + + def testArguments(self, test_data): + """Test if a function or method can be called or initialised correctly with + different values for their input arguments (parameters). + + The argument 'test_data' must be a dictionary with the following + structure: + + - Keys are tuples consisting of three strings: + (module_name, class_name, function_or_method_name) + - Values are dictionaries where the keys are the names of the input + argument that is being tested, and the values of these dictionaries + are a list that contains two lists. The first list contains valid + input arguments ('normal' argument tests) that should pass the test, + while the second list contains illegal input arguments ('exception' + argument tests) that should raise an exception. + + The lists of test cases are itself lists, each containing a number of + input argument values, as many as are expected by the function or + method that is being tested. + + This function returns a list containing the test results, where each + list element is a string with comma separated values (CSV) which are to + be written into the testing log file. + """ + + test_res_list = [] # The test results, one element per element in the test + # data dictionary + + for (test_method_names, test_method_data) in test_data.items(): + test_method_name = test_method_names[2] + print('Testing arguments for method/function:', test_method_name) + + for argument_name in test_method_data: + print(' Testing input argument:', argument_name) + + norm_test_data = test_method_data[argument_name][0] + exce_test_data = test_method_data[argument_name][1] + print(' Normal test cases: ', norm_test_data) + print(' Exception test cases:', exce_test_data) + + # Conduct normal tests - - - - - - - - - - - - - - - - - - - - - - - - + # + num_norm_test_cases = len(norm_test_data) + num_norm_test_passed = 0 + num_norm_test_failed = 0 + norm_failed_desc_str = '' + + for test_input in norm_test_data: + passed = True # Assume the test will pass :-) + + if (len(test_input) == 0): # Method has no input argument + try: + getattr(contdepfunct,test_method_name)() + except: + passed = False + + elif (len(test_input) == 1): # Method has one input argument + try: + getattr(contdepfunct,test_method_name)(test_input[0]) + except: + passed = False + + elif (len(test_input) == 2): # Method has two input arguments + try: + getattr(contdepfunct,test_method_name)(test_input[0], + test_input[1]) + except: + passed = False + + elif (len(test_input) == 3): # Method has three input arguments + try: + getattr(contdepfunct,test_method_name)(test_input[0], + test_input[1], + test_input[2]) + except: + passed = False + + elif (len(test_input) == 4): # Method has four input arguments + try: + getattr(contdepfunct,test_method_name)(test_input[0], + test_input[1], + test_input[2], + test_input[3]) + except: + passed = False + + elif (len(test_input) == 5): # Method has five input arguments + try: + getattr(contdepfunct,test_method_name)(test_input[0], + test_input[1], + test_input[2], + test_input[3], + test_input[4]) + except: + passed = False + + else: + raise Exception('Illegal number of input arguments') + + # Now process test results + # + if (passed == False): + num_norm_test_failed += 1 + norm_failed_desc_str += 'Failed test for input ' + \ + "'%s'; " % (str(test_input)) + else: + num_norm_test_passed += 1 + + assert num_norm_test_failed+num_norm_test_passed == num_norm_test_cases + + norm_test_result_str = test_method_names[0] + ',' + \ + test_method_names[1] + ',' + \ + test_method_names[2] + ',' + \ + argument_name + ',normal,' + \ + '%d,' % (num_norm_test_cases) + if (num_norm_test_failed == 0): + norm_test_result_str += 'all tests passed' + else: + norm_test_result_str += '%d tests failed,' % (num_norm_test_failed) + norm_test_result_str += '"'+norm_failed_desc_str[:-2]+'"' + + test_res_list.append(norm_test_result_str) + + # Conduct exception tests - - - - - - - - - - - - - - - - - - - - - - - + # + num_exce_test_cases = len(exce_test_data) + num_exce_test_passed = 0 + num_exce_test_failed = 0 + exce_failed_desc_str = '' + + for test_input in exce_test_data: + passed = True # Assume the test will pass (i.e. raise an exception) + + if (len(test_input) == 0): # Method has no input argument + try: + self.assertRaises(Exception, + getattr(contdepfunct,test_method_name)) + except: + passed = False + + elif (len(test_input) == 1): # Method has one input argument + try: + self.assertRaises(Exception, + getattr(contdepfunct,test_method_name),test_input[0]) + except: + passed = False + + elif (len(test_input) == 2): # Method has two input arguments + try: + self.assertRaises(Exception, + getattr(contdepfunct,test_method_name),test_input[0], + test_input[1]) + except: + passed = False + + elif (len(test_input) == 3): # Method has three input arguments + try: + self.assertRaises(Exception, + getattr(contdepfunct,test_method_name),test_input[0], + test_input[1], + test_input[2]) + except: + passed = False + + elif (len(test_input) == 4): # Method has four input arguments + try: + self.assertRaises(Exception, + getattr(contdepfunct,test_method_name),test_input[0], + test_input[1], + test_input[2], + test_input[3]) + except: + passed = False + + elif (len(test_input) == 5): # Method has five input arguments + try: + self.assertRaises(Exception, + getattr(contdepfunct,test_method_name),test_input[0], + test_input[1], + test_input[2], + test_input[3], + test_input[4]) + except: + passed = False + + else: + raise Exception('Illegal number of input arguments') + + # Now process test results + # + if (passed == False): + num_exce_test_failed += 1 + exce_failed_desc_str += 'Failed test for input ' + \ + "'%s'; " % (str(test_input)) + else: + num_exce_test_passed += 1 + + assert num_exce_test_failed+num_exce_test_passed == num_exce_test_cases + + exce_test_result_str = test_method_names[0] + ',' + \ + test_method_names[1] + ',' + \ + test_method_names[2] + ',' + \ + argument_name + ',exception,' + \ + '%d,' % (num_exce_test_cases) + if (num_exce_test_failed == 0): + exce_test_result_str += 'all tests passed' + else: + exce_test_result_str += '%d tests failed,' % (num_exce_test_failed) + exce_test_result_str += '"'+exce_failed_desc_str[:-2]+'"' + + test_res_list.append(exce_test_result_str) + + test_res_list.append('') # Empty line between tests of methods + + return test_res_list + + # --------------------------------------------------------------------------- + + def testFunct_blood_pressure_depending_on_age(self, num_tests): + """Test the functionality of 'blood_pressure_depending_on_age', making + sure this function returns a positive floating point value. + """ + + print('Testing functionality of "blood_pressure_depending_on_age"') + + num_passed = 0 + num_failed = 0 + + for i in range(num_tests): + + age = random.uniform(0.0, 120.0) + + try: + assert (contdepfunct.blood_pressure_depending_on_age(age) >= 0.0) + num_passed += 1 + except: + num_failed += 1 + + assert num_passed + num_failed == num_tests + + test_result_str = 'contdepfunct,n/a,blood_pressure_depending_on_age,' + \ + 'n/a,funct,%d,' % (num_tests) + if (num_failed == 0): + test_result_str += 'all tests passed' + else: + test_result_str += '%d tests failed' % (num_failed) + + return [test_result_str,''] + + # --------------------------------------------------------------------------- + + def testFunct_salary_depending_on_age(self, num_tests): + """Test the functionality of 'salary_depending_on_age', making sure + this function returns a positive floating point value. + """ + + print('Testing functionality of "salary_depending_on_age"') + + num_passed = 0 + num_failed = 0 + + for i in range(num_tests): + + age = random.uniform(0.0, 120.0) + + try: + assert (contdepfunct.salary_depending_on_age(age) >= 0.0) + num_passed += 1 + except: + num_failed += 1 + + assert num_passed + num_failed == num_tests + + test_result_str = 'contdepfunct,n/a,salary_depending_on_age,' + \ + 'n/a,funct,%d,' % (num_tests) + if (num_failed == 0): + test_result_str += 'all tests passed' + else: + test_result_str += '%d tests failed' % (num_failed) + + return [test_result_str,''] + +# ============================================================================= +# Generate a time string to be used for the log file +# +curr_time_tuple = time.localtime() +curr_time_str = str(curr_time_tuple[0]) + str(curr_time_tuple[1]).zfill(2) + \ + str(curr_time_tuple[2]).zfill(2) + '-' + \ + str(curr_time_tuple[3]).zfill(2) + \ + str(curr_time_tuple[4]).zfill(2) + +# Write test output header line into the log file +# +Path('./logs').mkdir(exist_ok=True) +out_file_name = './logs/contdepfunctTest-%s.csv' % (curr_time_str) + +out_file = open(out_file_name, 'w') + +out_file.write('Test results generated by contdepfunctTest.py' + os.linesep) + +out_file.write('Test started: ' + curr_time_str + os.linesep) + +out_file.write(os.linesep) + +out_file.write('Module name,Class name,Method name,Arguments,Test_type,' + \ + 'Patterns tested,Summary,Failure description' + os.linesep) +out_file.write(os.linesep) + +# Create instances for the testcase class that calls all tests +# +test_res_list = [] +test_case_ins = TestCase('testArguments') +test_res_list += test_case_ins.testArguments(test_argument_data_dict) + +test_case_ins = TestCase('testFunct_blood_pressure_depending_on_age') +test_res_list += \ + test_case_ins.testFunct_blood_pressure_depending_on_age(num_tests) + +test_case_ins = TestCase('testFunct_salary_depending_on_age') +test_res_list += test_case_ins.testFunct_salary_depending_on_age(num_tests) + +# Write test output results into the log file +# +for line in test_res_list: + out_file.write(line + os.linesep) + +out_file.close() + +print('Test results are written to', out_file_name) + +for line in test_res_list: + print(line) + + diff --git a/tests/corruptor_test.py b/tests/corruptor_test.py new file mode 100644 index 0000000000000000000000000000000000000000..01ef7192c7e2394739698deed6e9e9e752b62fc9 --- /dev/null +++ b/tests/corruptor_test.py @@ -0,0 +1,2771 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +import os +import random + +random.seed(42) +import time +import unittest +import difflib + +from geco_data_generator import basefunctions, corruptor + + +# Define the number of tests to be done for the functionality tests +# +num_tests = 10000 + +# Define dummy correct test functions that take a string as input and return +# an integer in the range of the length of the string +# +def test_function0(s): + return len(s) - 1 + + +def test_function1(s): + return len(s) + 3 - 4 + + +def test_function2(s): + return 0 + + +# Define several functions that should trigger an exception +# +def test_exce_function0(s): + return 999.99 + + +def test_exce_function1(s): + return len(s) * 2 + + +def test_exce_function2(s): + return 'test' + + +def char_set_funct1(s): + return s + + +def char_set_funct2(s): + return s[0 : len(s) / 2] + + +def exce_char_set_funct1(s): + return 123 + + +def exce_char_set_funct2(s): + return [] + + +def exce_char_set_funct3(s): + return None + + +def exce_char_set_funct3(): + return 'test' + + +# Define example data structures for corruptor +# +edit_corruptor = corruptor.CorruptValueEdit( + position_function=corruptor.position_mod_normal, + char_set_funct=basefunctions.char_set_ascii, + insert_prob=0.5, + delete_prob=0.5, + substitute_prob=0.0, + transpose_prob=0.0, +) + +edit_corruptor2 = corruptor.CorruptValueEdit( + position_function=corruptor.position_mod_uniform, + char_set_funct=basefunctions.char_set_ascii, + insert_prob=0.25, + delete_prob=0.25, + substitute_prob=0.25, + transpose_prob=0.25, +) + +surname_misspell_corruptor = corruptor.CorruptCategoricalValue( + lookup_file_name='surname-misspell.csv', + has_header_line=False, + unicode_encoding='ascii', +) + +ocr_corruptor = corruptor.CorruptValueOCR( + position_function=corruptor.position_mod_normal, + lookup_file_name='ocr-variations.csv', + has_header_line=False, + unicode_encoding='ascii', +) + +keyboard_corruptor = corruptor.CorruptValueKeyboard( + position_function=corruptor.position_mod_normal, row_prob=0.5, col_prob=0.5 +) + +phonetic_corruptor = corruptor.CorruptValuePhonetic( + position_function=corruptor.position_mod_normal, + lookup_file_name='phonetic-variations.csv', + has_header_line=False, + unicode_encoding='ascii', +) + +missing_val_corruptor = corruptor.CorruptMissingValue() +postcode_missing_val_corruptor = corruptor.CorruptMissingValue(missing_val='missing') +given_name_missing_val_corruptor = corruptor.CorruptMissingValue(missing_value='unknown') + +# Define example data structures for attr_mod_data_dictionary +# +attr_mod_data_dictionary1 = { + 'attr1': [(1.0, missing_val_corruptor)], + 'attr2': [ + (0.1, surname_misspell_corruptor), + (0.1, ocr_corruptor), + (0.1, keyboard_corruptor), + (0.7, phonetic_corruptor), + ], +} +attr_mod_data_dictionary2 = { + 'attr3': [ + (0.1, edit_corruptor2), + (0.1, ocr_corruptor), + (0.1, keyboard_corruptor), + (0.7, phonetic_corruptor), + ], + 'attr4': [(0.8, keyboard_corruptor), (0.2, postcode_missing_val_corruptor)], + 'attr5': [ + (0.1, edit_corruptor), + (0.1, missing_val_corruptor), + (0.4, keyboard_corruptor), + (0.4, phonetic_corruptor), + ], +} + +# Exception data structure for attr_mod_data_dictionary +attr_mod_data_dictionary3 = { + 'attr6': [(1.0, edit_corruptor2)], + 'attr7': [(0.7, missing_val_corruptor), (0.2, ocr_corruptor)], + 'attr8': [(1.0, edit_corruptor)], +} + +# Define example data structures for attr_mod_prob_dictionary +# +attr_mod_prob_dictionary1 = {'attr1': 0.4, 'attr2': 0.6} +attr_mod_prob_dictionary2 = {'attr3': 0.2, 'attr4': 0.3, 'attr5': 0.5} +# Exception data structure for attr_mod_prob_dictionary +attr_mod_prob_dictionary3 = {'attr6': 0.3, 'attr7': 0.3, 'attr8': 0.3} + +# Define argument test cases here +# +test_argument_data_dict = { + ('corruptor', 'CorruptValue', 'constructor (__init__)'): [ + 'base', + ['position_function'], + { + 'position_function': [ + [[test_function0], [test_function1], [test_function2]], + [ + [test_exce_function0], + [test_exce_function1], + [test_exce_function2], + [{}], + [[]], + ['test'], + [''], + [12.34], + [None], + ], + ] + }, + ], + # 'position_function' is not required by this derived class + ('corruptor', 'CorruptMissingValue', 'constructor (__init__)'): [ + 'derived', + ['missing_val'], + { + 'missing_val': [ + [[''], ['missing'], ['n/a'], ['unknown'], ['test'], ['123.4']], + [[None], [123.4], [[]], [{}]], + ] + }, + ], + # + ('corruptor', 'CorruptValueEdit', 'constructor (__init__)'): [ + 'derived', + [ + 'position_function', + 'char_set_funct', + 'insert_prob', + 'delete_prob', + 'substitute_prob', + 'transpose_prob', + ], + { + 'position_function': [ + [ + [test_function0, char_set_funct1, 0.2, 0.3, 0.3, 0.2], + [test_function1, char_set_funct1, 0.2, 0.3, 0.3, 0.2], + [test_function2, char_set_funct1, 0.2, 0.3, 0.3, 0.2], + ], + [ + [None, char_set_funct1, 0.2, 0.3, 0.3, 0.2], + [test_exce_function0, char_set_funct1, 0.2, 0.3, 0.3, 0.2], + [test_exce_function1, char_set_funct1, 0.2, 0.3, 0.3, 0.2], + [test_exce_function2, char_set_funct1, 0.2, 0.3, 0.3, 0.2], + ['test', char_set_funct1, 0.2, 0.3, 0.3, 0.2], + [123.4, char_set_funct1, 0.2, 0.3, 0.3, 0.2], + [[], char_set_funct1, 0.2, 0.3, 0.3, 0.2], + [{}, char_set_funct1, 0.2, 0.3, 0.3, 0.2], + ['', char_set_funct1, 0.2, 0.3, 0.3, 0.2], + ], + ], + 'char_set_funct': [ + [ + [test_function0, char_set_funct1, 0.2, 0.3, 0.3, 0.2], + [test_function0, char_set_funct2, 0.2, 0.3, 0.3, 0.2], + ], + [ + [test_function0, exce_char_set_funct1, 0.2, 0.3, 0.3, 0.2], + [test_function0, exce_char_set_funct2, 0.2, 0.3, 0.3, 0.2], + [test_function0, exce_char_set_funct3, 0.2, 0.3, 0.3, 0.2], + [test_function0, None, 0.2, 0.3, 0.3, 0.2], + [test_function0, [], 0.2, 0.3, 0.3, 0.2], + [test_function0, '', 0.2, 0.3, 0.3, 0.2], + [test_function0, 12.3, 0.2, 0.3, 0.3, 0.2], + [test_function0, -110, 0.2, 0.3, 0.3, 0.2], + [test_function0, {}, 0.2, 0.3, 0.3, 0.2], + [test_function0, 'char_set_funct1', 0.2, 0.3, 0.3, 0.2], + ], + ], + 'insert_prob': [ + [ + [test_function0, char_set_funct1, 0.2, 0.3, 0.3, 0.2], + [test_function0, char_set_funct1, 0.20, 0.3000, 0.3, 0.200], + [test_function0, char_set_funct1, 0.25, 0.0, 0.65, 0.100], + [test_function0, char_set_funct1, 0.5, 0.5, 0.0, 0.0], + ], + [ + [test_function0, char_set_funct1, -0.2, 0.5, 0.5, 0.0], + [test_function0, char_set_funct1, 0.2, 0.3, 0.3, 0.3], + [test_function0, char_set_funct1, 10, 20, 30, 40], + [test_function0, char_set_funct1, '0.2', '0.3', '0.3', '0.2'], + [test_function0, char_set_funct1, 0.3, 0.2, None, None], + [test_function0, char_set_funct1, None, None, None, None], + [ + test_function0, + char_set_funct1, + [2, 3, 4, 5], + [2, 3, 4, 5], + [2, 3, 4, 5], + [2, 3, 4, 5], + ], + [test_function0, char_set_funct1, {}, {}, {}, {}], + [test_function0, char_set_funct1, 0.2, 0.3, 0.2, 0.19999], + ], + ], + 'delete_prob': [ + [ + [test_function0, char_set_funct1, 0.225, 0.275, 0.350, 0.150], + [test_function0, char_set_funct1, 0.5, 0.0, 0.4, 0.1], + [test_function0, char_set_funct1, 0.05, 0.45, 0.25, 0.25], + ], + [ + [test_function0, char_set_funct1, 25, 25, 25, 25], + [test_function0, char_set_funct1, '25%', '30%', '15%', '30%'], + [test_function0, char_set_funct1, [0.2], [0.3], [0.3], [0.2]], + [test_function0, char_set_funct1, 0.2, None, 0.3, 0.5], + [test_function0, char_set_funct1, 0.2, '', 0.3, 0.5], + [test_function0, char_set_funct1, 0.4, -0.4, 0.3, 0.3], + ], + ], + 'substitute_prob': [ + [ + [test_function0, char_set_funct1, 0.2, 0.2, 0.4, 0.2], + [test_function0, char_set_funct1, 0.200, 0.350, 0.350, 0.100], + [test_function0, char_set_funct1, 0.3, 0.4, 0.02, 0.28], + ], + [ + [test_function0, char_set_funct1, 0.2, 0.3, -0.3, 0.2], + [test_function0, char_set_funct1, 0.3, 0.3, None, 0.4], + [test_function0, char_set_funct1, 0.4, 0.3, '', 0.3], + [test_function0, char_set_funct1, 0.2, 0.3, 3.0, 0.2], + [test_function0, char_set_funct1, 0.2, 0.3, [0.4], 0.2], + ], + ], + 'transpose_prob': [ + [ + [test_function0, char_set_funct1, 0.2, 0.2, 0.2, 0.4], + [test_function0, char_set_funct1, 0.200, 0.300, 0.498, 0.002], + [test_function0, char_set_funct1, 0.2, 0.3, 0.5, 0.0], + ], + [ + [test_function0, char_set_funct1, 0.2, 0.3, 0.3, -0.2], + [test_function0, char_set_funct1, 0.2, 0.3, 0.3, '0.2'], + [test_function0, char_set_funct1, 0.4, 0.3, 0.3, []], + [test_function0, char_set_funct1, 0.4, 0.3, 0.3, None], + [test_function0, char_set_funct1, 0.2, 0.3, 0.3, '20%'], + ], + ], + }, + ], + # + ('corruptor', 'CorruptValueKeyboard', 'constructor (__init__)'): [ + 'derived', + ['position_function', 'row_prob', 'col_prob'], + { + 'position_function': [ + [ + [test_function0, 0.4, 0.6], + [test_function1, 0.4, 0.6], + [test_function2, 0.4, 0.6], + ], + [ + [None, 0.4, 0.6], + [test_exce_function0, 0.4, 0.6], + [test_exce_function1, 0.4, 0.6], + [test_exce_function2, 0.4, 0.6], + ['test', 0.4, 0.6], + [123.4, 0.4, 0.6], + [[], 0.4, 0.6], + [{}, 0.4, 0.6], + ['', 0.4, 0.6], + ], + ], + 'row_prob': [ + [ + [test_function0, 0.4, 0.6], + [test_function0, 0.5, 0.5], + [test_function0, 0.0, 1.0], + [test_function0, 0.9, 0.1], + ], + [ + [test_function0, 0.4, 0.7], + [test_function0, 0.3, 0.3], + [test_function0, 0.5, 0.495], + [test_function0, 30, 40], + [test_function0, '0.3', '0.2'], + [test_function0, -0.3, 0.7], + [test_function0, None, None], + [test_function0, [2, 3, 4, 5], [2, 3, 4, 5]], + [test_function0, {}, {}], + [test_function0, 0.2, 0.19999], + ], + ], + 'col_prob': [ + [ + [test_function0, 0.6, 0.4], + [test_function0, 0.35, 0.65], + [test_function0, 1.0, 0.0], + ], + [ + [test_function0, 1.0, -0.1], + [test_function0, '15%', '30%'], + [test_function0, 0.7, '0.3'], + [test_function0, 0.5, 0.495], + [test_function0, 0.3, ''], + [test_function0, 0.3, [0.5]], + [test_function0, 0.3, None], + ], + ], + }, + ], + # + ('corruptor', 'CorruptValueOCR', 'constructor (__init__)'): [ + 'derived', + ['position_function', 'lookup_file_name', 'has_header_line', 'unicode_encoding'], + { + 'position_function': [ + [ + [test_function0, 'ocr-variations.csv', False, 'ascii'], + [test_function1, 'ocr-variations.csv', False, 'ascii'], + [test_function2, 'ocr-variations.csv', False, 'ascii'], + ], + [ + ['', 'ocr-variations.csv', False, 'ascii'], + [ + test_exce_function0, + 'ocr-variations.csv', + False, + 'ascii', + ], + [ + test_exce_function1, + '../lookup-files/ocr-variations.csv', + False, + 'ascii', + ], + [ + test_exce_function2, + '../lookup-files/ocr-variations.csv', + False, + 'ascii', + ], + [ + 'test_exce_function0', + '../lookup-files/ocr-variations.csv', + False, + 'ascii', + ], + [{}, '../lookup-files/ocr-variations.csv', False, 'ascii'], + [-12.54, '../lookup-files/ocr-variations.csv', False, 'ascii'], + [[], '../lookup-files/ocr-variations.csv', False, 'ascii'], + [None, '../lookup-files/ocr-variations.csv', False, 'ascii'], + ], + ], + 'lookup_file_name': [ + [ + [test_function0, '../lookup-files/ocr-variations.csv', False, 'ascii'], + [ + test_function0, + '../lookup-files/ocr-variations-upper-lower.csv', + False, + 'ascii', + ], + ], + [ + [test_function0, None, False, 'ascii'], + [test_function0, '../lookup-files/gender-income.csv', False, 'ascii'], + [ + test_function0, + '.../lookup-files/ocr-variations.csv', + False, + 'ascii', + ], + [test_function0, '', False, 'ascii'], + ], + ], + 'has_header_line': [ + [ + [test_function0, '../lookup-files/ocr-variations.csv', True, 'ascii'], + [test_function0, '../lookup-files/ocr-variations.csv', False, 'ascii'], + [test_function0, '../lookup-files/ocr-variations.csv', 1, 'ascii'], + [test_function0, '../lookup-files/ocr-variations.csv', 0, 'ascii'], + [test_function0, '../lookup-files/ocr-variations.csv', 1.00, 'ascii'], + ], + [ + [test_function0, '/lookup-files/ocr-variations.csv', None, 'ascii'], + [test_function0, '/lookup-files/ocr-variations.csv', 'true', 'ascii'], + [ + test_function0, + '../lookup-files/ocr-variations.csv', + 1.0001, + 'ascii', + ], + [test_function0, '', '1.0', 'ascii'], + ], + ], + 'unicode_encoding': [ + [ + [test_function0, '../lookup-files/ocr-variations.csv', False, 'ascii'], + [ + test_function0, + '../lookup-files/ocr-variations.csv', + False, + 'iso-8859-1', + ], + [test_function0, '../lookup-files/ocr-variations.csv', False, 'ASCII'], + [ + test_function0, + '../lookup-files/ocr-variations.csv', + False, + 'iso-2022-jp', + ], + ], + [ + [test_function0, '../lookup-files/ocr-variations.csv', False, ''], + [test_function0, '../lookup-files/ocr-variations.csv', False, 'hello'], + [test_function0, '../lookup-files/ocr-variations.csv', False, None], + ], + ], + }, + ], + # + # Position_function is not required by this corrupter derived class + ('corruptor', 'CorruptValuePhonetic', 'constructor (__init__)'): [ + 'derived', + ['lookup_file_name', 'has_header_line', 'unicode_encoding'], + { + 'lookup_file_name': [ + [['../lookup-files/phonetic-variations.csv', False, 'ascii']], + [ + [None, False, 'ascii'], + ['../lookup-files/gender-income.csv', False, 'ascii'], + ['.../lookup-files/phonetic-variations.csv', False, 'ascii'], + ['', False, 'ascii'], + ], + ], + 'has_header_line': [ + [ + ['../lookup-files/phonetic-variations.csv', True, 'ascii'], + ['../lookup-files/phonetic-variations.csv', False, 'ascii'], + ['../lookup-files/phonetic-variations.csv', 1, 'ascii'], + ['../lookup-files/phonetic-variations.csv', 0, 'ascii'], + ['../lookup-files/phonetic-variations.csv', 1.00, 'ascii'], + ], + [ + ['/lookup-files/phonetic-variations.csv', None, 'ascii'], + ['/lookup-files/phonetic-variations.csv', 'true', 'ascii'], + ['../lookup-files/phonetic-variations.csv', 1.0001, 'ascii'], + ['', '1.0', 'ascii'], + ], + ], + 'unicode_encoding': [ + [ + ['../lookup-files/phonetic-variations.csv', False, 'ascii'], + ['../lookup-files/phonetic-variations.csv', False, 'iso-8859-1'], + ['../lookup-files/phonetic-variations.csv', False, 'ASCII'], + ['../lookup-files/phonetic-variations.csv', False, 'iso-2022-jp'], + ], + [ + ['../lookup-files/phonetic-variations.csv', False, ''], + ['../lookup-files/phonetic-variations.csv', False, 'hello'], + ['../lookup-files/phonetic-variations.csv', False, None], + ], + ], + }, + ], + # + # Position_function is not required by this corrupter derived class + ('corruptor', 'CorruptCategoricalValue', 'constructor (__init__)'): [ + 'derived', + ['lookup_file_name', 'has_header_line', 'unicode_encoding'], + { + 'lookup_file_name': [ + [['../lookup-files/surname-misspell.csv', False, 'ascii']], + [ + [None, False, 'ascii'], + ['../lookup-files/gender-income.csv', False, 'ascii'], + ['.../lookup-files/surname-misspell.csv', False, 'ascii'], + ['', False, 'ascii'], + ], + ], + 'has_header_line': [ + [ + ['../lookup-files/surname-misspell.csv', True, 'ascii'], + ['../lookup-files/surname-misspell.csv', False, 'ascii'], + ['../lookup-files/surname-misspell.csv', 1, 'ascii'], + ['../lookup-files/surname-misspell.csv', 0, 'ascii'], + ['../lookup-files/surname-misspell.csv', 1.00, 'ascii'], + ], + [ + ['/lookup-files/surname-misspell.csv', None, 'ascii'], + ['/lookup-files/surname-misspell.csv', 'true', 'ascii'], + ['../lookup-files/surname-misspell.csv', 1.0001, 'ascii'], + ['', '1.0', 'ascii'], + ], + ], + 'unicode_encoding': [ + [ + ['../lookup-files/surname-misspell.csv', False, 'ascii'], + ['../lookup-files/surname-misspell.csv', False, 'iso-8859-1'], + ['../lookup-files/surname-misspell.csv', False, 'ASCII'], + ['../lookup-files/surname-misspell.csv', False, 'iso-2022-jp'], + ], + [ + ['../lookup-files/surname-misspell.csv', False, ''], + ['../lookup-files/surname-misspell.csv', False, 'hello'], + ['../lookup-files/surname-misspell.csv', False, None], + ], + ], + }, + ], + # + ('corruptor', 'CorruptDataSet', 'constructor (__init__)'): [ + 'derived', + [ + 'number_of_mod_records', + 'number_of_org_records', + 'attribute_name_list', + 'max_num_dup_per_rec', + 'num_dup_dist', + 'max_num_mod_per_attr', + 'num_mod_per_rec', + 'attr_mod_prob_dict', + 'attr_mod_data_dict', + ], + { + 'number_of_mod_records': [ + [ + [ + 100, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 8345, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 9999, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + ], + [ + [ + '', + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + '10000', + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 100000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + {}, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + -10000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 100.25, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + [], + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + None, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + ], + ], + 'number_of_org_records': [ + [ + [ + 1000, + 500, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 999, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 12345, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 999999, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + ], + [ + [ + 1000, + '', + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + '500', + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + None, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 10, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + -500, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + [500], + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + ], + ], + 'attribute_name_list': [ + [ + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr2', 'attr1'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr3', 'attr4', 'attr5'], + 10, + 'zipf', + 2, + 3, + attr_mod_prob_dictionary2, + attr_mod_data_dictionary2, + ], + [ + 1000, + 1000, + ['attr4', 'attr5', 'attr3'], + 10, + 'zipf', + 3, + 3, + attr_mod_prob_dictionary2, + attr_mod_data_dictionary2, + ], + ], + [ + [ + 1000, + 1000, + ['', ''], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + [], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + None, + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ('attr1', 'attr2'), + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr3', 'attr4'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary2, + attr_mod_data_dictionary2, + ], + ], + ], + 'max_num_dup_per_rec': [ + [ + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + 50, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + 2, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + 99, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + ], + [ + [ + 1000, + 1000, + ['attr1', 'attr2'], + '10', + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10.5, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + -10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + None, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + [10], + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + {}, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + ], + ], + 'num_dup_dist': [ + [ + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'uniform', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'poisson', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + ], + [ + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + '', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + None, + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf_dict', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 1234, + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + ['zipf', 'uniform'], + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + {}, + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + ], + ], + 'max_num_mod_per_attr': [ + [ + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 1, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr3', 'attr4', 'attr5'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary2, + attr_mod_data_dictionary2, + ], + [ + 1000, + 1000, + ['attr3', 'attr4', 'attr5'], + 10, + 'zipf', + 1, + 2, + attr_mod_prob_dictionary2, + attr_mod_data_dictionary2, + ], + ], + [ + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + -3, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 3.5, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + '3', + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + None, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + {}, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + '', + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + ], + ], + 'num_mod_per_rec': [ + [ + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + ], + [ + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + '4', + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 10, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + -4.5, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + [4], + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + None, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + '', + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + ], + ], + 'attr_mod_prob_dict': [ + [ + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr4', 'attr5', 'attr3'], + 10, + 'zipf', + 3, + 3, + attr_mod_prob_dictionary2, + attr_mod_data_dictionary2, + ], + ], + [ + [ + 1000, + 1000, + ['attr3', 'attr4', 'attr5'], + 10, + 'zipf', + 2, + 3, + attr_mod_prob_dictionary3, + attr_mod_data_dictionary2, + ], + [ + 1000, + 1000, + ['attr3', 'attr4', 'attr5'], + 10, + 'zipf', + 1, + 3, + attr_mod_prob_dictionary3, + attr_mod_data_dictionary3, + ], + [ + 1000, + 1000, + ['attr3', 'attr4', 'attr5'], + 10, + 'zipf', + 3, + 3, + attr_mod_prob_dictionary2, + attr_mod_data_dictionary3, + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + 'attr_mod_prob_dictionary1', + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + '', + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + [], + attr_mod_data_dictionary1, + ], + ], + ], + 'attr_mod_data_dict': [ + [ + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + attr_mod_data_dictionary1, + ], + [ + 1000, + 1000, + ['attr3', 'attr4', 'attr5'], + 10, + 'zipf', + 3, + 3, + attr_mod_prob_dictionary2, + attr_mod_data_dictionary2, + ], + ], + [ + [ + 1000, + 1000, + ['attr3', 'attr4', 'attr5'], + 10, + 'zipf', + 3, + 3, + attr_mod_prob_dictionary3, + attr_mod_data_dictionary3, + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + [attr_mod_data_dictionary1], + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + [0.6, 0.4], + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + '', + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + [], + ], + [ + 1000, + 1000, + ['attr1', 'attr2'], + 10, + 'zipf', + 2, + 2, + attr_mod_prob_dictionary1, + None, + ], + ], + ], + }, + ], +} + + +class TestCase(unittest.TestCase): + + # Initialise test case - - - - - - - - - - - - - - - - - - - - - - - - - - - + # + def setUp(self): + + # Randomly generate different types of strings + # + self.letter_string_list = [] + self.digit_string_list = [] + self.mixed_string_list = [] + + for t in range(num_tests): + l_letter = random.randint(1, 20) # Random length of string + l_digit = random.randint(1, 10) + l_mixed = random.randint(1, 30) + + s_letter = '' + for i in range(l_letter): + s_letter += random.choice('abcdefghijklmnopqrstuvwxyz') + s_digit = '' + for i in range(l_digit): + s_digit += random.choice('0123456789') + s_mixed = '' + for i in range(l_mixed): + s_mixed += random.choice('012345678abcdefghijklmnopqrstuvwxyz') + + self.letter_string_list.append(s_letter) + self.digit_string_list.append(s_digit) + self.mixed_string_list.append(s_mixed) + + # Clean up test case - - - - - - - - - - - - - - - - - - - - - - - - - - - - + # + def tearDown(self): + pass # Nothing to clean up + + # --------------------------------------------------------------------------- + # Start test cases + + def testArguments(self, test_data): + """Test if a function or method can be called or initialised correctly with + different values for their input arguments (parameters). + + The argument 'test_data' must be a dictionary with the following + structure: + + - Keys are tuples consisting of three strings: + (module_name, class_name, function_or_method_name) + - Values are lists made of three elements: + 1) If this Class is a base class ('base') or a derived class + ('derived'). These two require slightly different testing calls. + 2) A list that contains all the input arguments of the method, in the + same order as the values of these arguments are given in the + following dictionaries. + 3) Dictionaries where the keys are the names of the input argument + that is being tested, and the values of these dictionaries are a + list that contains two lists. The first list contains valid input + arguments ('normal' argument tests) that should pass the test, + while the second list contains illegal input arguments ('exception' + argument tests) that should raise an exception. + + The lists of test cases are itself lists, each containing a number of + input argument values, as many as are expected by the function or + method that is being tested. + + This function returns a list containing the test results, where each + list element is a string with comma separated values (CSV) which are to + be written into the testing log file. + """ + + test_res_list = [] # The test results, one element per element in the test + # data dictionary + + for (test_method_names, test_method_data) in test_data.iteritems(): + + test_type = test_method_data[0] + method_keyword_argument_list = test_method_data[1] + test_data_details = test_method_data[2] + + assert test_type[:3] in ['bas', 'der'] + + # For methods we need to test their __init__ function by calling the + # name of the constructor, which is the name of the class. + # (this is different from testing a function that is not in a class!) + # + test_method_name = test_method_names[1] + + print('Testing arguments for method/function:', test_method_name) + + for argument_name in test_data_details: + print(' Testing input argument:', argument_name) + + norm_test_data = test_data_details[argument_name][0] + exce_test_data = test_data_details[argument_name][1] + print(' Normal test cases: ', norm_test_data) + print(' Exception test cases:', exce_test_data) + + # Conduct normal tests - - - - - - - - - - - - - - - - - - - - - - - - + # + num_norm_test_cases = len(norm_test_data) + num_norm_test_passed = 0 + num_norm_test_failed = 0 + norm_failed_desc_str = '' + + for test_input in norm_test_data: + passed = True # Assume the test will pass :-) + + key_word_dict = {} + for i in range(len(method_keyword_argument_list)): + key_word_dict[method_keyword_argument_list[i]] = test_input[i] + print('Keyword dict normal:', key_word_dict) + + if test_type[:3] == 'bas': + try: + getattr(corruptor, test_method_name)(key_word_dict) + except: + passed = False + else: # For derived classes + try: + getattr(corruptor, test_method_name)(**key_word_dict) + except: + passed = False + + # Now process test results + # + if passed == False: + num_norm_test_failed += 1 + norm_failed_desc_str += 'Failed test for input ' + "'%s'; " % ( + str(test_input) + ) + else: + num_norm_test_passed += 1 + + assert num_norm_test_failed + num_norm_test_passed == num_norm_test_cases + + norm_test_result_str = ( + test_method_names[0] + + ',' + + test_method_names[1] + + ',' + + test_method_names[2] + + ',' + + argument_name + + ',normal,' + + '%d,' % (num_norm_test_cases) + ) + if num_norm_test_failed == 0: + norm_test_result_str += 'all tests passed' + else: + norm_test_result_str += '%d tests failed,' % (num_norm_test_failed) + norm_test_result_str += '"' + norm_failed_desc_str[:-2] + '"' + + test_res_list.append(norm_test_result_str) + + # Conduct exception tests - - - - - - - - - - - - - - - - - - - - - - - + # + num_exce_test_cases = len(exce_test_data) + num_exce_test_passed = 0 + num_exce_test_failed = 0 + exce_failed_desc_str = '' + + for test_input in exce_test_data: + passed = True # Assume the test will pass (i.e. raise an exception) + + key_word_dict = {} + for i in range(len(method_keyword_argument_list)): + key_word_dict[method_keyword_argument_list[i]] = test_input[i] + print('Keyword dict exception:', key_word_dict) + + if test_type[:3] == 'bas': + try: + self.assertRaises( + Exception, + getattr(corruptor, test_method_name), + key_word_dict, + ) + except: + passed = False + else: # For derived classes + try: + self.assertRaises( + Exception, + getattr(corruptor, test_method_name), + **key_word_dict + ) + except: + passed = False + + # Now process test results + # + if passed == False: + num_exce_test_failed += 1 + exce_failed_desc_str += 'Failed test for input ' + "'%s'; " % ( + str(test_input) + ) + else: + num_exce_test_passed += 1 + + assert num_exce_test_failed + num_exce_test_passed == num_exce_test_cases + + exce_test_result_str = ( + test_method_names[0] + + ',' + + test_method_names[1] + + ',' + + test_method_names[2] + + ',' + + argument_name + + ',exception,' + + '%d,' % (num_exce_test_cases) + ) + if num_exce_test_failed == 0: + exce_test_result_str += 'all tests passed' + else: + exce_test_result_str += '%d tests failed,' % (num_exce_test_failed) + exce_test_result_str += '"' + exce_failed_desc_str[:-2] + '"' + + test_res_list.append(exce_test_result_str) + + test_res_list.append('') # Empty line between tests of methods + + return test_res_list + + # --------------------------------------------------------------------------- + + def testFunct_position_mod_uniform(self): + """Test that this position function only returns positions with then range + of the given string length. + """ + + print('Testing functionality of "position_mod_uniform"') + + num_passed = 0 + num_failed = 0 + + all_tests = ( + self.letter_string_list + self.digit_string_list + self.mixed_string_list + ) + + for test_str in all_tests: + t_len = len(test_str) + pos = corruptor.position_mod_uniform(test_str) + + if (pos < 0) or (pos >= t_len): + num_failed += 1 + else: + num_passed += 1 + + assert num_passed + num_failed == len(all_tests) + + test_result_str = 'corruptor,n/a,position_mod_uniform,' + 'n/a,funct,%d,' % ( + num_tests + ) + if num_failed == 0: + test_result_str += 'all tests passed' + else: + test_result_str += '%d tests failed' % (num_failed) + + return [test_result_str, ''] + + # --------------------------------------------------------------------------- + + def testFunct_position_mod_normal(self): + """Test that this position function only returns positions with then range + of the given string length. + """ + + print('Testing functionality of "position_mod_normal"') + + num_passed = 0 + num_failed = 0 + + all_tests = ( + self.letter_string_list + self.digit_string_list + self.mixed_string_list + ) + + for test_str in all_tests: + t_len = len(test_str) + pos = corruptor.position_mod_normal(test_str) + + if (pos < 0) or (pos >= t_len): + num_failed += 1 + else: + num_passed += 1 + + assert num_passed + num_failed == len(all_tests) + + test_result_str = 'corruptor,n/a,position_mod_normal,' + 'n/a,funct,%d,' % ( + len(all_tests) + ) + if num_failed == 0: + test_result_str += 'all tests passed' + else: + test_result_str += '%d tests failed' % (num_failed) + + return [test_result_str, ''] + + # --------------------------------------------------------------------------- + + def testFunct_CorruptMissingValue(self): + """Test that this method only returns the specified missing value.""" + + print('Testing functionality of "CorruptMissingValue"') + + num_passed = 0 + num_failed = 0 + + empty_corruptor = corruptor.CorruptMissingValue() + miss_corruptor = corruptor.CorruptMissingValue(missing_val='miss') + na_corruptor = corruptor.CorruptMissingValue(missing_val='n/a') + + all_tests = ( + self.letter_string_list + self.digit_string_list + self.mixed_string_list + ) + + for test_str in all_tests: + passed = True + res_str = empty_corruptor.corrupt_value(test_str) + if res_str != '': + passed = False + + res_str = miss_corruptor.corrupt_value(test_str) + if res_str != 'miss': + passed = False + + res_str = miss_corruptor.corrupt_value(test_str) + if res_str != 'miss': + passed = False + + if passed == True: + num_passed += 1 + else: + num_failed += 1 + + assert num_passed + num_failed == len(all_tests) + + test_result_str = ( + 'corruptor,CorruptMissingValue,corrupt_value,' + + 'n/a,funct,%d,' % (len(all_tests)) + ) + if num_failed == 0: + test_result_str += 'all tests passed' + else: + test_result_str += '%d tests failed' % (num_failed) + + return [test_result_str, ''] + + # --------------------------------------------------------------------------- + + def testFunct_CorruptValueEdit(self): + """Test that this method only returns modified values with a single edit + according to the argument setting. + """ + + print('Testing functionality of "CorruptValueEdit"') + + num_passed = 0 + num_failed = 0 + + ins_edit_corruptor = corruptor.CorruptValueEdit( + position_function=corruptor.position_mod_uniform, + char_set_funct=basefunctions.char_set_ascii, + insert_prob=1.0, + delete_prob=0.0, + substitute_prob=0.0, + transpose_prob=0.0, + ) + + del_edit_corruptor = corruptor.CorruptValueEdit( + position_function=corruptor.position_mod_uniform, + char_set_funct=basefunctions.char_set_ascii, + insert_prob=0.0, + delete_prob=1.0, + substitute_prob=0.0, + transpose_prob=0.0, + ) + + sub_edit_corruptor = corruptor.CorruptValueEdit( + position_function=corruptor.position_mod_uniform, + char_set_funct=basefunctions.char_set_ascii, + insert_prob=0.0, + delete_prob=0.0, + substitute_prob=1.0, + transpose_prob=0.0, + ) + + tra_edit_corruptor = corruptor.CorruptValueEdit( + position_function=corruptor.position_mod_uniform, + char_set_funct=basefunctions.char_set_ascii, + insert_prob=0.0, + delete_prob=0.0, + substitute_prob=0.0, + transpose_prob=1.0, + ) + + ins_del_edit_corruptor = corruptor.CorruptValueEdit( + position_function=corruptor.position_mod_uniform, + char_set_funct=basefunctions.char_set_ascii, + insert_prob=0.5, + delete_prob=0.5, + substitute_prob=0.0, + transpose_prob=0.0, + ) + + sub_tra_edit_corruptor = corruptor.CorruptValueEdit( + position_function=corruptor.position_mod_uniform, + char_set_funct=basefunctions.char_set_ascii, + insert_prob=0.0, + delete_prob=0.0, + substitute_prob=0.5, + transpose_prob=0.5, + ) + + all_tests = ( + self.letter_string_list + self.digit_string_list + self.mixed_string_list + ) + + for test_str in all_tests: + passed = True + + res_str = ins_edit_corruptor.corrupt_value(test_str) + if len(res_str) != len(test_str) + 1: + passed = False + if test_str.isalpha(): + if not res_str.isalpha(): + passed = False + elif test_str.isdigit(): + if not res_str.isdigit(): + passed = False + + res_str = del_edit_corruptor.corrupt_value(test_str) + if len(res_str) != len(test_str) - 1: + passed = False + if (res_str != '') and test_str.isalpha(): + if not res_str.isalpha(): + passed = False + elif (res_str != '') and test_str.isdigit(): + if not res_str.isdigit(): + passed = False + + res_str = sub_edit_corruptor.corrupt_value(test_str) + if len(res_str) != len(test_str): + passed = False + if test_str.isalpha(): + if not res_str.isalpha(): + passed = False + elif test_str.isdigit(): + if not res_str.isdigit(): + passed = False + + res_str = tra_edit_corruptor.corrupt_value(test_str) + if len(res_str) != len(test_str): + passed = False + if test_str.isalpha(): + if not res_str.isalpha(): + passed = False + elif test_str.isdigit(): + if not res_str.isdigit(): + passed = False + + res_str = ins_del_edit_corruptor.corrupt_value(test_str) + if abs(len(res_str) - len(test_str)) != 1: + passed = False + if (res_str != '') and test_str.isalpha(): + if not res_str.isalpha(): + passed = False + elif (res_str != '') and test_str.isdigit(): + if not res_str.isdigit(): + passed = False + + res_str = sub_tra_edit_corruptor.corrupt_value(test_str) + if len(res_str) != len(test_str): + passed = False + if test_str.isalpha(): + if not res_str.isalpha(): + passed = False + elif test_str.isdigit(): + if not res_str.isdigit(): + passed = False + + if passed == True: + num_passed += 1 + else: + num_failed += 1 + + assert num_passed + num_failed == len(all_tests) + + test_result_str = 'corruptor,CorruptValueEdit,corrupt_value,' + 'n/a,funct,%d,' % ( + len(all_tests) + ) + if num_failed == 0: + test_result_str += 'all tests passed' + else: + test_result_str += '%d tests failed' % (num_failed) + + return [test_result_str, ''] + + # --------------------------------------------------------------------------- + + def testFunct_CorruptValueKeyboard(self): + """Test that this method only returns modified values with a single edit + and correct character according to the argument setting. + """ + + print('Testing functionality of "CorruptValueKeyboard"') + + num_passed = 0 + num_failed = 0 + + rows = { + 'a': 's', + 'b': 'vn', + 'c': 'xv', + 'd': 'sf', + 'e': 'wr', + 'f': 'dg', + 'g': 'fh', + 'h': 'gj', + 'i': 'uo', + 'j': 'hk', + 'k': 'jl', + 'l': 'k', + 'm': 'n', + 'n': 'bm', + 'o': 'ip', + 'p': 'o', + 'q': 'w', + 'r': 'et', + 's': 'ad', + 't': 'ry', + 'u': 'yi', + 'v': 'cb', + 'w': 'qe', + 'x': 'zc', + 'y': 'tu', + 'z': 'x', + '1': '2', + '2': '13', + '3': '24', + '4': '35', + '5': '46', + '6': '57', + '7': '68', + '8': '79', + '9': '80', + '0': '9', + } + + cols = { + 'a': 'qzw', + 'b': 'gh', + 'c': 'df', + 'd': 'erc', + 'e': 'ds34', + 'f': 'rvc', + 'g': 'tbv', + 'h': 'ybn', + 'i': 'k89', + 'j': 'umn', + 'k': 'im', + 'l': 'o', + 'm': 'jk', + 'n': 'hj', + 'o': 'l90', + 'p': '0', + 'q': 'a12', + 'r': 'f45', + 's': 'wxz', + 't': 'g56', + 'u': 'j78', + 'v': 'fg', + 'w': 's23', + 'x': 'sd', + 'y': 'h67', + 'z': 'as', + '1': 'q', + '2': 'qw', + '3': 'we', + '4': 'er', + '5': 'rt', + '6': 'ty', + '7': 'yu', + '8': 'ui', + '9': 'io', + '0': 'op', + } + + row_keyboard_corruptor = corruptor.CorruptValueKeyboard( + position_function=corruptor.position_mod_uniform, row_prob=1.0, col_prob=0.0 + ) + + col_keyboard_corruptor = corruptor.CorruptValueKeyboard( + position_function=corruptor.position_mod_uniform, row_prob=0.0, col_prob=1.0 + ) + + all_tests = ( + self.letter_string_list + self.digit_string_list + self.mixed_string_list + ) + + for test_str in all_tests: + passed = True + test_str_mod_list = [] + res_str_mod_list = [] + + res_str = row_keyboard_corruptor.corrupt_value(test_str) + + if len(res_str) != len(test_str): + passed = False + + else: + for i in range(len(test_str)): + if res_str[i] != test_str[i]: + test_str_mod_list.append(test_str[i]) + res_str_mod_list.append(res_str[i]) + if (len(test_str_mod_list) != 1) or (len(res_str_mod_list) != 1): + passed = False + + else: + test_str_mod_char = test_str_mod_list[0] + res_str_mod_char = res_str_mod_list[0] + row_chars = rows[test_str_mod_char] + if res_str_mod_char not in row_chars: + passed = False + + test_str_mod_list = [] + res_str_mod_list = [] + + res_str = col_keyboard_corruptor.corrupt_value(test_str) + + if len(res_str) != len(test_str): + passed = False + + else: + for i in range(len(test_str)): + if res_str[i] != test_str[i]: + test_str_mod_list.append(test_str[i]) + res_str_mod_list.append(res_str[i]) + if (len(test_str_mod_list) != 1) or (len(res_str_mod_list) != 1): + passed = False + + else: + test_str_mod_char = test_str_mod_list[0] + res_str_mod_char = res_str_mod_list[0] + col_chars = cols[test_str_mod_char] + if res_str_mod_char not in col_chars: + passed = False + + if passed == True: + num_passed += 1 + else: + num_failed += 1 + + assert num_passed + num_failed == len(all_tests) + + test_result_str = ( + 'corruptor,CorruptValueKeyboard,corrupt_value,' + + 'n/a,funct,%d,' % (len(all_tests)) + ) + if num_failed == 0: + test_result_str += 'all tests passed' + else: + test_result_str += '%d tests failed' % (num_failed) + + return [test_result_str, ''] + + # --------------------------------------------------------------------------- + + def testFunct_CorruptValueOCR(self): + """Test that this method returns modified values with the appropriate + characters replaced according to the values in the lookup file. + """ + + print('Testing functionality of "CorruptValueOCR"') + + num_passed = 0 + num_failed = 0 + + max_chars = 3 + + # Load the lookup file and store the values in a dictionary + # + header_list, file_data = basefunctions.read_csv_file( + '../lookup-files/ocr-variations.csv', 'ascii', False + ) + + ocr_dict = {} + + for ocr_pair_list in file_data: + + org_val = ocr_pair_list[0].strip() + sub_val = ocr_pair_list[1].strip() + + if org_val not in ocr_dict: + ocr_dict[org_val] = [sub_val] + else: + sub_val_list = ocr_dict[org_val] + sub_val_list.append(sub_val) + + if sub_val not in ocr_dict: + ocr_dict[sub_val] = [org_val] + else: + org_val_list = ocr_dict[sub_val] + org_val_list.append(org_val) + + # print(cr_dict) + + # Run the tests + # + all_tests = ( + self.letter_string_list + self.digit_string_list + self.mixed_string_list + ) + + for test_str in all_tests: + + passed = True + test_str_mod = u'' + res_str_mod = u'' + + res_str = ocr_corruptor.corrupt_value(test_str) + + if test_str != res_str: + if len(test_str) == len(res_str): # same lenth + passed = False + iter_loop = True + for i in range(len(test_str)): + if res_str[i] != test_str[i]: + x = 0 + while ( + (iter_loop == True) + and (x <= max_chars) + and ((i + x) < len(test_str)) + ): + test_str_mod += test_str[i + x] + res_str_mod += res_str[i + x] + if test_str_mod in ocr_dict: + subs_chars = ocr_dict[test_str_mod] + if res_str_mod in subs_chars: + passed = True + iter_loop = False + x += 1 + + else: # different lengths + passed = False + if len(test_str) > len(res_str): + smaller_string = res_str + longer_string = test_str + elif len(test_str) < len(res_str): + smaller_string = test_str + longer_string = res_str + iter_loop = True + for i in range(len(smaller_string)): + test_str_mod = '' + if smaller_string[i] != longer_string[i]: + x = 0 + while ( + (iter_loop == True) + and (x <= max_chars) + and ((i + x) < len(longer_string)) + ): + test_str_mod += longer_string[i + x] + y = 0 + res_str_mod = '' + while ( + (iter_loop == True) + and (y <= max_chars) + and ((i + y) < len(smaller_string)) + ): + res_str_mod += smaller_string[i + y] + if test_str_mod in ocr_dict: + subs_chars = ocr_dict[test_str_mod] + if res_str_mod in subs_chars: + passed = True + iter_loop = False + y += 1 + x += 1 + else: # remaining characters in the longer string + if i == len(smaller_string) - 1: + test_str_mod = smaller_string[len(smaller_string) - 1] + res_str_mod = longer_string[len(smaller_string) - 1 :] + if test_str_mod in ocr_dict: + subs_chars = ocr_dict[test_str_mod] + if res_str_mod in subs_chars: + passed = True + + if passed == True: + num_passed += 1 + else: + num_failed += 1 + + # assert num_passed + num_failed == len(all_tests) + + test_result_str = 'corruptor,CorruptValueOCR,corrupt_value,' + 'n/a,funct,%d,' % ( + len(all_tests) + ) + if num_failed == 0: + test_result_str += 'all tests passed' + else: + test_result_str += '%d tests failed' % (num_failed) + + return [test_result_str, ''] + + # --------------------------------------------------------------------------- + + def testFunct_CorruptValuePhonetic(self): + """Test that this method returns modified values with the + correct characters replaced according to the phonetic rules + specified in the lookup file. + """ + + print('Testing functionality of "CorruptValuePhonetic"') + + num_passed = 0 + num_failed = 0 + + max_chars = 5 # max number of characters that can be replaced + # according to the lookup file + + slab_width = 2 # max number of characters to be searched for + # in forward and backward + + # Load the lookup file and store the values in a dictionary + # + header_list, file_data = basefunctions.read_csv_file( + '../lookup-files/phonetic-variations.csv', 'ascii', False + ) + + phonetic_dict = {} + + for rule_list in file_data: + + pos_val = rule_list[0].strip() + org_val = rule_list[1].strip() + sub_val = rule_list[2].strip() + + if org_val not in phonetic_dict: + phonetic_dict[org_val] = [sub_val] + else: + sub_val_list = phonetic_dict[org_val] + if sub_val not in sub_val_list: + sub_val_list.append(sub_val) + + if sub_val not in phonetic_dict: + phonetic_dict[sub_val] = [org_val] + else: + org_val_list = phonetic_dict[sub_val] + if org_val not in org_val_list: + org_val_list.append(org_val) + + # print(honetic_dict) + + # Load surnames from a lookup file + # + surname_list = [] + header_list, file_data = basefunctions.read_csv_file( + '../lookup-files/surname-misspell.csv', 'ascii', False + ) + + for val_pair in file_data: + org_val = val_pair[0].strip() + sub_val = val_pair[1].strip() + + if org_val not in surname_list: + surname_list.append(org_val) + if sub_val not in surname_list: + surname_list.append(sub_val) + + # Run the tests + # + all_tests = self.letter_string_list + surname_list + + for test_str in all_tests: + + passed = True + test_str_mod = u'' + res_str_mod = u'' + + res_str = phonetic_corruptor.corrupt_value(test_str) + + # test_str = 'szd' + # res_str = 'sd' + + if test_str != res_str: + if len(test_str) == len(res_str): # same length + passed = False + iter_loop = True + for i in range(len(test_str)): + if res_str[i] != test_str[i]: + x = 0 + while ( + (iter_loop == True) + and (x <= max_chars) + and ((i + x) < len(test_str)) + ): + test_str_mod += test_str[i + x] + res_str_mod += res_str[i + x] + for k, v in phonetic_dict.items(): + if (test_str_mod in k) or (k in test_str_mod): + subs_chars = phonetic_dict[k] + for v2 in subs_chars: + if (res_str_mod in v2) or (v2 in res_str_mod): + passed = True + iter_loop = False + x += 1 + + else: # different lengths + passed = False + if len(test_str) > len(res_str): + smaller_string = res_str + longer_string = test_str + elif len(test_str) < len(res_str): + smaller_string = test_str + longer_string = res_str + iter_loop = True + for i in range(len(smaller_string)): + test_str_mod = '' + if smaller_string[i] != longer_string[i]: + if i >= slab_width: + x = -slab_width + else: + x = -i + while ( + (iter_loop == True) + and (x <= max_chars) + and (0 <= (i + x) < len(longer_string)) + ): + test_str_mod += longer_string[i + x] + if i >= slab_width: + y = -slab_width + else: + y = -i + res_str_mod = '' + while ( + (iter_loop == True) + and (y <= max_chars) + and (0 <= (i + y) < len(smaller_string)) + ): + res_str_mod += smaller_string[i + y] + for k, v in phonetic_dict.items(): + if (test_str_mod in k) or (k in test_str_mod): + subs_chars = phonetic_dict[k] + for v2 in subs_chars: + if (res_str_mod in v2) or ( + v2 in res_str_mod + ): + passed = True + iter_loop = False + y += 1 + x += 1 + else: # remaining characters of longer string + if i == len(smaller_string) - 1: + if len(smaller_string) > slab_width: + test_str_mod = smaller_string[ + len(smaller_string) - 1 - slab_width : + ] + else: + test_str_mod = smaller_string[ + len(smaller_string) - 1 - i : + ] + if len(longer_string) > slab_width: + res_str_mod = longer_string[ + len(smaller_string) - 1 - slab_width : + ] + else: + res_str_mod = longer_string[ + len(smaller_string) - 1 - i : + ] + for k, v in phonetic_dict.items(): + if (test_str_mod in k) or (k in test_str_mod): + subs_chars = phonetic_dict[k] + for v2 in subs_chars: + if (res_str_mod in v2) or (v2 in res_str_mod): + passed = True + + if passed == False: + # check for characters removed from the original str -test_str + diff_list = [] + d = difflib.Differ() + l = list(d.compare(test_str, res_str)) + for diff_val in l: + if diff_val.startswith("- "): + diff_list.append(diff_val[-1:]) + if len(test_str) - len(res_str) == 1: + if (len(diff_list) == 1) and ( + diff_list[0] in ['h', 'e', 'w', 'x'] + ): + passed = True + elif len(test_str) - len(res_str) == 2: + if len(diff_list) == 2: + if ('g' in diff_list) and ('h' in diff_list): + passed = True + elif ('x' in diff_list) and ('c' in diff_list): + passed = True + elif diff_list[0] == 'x' and diff_list[1] == 'x': + passed = True + + if passed == False: + print('fail test,', test_str, res_str, test_str_mod, res_str_mod) + + if passed == True: + num_passed += 1 + else: + num_failed += 1 + + assert num_passed + num_failed == len(all_tests) + + test_result_str = ( + 'corruptor,CorruptValuePhonetic,corrupt_value,' + + 'n/a,funct,%d,' % (len(all_tests)) + ) + if num_failed == 0: + test_result_str += 'all tests passed' + else: + test_result_str += '%d tests failed' % (num_failed) + + return [test_result_str, ''] + + # --------------------------------------------------------------------------- + + def testFunct_CorruptCategoricalValue(self): + """Test that this method only returns modified values with the correct + misspelling according to the argument setting. + """ + + print('Testing functionality of "CorruptCategoricalValue"') + + num_passed = 0 + num_failed = 0 + + # Load the lookup file and store the values in a dictionary + # + header_list, file_data = basefunctions.read_csv_file( + '../lookup-files/surname-misspell.csv', 'ascii', False + ) + + misspell_dict = {} + org_val_list = [] + + for misspell_pair_list in file_data: + + org_val = misspell_pair_list[0].strip() + sub_val = misspell_pair_list[1].strip() + + if org_val not in misspell_dict: + misspell_dict[org_val] = [sub_val] + org_val_list.append(org_val) + else: + sub_val_list = misspell_dict[org_val] + sub_val_list.append(sub_val) + + # print(isspell_dict) + + # Run the tests + # + + for test_str in org_val_list: + passed = True + + res_str = surname_misspell_corruptor.corrupt_value(test_str) + + if res_str != test_str: + if res_str not in misspell_dict[test_str]: + passed = False + + if passed == True: + num_passed += 1 + else: + num_failed += 1 + + assert num_passed + num_failed == len(org_val_list) + + test_result_str = ( + 'corruptor,CorruptCategoricalValue,corrupt_value,' + + 'n/a,funct,%d,' % (len(org_val_list)) + ) + if num_failed == 0: + test_result_str += 'all tests passed' + else: + test_result_str += '%d tests failed' % (num_failed) + + return [test_result_str, ''] + + +# ============================================================================= +# Generate a time string to be used for the log file +# +curr_time_tuple = time.localtime() +curr_time_str = ( + str(curr_time_tuple[0]) + + str(curr_time_tuple[1]).zfill(2) + + str(curr_time_tuple[2]).zfill(2) + + '-' + + str(curr_time_tuple[3]).zfill(2) + + str(curr_time_tuple[4]).zfill(2) +) + +# Write test output header line into the log file +# +out_file_name = './logs/corruptorTest-%s.csv' % (curr_time_str) + +out_file = open(out_file_name, 'w') + +out_file.write('Test results generated by corruptorTest.py' + os.linesep) + +out_file.write('Test started: ' + curr_time_str + os.linesep) + +out_file.write(os.linesep) + +out_file.write( + 'Module name,Class name,Method name,Arguments,Test_type,' + + 'Patterns tested,Summary,Failure description' + + os.linesep +) +out_file.write(os.linesep) + +# Create instances for the testcase class that calls all tests +# +test_res_list = [] +test_case_ins = TestCase('testArguments') +test_res_list += test_case_ins.testArguments(test_argument_data_dict) + +# Add inidividual functionality tests here +# +test_case_ins = TestCase('testFunct_position_mod_uniform') +test_case_ins.setUp() +test_res_list += test_case_ins.testFunct_position_mod_uniform() + +test_case_ins = TestCase('testFunct_position_mod_normal') +test_case_ins.setUp() +test_res_list += test_case_ins.testFunct_position_mod_normal() + +test_case_ins = TestCase('testFunct_CorruptMissingValue') +test_case_ins.setUp() +test_res_list += test_case_ins.testFunct_CorruptMissingValue() + +test_case_ins = TestCase('testFunct_CorruptValueEdit') +test_case_ins.setUp() +test_res_list += test_case_ins.testFunct_CorruptValueEdit() + +test_case_ins = TestCase('testFunct_CorruptValueKeyboard') +test_case_ins.setUp() +test_res_list += test_case_ins.testFunct_CorruptValueKeyboard() + +test_case_ins = TestCase('testFunct_CorruptValueOCR') +test_case_ins.setUp() +test_res_list += test_case_ins.testFunct_CorruptValueOCR() + +test_case_ins = TestCase('testFunct_CorruptValuePhonetic') +test_case_ins.setUp() +test_res_list += test_case_ins.testFunct_CorruptValuePhonetic() + +test_case_ins = TestCase('testFunct_CorruptCategoricalValue') +test_case_ins.setUp() +test_res_list += test_case_ins.testFunct_CorruptCategoricalValue() + +# Write test output results into the log file +# +for line in test_res_list: + out_file.write(line + os.linesep) + +out_file.close() + +print('Test results are written to', out_file_name) + +for line in test_res_list: + print(line) + +# ============================================================================= diff --git a/tests/generator_test.py b/tests/generator_test.py new file mode 100644 index 0000000000000000000000000000000000000000..84fdfb84d35c93d43ac0e21641a6b7fc31b08cbf --- /dev/null +++ b/tests/generator_test.py @@ -0,0 +1,3961 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# ============================================================================= +# Import necessary modules (Python standard modules first, then system modules) + +import os +import random + +random.seed(42) +import time +import unittest + +from geco_data_generator import attrgenfunct, basefunctions, contdepfunct, generator + + +# ============================================================================= + +# Define the number of tests to be done for the functionality tests +# +num_tests = 10000 + +# Define dummy correct test functions with between 0 and 5 arguments and that +# return a string +# +def test_function0(): + return 'test0' + + +def test_function1(a1): + return 'test1: ' + str(a1) + + +def test_function2(a1, a2): + return 'test2: ' + str(a1) + ',' + str(a2) + + +def test_function3(a1, a2, a3): + return 'test3: ' + str(a1) + ',' + str(a2) + ',' + str(a3) + + +def test_function4(a1, a2, a3, a4): + return 'test4: ' + str(a1) + ',' + str(a2) + ',' + str(a3) + ',' + str(a4) + + +def test_function5(a1, a2, a3, a4, a5): + return ( + 'test5: ' + str(a1) + ',' + str(a2) + ',' + str(a3) + ',' + str(a4) + ',' + str(a5) + ) + + +# Define several functions that should trigger an exception +# +def test_exce_function0(): + return 999.99 + + +def test_exce_function1(): + return 1999 + + +def test_exce_function2(a1, a2, a3, a4, a5, a6): + return '' + + +# Define dummy correct test functions that take a floating-point value as +# input and that return a floating-point value +def test_cont_function1(f1): + return f1 * 2.0 + + +def test_cont_function2(f1): + return f1 + + +def test_cont_function3(f1): + return 10.0 + + +def test_cont_function4(f1): + return -123.456 + + +# Define dummy exception test functions that do not +# return a floating-point value +def test_exce_cont_function1(f1): + return str(f1 * 2.0) + + +def test_exce_cont_function2(f1): + return int(10) + + +def test_exce_cont_function3(f1): + return 'test' + + +# Define example data structures for attributes +# +gname_attr = generator.GenerateFreqAttribute( + attribute_name='attr1', + freq_file_name='../lookup-files/givenname_f_freq.csv', + has_header_line=False, + unicode_encoding='ascii', +) + +postcode_attr = generator.GenerateFreqAttribute( + attribute_name='attr2', + freq_file_name='../lookup-files/postcode_act_freq.csv', + has_header_line=False, + unicode_encoding='ascii', +) + +age_uniform_attr = generator.GenerateFuncAttribute( + attribute_name='attr3', function=attrgenfunct.generate_uniform_age, parameters=[0, 120] +) + +gender_city_comp_attr = generator.GenerateCateCateCompoundAttribute( + categorical1_attribute_name='gender', + categorical2_attribute_name='city', + lookup_file_name='../lookup-files/gender-city.csv', + has_header_line=True, + unicode_encoding='ascii', +) + +gender_income_comp_attr = generator.GenerateCateContCompoundAttribute( + categorical_attribute_name='gender2', + continuous_attribute_name='income', + continuous_value_type='float1', + lookup_file_name='../lookup-files/gender-income.csv', + has_header_line=False, + unicode_encoding='ascii', +) + +gender_city_income_comp_attr = generator.GenerateCateCateContCompoundAttribute( + categorical1_attribute_name='gender3', + categorical2_attribute_name='city2', + continuous_attribute_name='income2', + continuous_value_type='float4', + lookup_file_name='../lookup-files/gender-city-income.csv', + has_header_line=False, + unicode_encoding='ascii', +) + +age_blood_pressure_comp_attr = generator.GenerateContContCompoundAttribute( + continuous1_attribute_name='age', + continuous2_attribute_name='blood-pressure', + continuous1_funct_name='uniform', + continuous1_funct_param=[10, 110], + continuous2_function=contdepfunct.blood_pressure_depending_on_age, + continuous1_value_type='int', + continuous2_value_type='float3', +) + +# Define example attribute data lists +# +attr_data_list1 = [gname_attr] +attr_data_list2 = [gname_attr, postcode_attr] +attr_data_list3 = [gname_attr, postcode_attr, age_uniform_attr] +attr_data_list4 = [gname_attr, gender_city_comp_attr, postcode_attr] + +# Define argument test cases here +# +test_argument_data_dict = { + ('generator', 'GenerateAttribute', 'constructor (__init__)'): [ + 'base', + ['attribute_name'], + { + 'attribute_name': [ + [['test'], ['1234'], ['myattribute']], + [[''], [12], [12.54], [{}], [[]]], + ] + }, + ], + # + ('generator', 'GenerateFuncAttribute', 'constructor (__init__)'): [ + 'derived', + ['attribute_name', 'function', 'parameters'], + { + 'attribute_name': [ + [ + ['test', test_function0, []], + ['1234', test_function1, [66]], + ['myattribute', test_function2, [66, 'pop']], + ['myatt1', test_function3, ['pop2', '55', '']], + ['myatt2', test_function4, [11, 22, 33, 44]], + ['myatt', test_function5, [11, None, '33', 44, '55']], + ], + [ + ['', test_function0, []], + [1234, test_function1, [66]], + [{}, test_function2, [66, 'pop']], + [-12.54, test_function3, ['pop2', '55', '']], + [[], test_function4, [11, 22, 33, 44]], + [None, test_function5, [11, None, '33', 44, '55']], + ], + ], + 'function': [ + [ + ['test', test_function0, []], + ['1234', test_function1, [66]], + ['myattribute', test_function2, [66, 'pop']], + ['myatt1', test_function3, ['pop2', '55', '']], + ['myatt2', test_function4, [11, 22, 33, 44]], + ['myatt', test_function5, [11, None, '33', 44, '55']], + ], + [ + ['test', test_exce_function0, None], + ['1234', test_exce_function1, [66]], + ['myattribute', test_exce_function2, [66, 'pop']], + ], + ], + 'parameters': [ + [ + ['test', test_function0, []], + ['1234', test_function1, [66]], + ['myattribute', test_function2, [66, 'pop']], + ['myatt1', test_function3, ['pop2', '55', '']], + ['myatt2', test_function4, [11, 22, 33, 44]], + ['myatt', test_function5, [11, None, '33', 44, '55']], + ], + [ + ['test', test_function0, [1, 2, 3, 4, 5, 6, 7, 8]], + ['1234', test_function1, [66, 6, 7, 4, 8, 56, 9, 0, 66]], + ['myattribute', test_function2, ['pop']], + ['myatt1', test_function3, [{}]], + ], + ], + }, + ], + # + ('generator', 'GenerateFreqAttribute', 'constructor (__init__)'): [ + 'derived', + ['attribute_name', 'freq_file_name', 'has_header_line', 'unicode_encoding'], + { + 'attribute_name': [ + [ + ['test', '../lookup-files/givenname_f_freq.csv', False, 'ascii'], + ['1234', '../lookup-files/givenname_f_freq.csv', False, 'ascii'], + [ + 'myattribute', + '../lookup-files/givenname_f_freq.csv', + False, + 'ascii', + ], + ['myatt1', '../lookup-files/givenname_f_freq.csv', False, 'ascii'], + ['myatt2', '../lookup-files/givenname_f_freq.csv', False, 'ascii'], + ['myatt', '../lookup-files/givenname_f_freq.csv', False, 'ascii'], + ], + [ + ['', '../lookup-files/givenname_f_freq.csv', False, 'ascii'], + [1234, '../lookup-files/givenname_f_freq.csv', False, 'ascii'], + [{}, '../lookup-files/givenname_f_freq.csv', False, 'ascii'], + [-12.54, '../lookup-files/givenname_f_freq.csv', False, 'ascii'], + [[], '../lookup-files/givenname_f_freq.csv', False, 'ascii'], + [None, '../lookup-files/givenname_f_freq.csv', False, 'ascii'], + ], + ], + 'freq_file_name': [ + [ + ['myatt1', '../lookup-files/givenname_f_freq.csv', False, 'ascii'], + ['myatt1', '../lookup-files/givenname_m_freq.csv', False, 'ascii'], + ['myatt1', '../lookup-files/postcode_act_freq.csv', False, 'ascii'], + ], + [ + ['myatt1', None, False, 'ascii'], + ['myatt1', '../lookup-files/gender-income.csv', False, 'ascii'], + ['myatt1', '.../lookup-files/givenname_f_freq.csv', False, 'ascii'], + ['myatt1', '', False, 'ascii'], + ], + ], + 'has_header_line': [ + [ + ['myatt1', '../lookup-files/givenname_f_freq.csv', True, 'ascii'], + ['myatt1', '../lookup-files/givenname_f_freq.csv', False, 'ascii'], + ['myatt1', '../lookup-files/givenname_f_freq.csv', 1, 'ascii'], + ['myatt1', '../lookup-files/givenname_f_freq.csv', 0, 'ascii'], + ['myatt1', '../lookup-files/givenname_f_freq.csv', 1.00, 'ascii'], + ], + [ + ['myatt1', '/lookup-files/givenname_f_freq.csv', None, 'ascii'], + ['myatt1', '/lookup-files/givenname_f_freq.csv', 'true', 'ascii'], + ['myatt1', '../lookup-files/givenname_f_freq.csv', 1.0001, 'ascii'], + ['myatt1', '', '1.0', 'ascii'], + ], + ], + 'unicode_encoding': [ + [ + ['myatt1', '../lookup-files/givenname_f_freq.csv', False, 'ascii'], + [ + 'myatt1', + '../lookup-files/givenname_f_freq.csv', + False, + 'iso-8859-1', + ], + ['myatt1', '../lookup-files/givenname_f_freq.csv', False, 'ASCII'], + [ + 'myatt1', + '../lookup-files/givenname_f_freq.csv', + False, + 'iso-2022-jp', + ], + ], + [ + ['myatt1', '../lookup-files/givenname_f_freq.csv', False, ''], + ['myatt1', '../lookup-files/givenname_f_freq.csv', False, 'hello'], + ['myatt1', '../lookup-files/givenname_f_freq.csv', False, None], + ], + ], + }, + ], + # 'GenerateCompoundAttribute' base class does not have any arguments to be + # initialiszed + # + ('generator', 'GenerateCateCateCompoundAttribute', 'constructor (__init__)'): [ + 'derived', + [ + 'categorical1_attribute_name', + 'categorical2_attribute_name', + 'lookup_file_name', + 'has_header_line', + 'unicode_encoding', + ], + { + 'categorical1_attribute_name': [ + [ + [ + 'myattr1', + 'myattr2', + '../lookup-files/gender-city.csv', + True, + 'ascii', + ], + ['attr1', 'myattr2', '../lookup-files/gender-city.csv', True, 'ascii'], + [ + 'attribute1', + 'myattr2', + '../lookup-files/gender-city.csv', + True, + 'ascii', + ], + [ + 'Surname', + 'myattr2', + '../lookup-files/gender-city.csv', + True, + 'ascii', + ], + ['att1', 'myattr2', '../lookup-files/gender-city.csv', True, 'ascii'], + ['1234', 'myattr2', '../lookup-files/gender-city.csv', True, 'ascii'], + ], + [ + ['', 'myattr2', '../lookup-files/gender-city.csv', True, 'ascii'], + [1234, 'myattr2', '../lookup-files/gender-city.csv', True, 'ascii'], + [{}, 'myattr2', '../lookup-files/gender-city.csv', True, 'ascii'], + [-12.54, 'myattr2', '../lookup-files/gender-city.csv', True, 'ascii'], + [[], 'myattr2', '../lookup-files/gender-city.csv', True, 'ascii'], + [None, 'myattr2', '../lookup-files/gender-city.csv', True, 'ascii'], + ], + ], + 'categorical2_attribute_name': [ + [ + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-city.csv', + True, + 'ascii', + ], + [ + 'myatt1', + 'attribute2', + '../lookup-files/gender-city.csv', + True, + 'ascii', + ], + ['myatt1', 'attr2', '../lookup-files/gender-city.csv', True, 'ascii'], + ['myatt1', 'myatt2', '../lookup-files/gender-city.csv', True, 'ascii'], + ['myatt1', 'att2', '../lookup-files/gender-city.csv', True, 'ascii'], + [ + 'myatt1', + 'Given Name', + '../lookup-files/gender-city.csv', + True, + 'ascii', + ], + ], + [ + ['myatt1', '', '../lookup-files/gender-city.csv', True, 'ascii'], + ['myatt1', 1234, '../lookup-files/gender-city.csv', True, 'ascii'], + ['myatt1', {}, '../lookup-files/gender-city.csv', True, 'ascii'], + ['myattr1', [], '../lookup-files/gender-city.csv', True, 'ascii'], + ['myattr1', -12.34, '../lookup-files/gender-city.csv', True, 'ascii'], + ['myattr1', None, '../lookup-files/gender-city.csv', True, 'ascii'], + ], + ], + 'lookup_file_name': [ + [['myatt1', 'myattr2', '../lookup-files/gender-city.csv', True, 'ascii']], + [ + ['myatt1', 'myattr2', None, True, 'ascii'], + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-income.csv', + True, + 'ascii', + ], + [ + 'myatt1', + 'myattr2', + '.../lookup-files/gender-city.csv', + True, + 'ascii', + ], + ['myatt1', 'myattr2', '', True, 'ascii'], + ], + ], + 'has_header_line': [ + [ + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-city.csv', + True, + 'ascii', + ], + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-city.csv', + True, + 'ascii', + ], + ['myatt1', 'myattr2', '../lookup-files/gender-city.csv', 1, 'ascii'], + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-city.csv', + 1.00, + 'ascii', + ], + ], + [ + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-city.csv', + None, + 'ascii', + ], + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-city.csv', + False, + 'ascii', + ], + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-city.csv', + 1.0001, + 'ascii', + ], + ['myatt1', 'myattr2', '', '1.0', 'ascii'], + ], + ], + 'unicode_encoding': [ + [ + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-city.csv', + True, + 'ascii', + ], + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-city.csv', + True, + 'iso-8859-1', + ], + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-city.csv', + True, + 'ASCII', + ], + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-city.csv', + True, + 'ISO-2022-JP', + ], + ], + [ + ['myatt1', 'myattr2', '../lookup-files/gender-city.csv', True, ''], + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-city.csv', + True, + 'asciii', + ], + ['myatt1', 'myattr2', '../lookup-files/gender-city.csv', True, None], + ], + ], + }, + ], + # + ('generator', 'GenerateCateContCompoundAttribute', 'constructor (__init__)'): [ + 'derived', + [ + 'categorical_attribute_name', + 'continuous_attribute_name', + 'lookup_file_name', + 'has_header_line', + 'unicode_encoding', + 'continuous_value_type', + ], + { + 'categorical_attribute_name': [ + [ + [ + 'myattr1', + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'int', + ], + [ + 'attr1', + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'int', + ], + [ + 'attribute1', + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'int', + ], + [ + 'Surname', + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'int', + ], + [ + 'att1', + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'int', + ], + [ + '1234', + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'int', + ], + ], + [ + [ + '', + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'int', + ], + [ + 1234, + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'int', + ], + [ + {}, + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'int', + ], + [ + -12.54, + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'int', + ], + [ + [], + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'int', + ], + [ + None, + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'int', + ], + ], + ], + 'continuous_attribute_name': [ + [ + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'int', + ], + [ + 'myatt1', + 'attribute2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'int', + ], + [ + 'myatt1', + 'attr2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'int', + ], + [ + 'myatt1', + 'myatt2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'int', + ], + [ + 'myatt1', + 'att2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'int', + ], + [ + 'myatt1', + 'Given Name', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'int', + ], + ], + [ + [ + 'myatt1', + '', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'int', + ], + [ + 'myatt1', + 1234, + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'int', + ], + [ + 'myatt1', + {}, + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'int', + ], + [ + 'myattr1', + [], + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'int', + ], + [ + 'myattr1', + -12.34, + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'int', + ], + [ + 'myattr1', + None, + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'int', + ], + ], + ], + 'lookup_file_name': [ + [ + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'int', + ] + ], + [ + ['myatt1', 'myattr2', None, False, 'ascii', 'int'], + [ + 'myatt1', + 'myattr2', + '../lookup-files/givenname_m_freq.csv', + False, + 'ascii', + 'int', + ], + [ + 'myatt1', + 'myattr2', + '.../lookup-files/gender-income.csv', + False, + 'ascii', + 'int', + ], + ['myatt1', 'myattr2', '', False, 'ascii', 'int'], + ], + ], + 'has_header_line': [ + [ + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'int', + ], + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'int', + ], + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-income.csv', + 1, + 'ascii', + 'int', + ], + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-income.csv', + 0, + 'ascii', + 'int', + ], + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-income.csv', + 1.00, + 'ascii', + 'int', + ], + ], + [ + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-income.csv', + None, + 'ascii', + 'int', + ], + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-income.csv', + '', + 'ascii', + 'int', + ], + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-income.csv', + 'true', + 'ascii', + 'int', + ], + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-income.csv', + 1.0001, + 'ascii', + 'int', + ], + ['myatt1', 'myattr2', '', '1.0', 'ascii', 'int'], + ], + ], + 'unicode_encoding': [ + [ + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'int', + ], + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'iso-8859-1', + 'int', + ], + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'ASCII', + 'int', + ], + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'ISO-2022-JP', + 'int', + ], + ], + [ + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-income.' 'csv', + False, + '', + 'int', + ], + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'asciii', + 'int', + ], + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-income.csv', + False, + None, + 'int', + ], + ], + ], + 'continuous_value_type': [ + [ + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'int', + ], + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'float2', + ], + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'float3', + ], + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'float4', + ], + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'float5', + ], + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'float6', + ], + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'float7', + ], + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'float8', + ], + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'float9', + ], + ], + [ + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + '', + ], + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + None, + ], + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'float', + ], + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'float10', + ], + [ + 'myatt1', + 'myattr2', + '../lookup-files/gender-income.csv', + False, + 'ascii', + 'integer', + ], + ], + ], + }, + ], + # + ('generator', 'GenerateCateCateContCompoundAttribute', 'constructor (__init__)'): [ + 'derived', + [ + 'categorical1_attribute_name', + 'categorical2_attribute_name', + 'continuous_attribute_name', + 'lookup_file_name', + 'has_header_line', + 'unicode_encoding', + 'continuous_value_type', + ], + { + 'categorical1_attribute_name': [ + [ + [ + 'myattr1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-income.csv', + False, + 'ascii', + 'int', + ], + [ + 'attr1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-income.csv', + False, + 'ascii', + 'int', + ], + [ + 'attribute1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-income' '.csv', + False, + 'ascii', + 'int', + ], + [ + 'Surname', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-income.csv', + False, + 'ascii', + 'int', + ], + [ + 'att1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-income.csv', + False, + 'ascii', + 'int', + ], + [ + '1234', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-income.csv', + False, + 'ascii', + 'int', + ], + ], + [ + [ + '', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-income.csv', + False, + 'ascii', + 'int', + ], + [ + 1234, + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-income.csv', + False, + 'ascii', + 'int', + ], + [ + {}, + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-income.csv', + False, + 'ascii', + 'int', + ], + [ + -12.54, + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-income.csv', + False, + 'ascii', + 'int', + ], + [ + [], + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-income.csv', + False, + 'ascii', + 'int', + ], + [ + None, + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-income.csv', + False, + 'ascii', + 'int', + ], + ], + ], + 'categorical2_attribute_name': [ + [ + [ + 'myatt1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-income.csv', + False, + 'ascii', + 'int', + ], + [ + 'myatt1', + 'attribute2', + 'myattr3', + '../lookup-files/gender-city-income.csv', + False, + 'ascii', + 'int', + ], + [ + 'myatt1', + 'attr2', + 'myattr3', + '../lookup-files/gender-city-income.csv', + False, + 'ascii', + 'int', + ], + [ + 'myatt1', + 'myatt2', + 'myattr3', + '../lookup-files/gender-city-income.csv', + False, + 'ascii', + 'int', + ], + [ + 'myatt1', + 'att2', + 'myattr3', + '../lookup-files/gender-city-income.csv', + False, + 'ascii', + 'int', + ], + [ + 'myatt1', + 'Given Name', + 'myattr3', + '../lookup-files/gender-city-income' '.csv', + False, + 'ascii', + 'int', + ], + ], + [ + [ + 'myatt1', + '', + 'myattr3', + '../lookup-files/gender-city-income.csv', + False, + 'ascii', + 'int', + ], + [ + 'myatt1', + 1234, + 'myattr3', + '../lookup-files/gender-city-income.csv', + False, + 'ascii', + 'int', + ], + [ + 'myatt1', + {}, + 'myattr3', + '../lookup-files/gender-city-income.csv', + False, + 'ascii', + 'int', + ], + [ + 'myatt1', + [], + 'myattr3', + '../lookup-files/gender-city-income.csv', + False, + 'ascii', + 'int', + ], + [ + 'myatt1', + -12.34, + 'myattr3', + '../lookup-files/gender-city-income.' 'csv', + False, + 'ascii', + 'int', + ], + [ + 'myatt1', + None, + 'myattr3', + '../lookup-files/gender-city-income.' 'csv', + False, + 'ascii', + 'int', + ], + ], + ], + 'continuous_attribute_name': [ + [ + [ + 'myatt1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-income.' 'csv', + False, + 'ascii', + 'int', + ], + [ + 'myatt1', + 'myattr2', + 'attr3', + '../lookup-files/gender-city-income.' 'csv', + False, + 'ascii', + 'int', + ], + [ + 'myatt1', + 'myattr2', + 'att3', + '../lookup-files/gender-city-income.' 'csv', + False, + 'ascii', + 'int', + ], + [ + 'myatt1', + 'myattr2', + 'myattribute3', + '../lookup-files/gender-city-' 'income.csv', + False, + 'ascii', + 'int', + ], + [ + 'myatt1', + 'myattr2', + 'Suburb', + '../lookup-files/gender-city-income' '.csv', + False, + 'ascii', + 'int', + ], + [ + 'myatt1', + 'myattr2', + '1234', + '../lookup-files/gender-city-income.' 'csv', + False, + 'ascii', + 'int', + ], + ], + [ + [ + 'myatt1', + 'myattr2', + '', + '../lookup-files/gender-city-income.csv', + False, + 'ascii', + 'int', + ], + [ + 'myatt1', + 'myattr2', + 1234, + '../lookup-files/gender-city-income.csv', + False, + 'ascii', + 'int', + ], + [ + 'myatt1', + 'myattr2', + -12.34, + '../lookup-files/gender-city-income.csv', + False, + 'ascii', + 'int', + ], + [ + 'myattr1', + 'myattr2', + None, + '../lookup-files/gender-city-income.csv', + False, + 'ascii', + 'int', + ], + [ + 'myattr1', + 'myattr2', + [], + '../lookup-files/gender-city-income.csv', + False, + 'ascii', + 'int', + ], + [ + 'myattr1', + 'myattr2', + {}, + '../lookup-files/gender-city-income.csv', + False, + 'ascii', + 'int', + ], + ], + ], + 'lookup_file_name': [ + [ + [ + 'myatt1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-' 'income.csv', + False, + 'ascii', + 'int', + ] + ], + [ + ['myatt1', 'myattr2', 'myattr3', None, False, 'ascii', 'int'], + [ + 'myatt1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-' 'city.csv', + False, + 'ascii', + 'int', + ], + [ + 'myatt1', + 'myattr2', + 'myattr3', + '.../lookup-files/gender-city-' 'income.csv', + False, + 'ascii', + 'int', + ], + ['myatt1', 'myattr2', 'myattr3', '', False, 'ascii', 'int'], + ], + ], + 'has_header_line': [ + [ + [ + 'myatt1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-' 'income.csv', + True, + 'ascii', + 'int', + ], + [ + 'myatt1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-' 'income.csv', + False, + 'ascii', + 'int', + ], + [ + 'myatt1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-' 'income.csv', + 1, + 'ascii', + 'int', + ], + [ + 'myatt1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-' 'income.csv', + 0, + 'ascii', + 'int', + ], + [ + 'myatt1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-' 'income.csv', + 1.00, + 'ascii', + 'int', + ], + ], + [ + [ + 'myatt1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-' 'income.csv', + None, + 'ascii', + 'int', + ], + [ + 'myatt1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-' 'income.csv', + 'true', + 'ascii', + 'int', + ], + [ + 'myatt1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-' 'income.csv', + 1.0001, + 'ascii', + 'int', + ], + ['myatt1', 'myattr2', 'myattr3', '', '1.0', 'ascii', 'int'], + ], + ], + 'unicode_encoding': [ + [ + [ + 'myatt1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-' 'income.csv', + False, + 'ascii', + 'int', + ], + [ + 'myatt1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-' 'income.csv', + False, + 'iso-8859-1', + 'int', + ], + [ + 'myatt1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-' 'income.csv', + False, + 'ASCII', + 'int', + ], + [ + 'myatt1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-' 'income.csv', + False, + 'ISO-2022-JP', + 'int', + ], + ], + [ + [ + 'myatt1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-' 'income.csv', + False, + '', + 'int', + ], + [ + 'myatt1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-' 'income.csv', + False, + 'asciii', + 'int', + ], + [ + 'myatt1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-' 'income.csv', + False, + None, + 'int', + ], + ], + ], + 'continuous_value_type': [ + [ + [ + 'myatt1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-' 'income.csv', + False, + 'ascii', + 'int', + ], + [ + 'myatt1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-' 'income.csv', + False, + 'ascii', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-' 'income.csv', + False, + 'ascii', + 'float2', + ], + [ + 'myatt1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-' 'income.csv', + False, + 'ascii', + 'float3', + ], + [ + 'myatt1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-' 'income.csv', + False, + 'ascii', + 'float4', + ], + [ + 'myatt1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-' 'income.csv', + False, + 'ascii', + 'float5', + ], + [ + 'myatt1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-' 'income.csv', + False, + 'ascii', + 'float6', + ], + [ + 'myatt1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-' 'income.csv', + False, + 'ascii', + 'float7', + ], + [ + 'myatt1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-' 'income.csv', + False, + 'ascii', + 'float8', + ], + [ + 'myatt1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-' 'income.csv', + False, + 'ascii', + 'float9', + ], + ], + [ + [ + 'myatt1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-' 'income.csv', + False, + 'ascii', + '', + ], + [ + 'myatt1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-' 'income.csv', + False, + 'ascii', + None, + ], + [ + 'myatt1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-' 'income.csv', + False, + 'ascii', + 'float', + ], + [ + 'myatt1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-' 'income.csv', + False, + 'ascii', + 'float10', + ], + [ + 'myatt1', + 'myattr2', + 'myattr3', + '../lookup-files/gender-city-' 'income.csv', + False, + 'ascii', + 'integer', + ], + ], + ], + }, + ], + # + ('generator', 'GenerateContContCompoundAttribute', 'constructor (__init__)'): [ + 'derived', + [ + 'continuous1_attribute_name', + 'continuous2_attribute_name', + 'continuous1_funct_name', + 'continuous1_funct_param', + 'continuous2_function', + 'continuous1_value_type', + 'continuous2_value_type', + ], + { + 'continuous1_attribute_name': [ + [ + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float1', + ], + [ + '1234', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myattribute', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'test', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt2', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float1', + ], + ], + [ + [ + '', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float1', + ], + [ + 1234, + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float1', + ], + [ + {}, + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float1', + ], + [ + -12.54, + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float1', + ], + [ + [], + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float1', + ], + [ + None, + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float1', + ], + ], + ], + 'continuous2_attribute_name': [ + [ + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt1', + 'myatt2', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt1', + 'attribute2', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt1', + '2ndattribute', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt1', + 'Given Name', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt1', + '1234', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float1', + ], + ], + [ + [ + 'myatt1', + '', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt1', + 1234, + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt1', + -12.34, + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt1', + {}, + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt1', + [], + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt1', + None, + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float1', + ], + ], + ], + 'continuous1_funct_name': [ + [ + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + 'normal', + [50, 10, 0, 100], + test_cont_function1, + 'int', + 'float1', + ], + ], + [ + [ + 'myatt1', + 'myattr2', + '', + [20, 100], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + 'unform', + [20, 100], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + None, + [20, 100], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + [], + [20, 100], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + {}, + [20, 100], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + 'nomal', + [50, 10, 0, 100], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + 1234, + [50, 10, 0, 100], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + 'norm_fun', + [50, 10, 0, 100], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + ['normal'], + [50, 10, 0, 100], + test_cont_function1, + 'int', + 'float1', + ], + ], + ], + 'continuous1_funct_param': [ + [ + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + 'uniform', + [20.0, 100.0], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + 'uniform', + [-20, 100], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + 'normal', + [50, 10, 0, 100], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + 'normal', + [30, 20, 10, 120], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + 'normal', + [30.8, 2.0, -10, 120], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + 'normal', + [30, 20, 10, None], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + 'normal', + [30, 20, None, 120], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + 'normal', + [30, 20, None, None], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + 'normal', + [70, 20, -10, 200], + test_cont_function1, + 'int', + 'float1', + ], + ], + # min_val > max_val + [ + [ + 'myatt1', + 'myattr2', + 'uniform', + [100, 20], + test_cont_function1, + 'int', + 'float1', + ], + # min_val = max_val + [ + 'myatt1', + 'myattr2', + 'uniform', + [30, 30], + test_cont_function1, + 'int', + 'float1', + ], + # 2 args for normal function, 4 required + [ + 'myatt1', + 'myattr2', + 'normal', + [30, 10], + test_cont_function1, + 'int', + 'float1', + ], + # min_val > max_val + [ + 'myatt1', + 'myattr2', + 'normal', + [30, 20, 100, 10], + test_cont_function1, + 'int', + 'float1', + ], + # min_val = max_val + [ + 'myatt1', + 'myattr2', + 'normal', + [30, 20, 10, 10], + test_cont_function1, + 'int', + 'float1', + ], + # mu < min_val + [ + 'myatt1', + 'myattr2', + 'normal', + [30, 20, 40, 100], + test_cont_function1, + 'int', + 'float1', + ], + # mu > max_val + [ + 'myatt1', + 'myattr2', + 'normal', + [30, 20, 10, 20], + test_cont_function1, + 'int', + 'float1', + ], + # sigma < 0 + [ + 'myatt1', + 'myattr2', + 'normal', + [30, -20, 10, 120], + test_cont_function1, + 'int', + 'float1', + ], + # sigma = 0 + [ + 'myatt1', + 'myattr2', + 'normal', + [30, 0, 10, 120], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + 'normal', + [30, 20, '', ''], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + 'normal', + ['30', '20', '10', '120'], + test_cont_function1, + 'int', + 'float1', + ], + ], + ], + 'continuous2_function': [ + [ + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function2, + 'int', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function3, + 'int', + 'float1', + ], + ], + [ + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_exce_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_exce_cont_function2, + 'int', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_exce_cont_function3, + 'int', + 'float1', + ], + ], + ], + 'continuous1_value_type': [ + [ + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'float1', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'float2', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'float3', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'float4', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'float5', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'float6', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'float7', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'float8', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'float9', + 'float1', + ], + ], + [ + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'float', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + '', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'integer', + 'float1', + ], + ], + ], + 'continuous2_value_type': [ + [ + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'int', + ], + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float1', + ], + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float2', + ], + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float3', + ], + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float4', + ], + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float5', + ], + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float6', + ], + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float7', + ], + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float8', + ], + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float9', + ], + ], + [ + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'float', + ], + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + '', + ], + [ + 'myatt1', + 'myattr2', + 'uniform', + [20, 100], + test_cont_function1, + 'int', + 'integer', + ], + ], + ], + }, + ], + # + ('generator', 'GenerateDataSet', 'constructor (__init__)'): [ + 'derived', + [ + 'output_file_name', + 'write_header_line', + 'rec_id_attr_name', + 'number_of_records', + 'attribute_name_list', + 'attribute_data_list', + 'unicode_encoding', + ], + { + 'output_file_name': [ + [ + [ + 'test.csv', + True, + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + 'test.log', + True, + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + 'test.txt', + True, + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + 'test2.csv', + True, + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + ], + [ + [ + '', + True, + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + 1234, + True, + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + {}, + True, + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + -12.54, + True, + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + [], + True, + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + None, + True, + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + ], + ], + 'write_header_line': [ + [ + [ + 'test.csv', + True, + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + 'test.csv', + False, + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + 'test.csv', + 1, + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + 'test.csv', + 0, + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + 'test.csv', + 1.00, + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + 'test.csv', + 0.0, + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + ], + [ + [ + 'test.csv', + '', + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + 'test.csv', + 'True', + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + 'test.csv', + 1234, + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + 'test.csv', + {}, + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + 'test.csv', + [], + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + 'test.csv', + -12.34, + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + 'test.csv', + None, + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + ], + ], + 'rec_id_attr_name': [ + [ + [ + 'test.csv', + True, + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + 'test.csv', + True, + 'rec_num', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + 'test.csv', + True, + 'id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + 'test.csv', + True, + 'num', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + 'test.csv', + True, + 'test', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + 'test.csv', + True, + '1234', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + ], + [ + [ + 'test.csv', + True, + '', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + 'test.csv', + True, + 1234, + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + 'test.csv', + True, + -12.34, + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + 'test.csv', + True, + None, + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + 'test.csv', + True, + [], + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + 'test.csv', + True, + {}, + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + ], + ], + 'number_of_records': [ + [ + [ + 'test.csv', + True, + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + 'test.csv', + True, + 'rec_id', + 10000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + 'test.csv', + True, + 'rec_id', + 1234, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + ], + [ + [ + 'test.csv', + True, + 'rec_id', + None, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + 'test.csv', + True, + 'rec_id', + '1000', + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + 'test.csv', + True, + 'rec_id', + 123.4, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + 'test.csv', + True, + 'rec_id', + '', + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + ], + ], + 'attribute_name_list': [ + [ + [ + 'test.csv', + True, + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + 'test.csv', + True, + 'rec_id', + 1000, + ['attr1', 'attr2', 'attr3'], + attr_data_list3, + 'ascii', + ], + [ + 'test.csv', + True, + 'rec_id', + 1000, + ['attr1'], + attr_data_list1, + 'ascii', + ], + ], + [ + ['test.csv', True, 'rec_id', 1000, None, attr_data_list1, 'ascii'], + ['test.csv', True, 'rec_id', 1000, [], attr_data_list1, 'ascii'], + [ + 'test.csv', + True, + 'rec_id', + 1000, + ['rec_id'], + attr_data_list1, + 'ascii', + ], + [ + 'test.csv', + True, + 'rec_id', + 1000, + ['attr2'], + attr_data_list1, + 'ascii', + ], + [ + 'test.csv', + True, + 'rec_id', + 1000, + ['attr1', ''], + attr_data_list1, + 'ascii', + ], + [ + 'test.csv', + True, + 'rec_id', + 1000, + ['attr1', 'attr1'], + attr_data_list2, + 'ascii', + ], + ], + ], + 'attribute_data_list': [ + [ + [ + 'test.csv', + True, + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + 'test.csv', + True, + 'rec_id', + 1000, + ['attr1'], + attr_data_list1, + 'ascii', + ], + [ + 'test.csv', + True, + 'rec_id', + 1000, + ['attr1', 'attr2', 'attr3'], + attr_data_list3, + 'ascii', + ], + [ + 'test.csv', + True, + 'rec_id', + 1000, + ['attr1', 'gender', 'city', 'attr2'], + attr_data_list4, + 'ascii', + ], + ], + [ + [ + 'test.csv', + True, + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list1, + 'ascii', + ], + [ + 'test.csv', + True, + 'rec_id', + 1000, + ['attr1', 'attr2'], + [1, 2, 3], + 'ascii', + ], + [ + 'test.csv', + True, + 'rec_id', + 1000, + ['attr1', 'attr2'], + 'test', + 'ascii', + ], + ['test.csv', True, 'rec_id', 1000, ['attr1', 'attr2'], {}, 'ascii'], + ['test.csv', True, 'rec_id', 1000, ['attr1', 'attr2'], None, 'ascii'], + ['test.csv', True, 'rec_id', 1000, ['attr1', 'attr2'], [], 'ascii'], + ], + ], + 'unicode_encoding': [ + [ + [ + 'test.csv', + True, + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ascii', + ], + [ + 'test.csv', + True, + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'iso-8859-1', + ], + [ + 'test.csv', + True, + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'iso-2022-jp', + ], + [ + 'test.csv', + True, + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'ASCII', + ], + ], + [ + [ + 'test.csv', + True, + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + '', + ], + [ + 'test.csv', + True, + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + 'asccii', + ], + [ + 'test.csv', + True, + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + '8859-1', + ], + [ + 'test.csv', + True, + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + [], + ], + [ + 'test.csv', + True, + 'rec_id', + 1000, + ['attr1', 'attr2'], + attr_data_list2, + None, + ], + ], + ], + }, + ], +} + +# ============================================================================= + + +class TestCase(unittest.TestCase): + + # Initialise test case - - - - - - - - - - - - - - - - - - - - - - - - - - - + # + def setUp(self): + pass # Nothing to initialize + + # Clean up test case - - - - - - - - - - - - - - - - - - - - - - - - - - - - + # + def tearDown(self): + pass # Nothing to clean up + + # --------------------------------------------------------------------------- + # Start test cases + + def testArguments(self, test_data): + """Test if a function or method can be called or initialised correctly with + different values for their input arguments (parameters). + + The argument 'test_data' must be a dictionary with the following + structure: + + - Keys are tuples consisting of three strings: + (module_name, class_name, function_or_method_name) + - Values are lists made of three elements: + 1) If this Class is a base class ('base') or a derived class + ('derived'). These two require slightly different testing calls. + 2) A list that contains all the input arguments of the method, in the + same order as the values of these arguments are given in the + following dictionaries. + 3) Dictionaries where the keys are the names of the input argument + that is being tested, and the values of these dictionaries are a + list that contains two lists. The first list contains valid input + arguments ('normal' argument tests) that should pass the test, + while the second list contains illegal input arguments ('exception' + argument tests) that should raise an exception. + + The lists of test cases are itself lists, each containing a number of + input argument values, as many as are expected by the function or + method that is being tested. + + This function returns a list containing the test results, where each + list element is a string with comma separated values (CSV) which are to + be written into the testing log file. + """ + + test_res_list = [] # The test results, one element per element in the test + # data dictionary + + for (test_method_names, test_method_data) in test_data.iteritems(): + + test_type = test_method_data[0] + method_keyword_argument_list = test_method_data[1] + test_data_details = test_method_data[2] + + assert test_type[:3] in ['bas', 'der'] + + print('1:', method_keyword_argument_list) + print('2:', test_data_details) + + # For methods we need to test their __init__ function by calling the + # name of the constructor, which is the name of the class. + # (this is different from testing a function that is not in a class!) + # + test_method_name = test_method_names[1] + + print('Testing arguments for method/function:', test_method_name) + + for argument_name in test_data_details: + print(' Testing input argument:', argument_name) + + norm_test_data = test_data_details[argument_name][0] + exce_test_data = test_data_details[argument_name][1] + print(' Normal test cases: ', norm_test_data) + print(' Exception test cases:', exce_test_data) + + # Conduct normal tests - - - - - - - - - - - - - - - - - - - - - - - - + # + num_norm_test_cases = len(norm_test_data) + num_norm_test_passed = 0 + num_norm_test_failed = 0 + norm_failed_desc_str = '' + + for test_input in norm_test_data: + passed = True # Assume the test will pass :-) + + key_word_dict = {} + for i in range(len(method_keyword_argument_list)): + key_word_dict[method_keyword_argument_list[i]] = test_input[i] + print('Keyword dict normal:', key_word_dict) + + if test_type[:3] == 'bas': + try: + getattr(generator, test_method_name)(key_word_dict) + except: + passed = False + else: + try: + getattr(generator, test_method_name)(**key_word_dict) + except: + passed = False + + # Now process test results + # + if passed == False: + num_norm_test_failed += 1 + norm_failed_desc_str += 'Failed test for input ' + "'%s'; " % ( + str(test_input) + ) + else: + num_norm_test_passed += 1 + + assert num_norm_test_failed + num_norm_test_passed == num_norm_test_cases + + norm_test_result_str = ( + test_method_names[0] + + ',' + + test_method_names[1] + + ',' + + test_method_names[2] + + ',' + + argument_name + + ',normal,' + + '%d,' % (num_norm_test_cases) + ) + if num_norm_test_failed == 0: + norm_test_result_str += 'all tests passed' + else: + norm_test_result_str += '%d tests failed,' % (num_norm_test_failed) + norm_test_result_str += '"' + norm_failed_desc_str[:-2] + '"' + + test_res_list.append(norm_test_result_str) + + # Conduct exception tests - - - - - - - - - - - - - - - - - - - - - - - + # + num_exce_test_cases = len(exce_test_data) + num_exce_test_passed = 0 + num_exce_test_failed = 0 + exce_failed_desc_str = '' + + for test_input in exce_test_data: + passed = True # Assume the test will pass (i.e. raise an exception) + + key_word_dict = {} + for i in range(len(method_keyword_argument_list)): + key_word_dict[method_keyword_argument_list[i]] = test_input[i] + print('Keyword dict exception:', key_word_dict) + + if test_type[:3] == 'bas': + try: + self.assertRaises( + Exception, + getattr(generator, test_method_name), + key_word_dict, + ) + except: + passed = False + else: + try: + self.assertRaises( + Exception, + getattr(generator, test_method_name), + **key_word_dict + ) + except: + passed = False + + # Now process test results + # + if passed == False: + num_exce_test_failed += 1 + exce_failed_desc_str += 'Failed test for input ' + "'%s'; " % ( + str(test_input) + ) + else: + num_exce_test_passed += 1 + + assert num_exce_test_failed + num_exce_test_passed == num_exce_test_cases + + exce_test_result_str = ( + test_method_names[0] + + ',' + + test_method_names[1] + + ',' + + test_method_names[2] + + ',' + + argument_name + + ',exception,' + + '%d,' % (num_exce_test_cases) + ) + if num_exce_test_failed == 0: + exce_test_result_str += 'all tests passed' + else: + exce_test_result_str += '%d tests failed,' % (num_exce_test_failed) + exce_test_result_str += '"' + exce_failed_desc_str[:-2] + '"' + + test_res_list.append(exce_test_result_str) + + test_res_list.append('') # Empty line between tests of methods + + return test_res_list + + # --------------------------------------------------------------------------- + + def testFunct_GenerateFreqAttribute(self): + """Test that this method returns a correct string value for attribute.""" + + print('Testing functionality of "GenerateFreqAttribute"') + + num_passed = 0 + num_failed = 0 + + # Load the lookup file and store the values in a dictionary + # + header_list, gname_file_data = basefunctions.read_csv_file( + '../lookup-files/givenname_f_freq.csv', 'ascii', False + ) + + header_list, postcode_file_data = basefunctions.read_csv_file( + '../lookup-files/postcode_act_freq.csv', 'ascii', False + ) + + gname_freq_val_list = [] + postcode_freq_val_list = [] + + for freq_pair_list in gname_file_data: + attr_val = freq_pair_list[0].strip() + if attr_val not in gname_freq_val_list: + gname_freq_val_list.append(attr_val) + + for freq_pair_list in postcode_file_data: + attr_val = freq_pair_list[0].strip() + if attr_val not in postcode_freq_val_list: + postcode_freq_val_list.append(attr_val) + + passed = True + + for t in range(num_tests): + gname_attr_val = gname_attr.create_attribute_value() + if gname_attr_val not in gname_freq_val_list: + passed = False + + if passed == True: + num_passed += 1 + else: + num_failed += 1 + + for t in range(num_tests): + postcode_attr_val = postcode_attr.create_attribute_value() + if postcode_attr_val not in postcode_freq_val_list: + passed = False + + if passed == True: + num_passed += 1 + else: + num_failed += 1 + + assert num_passed + num_failed == 2 * num_tests + + test_result_str = ( + 'generator,GenerateFreqAttribute,create_attribute_value,' + + 'n/a,funct,%d,' % (2 * num_tests) + ) + if num_failed == 0: + test_result_str += 'all tests passed' + else: + test_result_str += '%d tests failed' % (num_failed) + + return [test_result_str, ''] + + # --------------------------------------------------------------------------- + + def testFunct_GenerateFuncAttribute(self): + """Test that this method returns a correct string value for attribute.""" + + print('Testing functionality of "GenerateFuncAttribute"') + + num_passed = 0 + num_failed = 0 + + passed = True + + for t in range(num_tests): + age_attr_val = age_uniform_attr.create_attribute_value() + if not isinstance(age_attr_val, str): + passed = False + try: + int_val = int(age_attr_val) + if not isinstance(int_val, int): + passed = False + elif int_val > 120: + passed = False + elif int_val < 0: + passed = False + except: + passed = False + + if passed == True: + num_passed += 1 + else: + num_failed += 1 + + assert num_passed + num_failed == num_tests + + test_result_str = ( + 'generator,GenerateFuncAttribute,create_attribute_value,' + + 'n/a,funct,%d,' % (num_tests) + ) + if num_failed == 0: + test_result_str += 'all tests passed' + else: + test_result_str += '%d tests failed' % (num_failed) + + return [test_result_str, ''] + + # --------------------------------------------------------------------------- + + def testFunct_GenerateCateCateCompoundAttribute(self): + """Test that this method returns two correct string values for the + compound attribute of two categorical attributes. + """ + + print('Testing functionality of "GenerateCateCateCompoundAttribute"') + + num_passed = 0 + num_failed = 0 + + # Load the lookup file and store the values in a dictionary + # + header_list, file_data = basefunctions.read_csv_file( + '../lookup-files/gender-city.csv', 'ascii', True + ) + + cate_val_dict = {} # attr1 values are the keys and the values are + # the corresponding attr2 values. + + i = 0 # Line counter in file data + + while i < len(file_data): + rec_list = file_data[i] + cate_attr1_val = rec_list[0].strip() + + # Process values for second categorical attribute in this line + # + cate_attr2_data = rec_list[2:] # All values and counts of attribute 2 + cate_attr2_val_list = [] # Values in second categorical attribute for + # this categorical value from first attribute + while cate_attr2_data != []: + if len(cate_attr2_data) == 1: + if cate_attr2_data[0] != '\\': + raise Exception( + 'Line in categorical look-up file has illegal' + 'format.' + ) + # Get the next record from file data with a continuation of the + # categorical values from the second attribute + # + i += 1 + cate_attr2_data = file_data[i] + cate_attr2_val = cate_attr2_data[0] + cate_attr2_val_list.append(cate_attr2_val) + cate_attr2_data = cate_attr2_data[2:] + cate_val_dict[cate_attr1_val] = cate_attr2_val_list + i += 1 + + # print(ate_val_dict) + + passed = True + + for t in range(num_tests): + ( + gender_attr_val, + city_attr_val, + ) = gender_city_comp_attr.create_attribute_values() + + if gender_attr_val not in cate_val_dict: + passed = False + else: + city_attr_vals = cate_val_dict[gender_attr_val] + if city_attr_val not in city_attr_vals: + passed = False + + if passed == True: + num_passed += 1 + else: + num_failed += 1 + + assert num_passed + num_failed == num_tests + + test_result_str = ( + 'generator,GenerateCateCateCompoundAttribute,create_' + + 'attribute_values,n/a,funct,%d,' % (num_tests) + ) + if num_failed == 0: + test_result_str += 'all tests passed' + else: + test_result_str += '%d tests failed' % (num_failed) + + return [test_result_str, ''] + + # --------------------------------------------------------------------------- + + def testFunct_GenerateCateContCompoundAttribute(self): + """Test that this method returns two correct string values for the + compound attribute of one categorical attribute and one continuous + attribute. + """ + + print('Testing functionality of "GenerateCateContCompoundAttribute"') + + num_passed = 0 + num_failed = 0 + + # Load the lookup file and store the values in a dictionary + # + header_list, file_data = basefunctions.read_csv_file( + '../lookup-files/gender-income.csv', 'ascii', False + ) + + cate_cont_val_dict = {} # attr1 values are the keys and the values are + # the corresponding attr2 values. + + for val_pair_list in file_data: + cate_attr_val = val_pair_list[0].strip() + cont_attr_list = val_pair_list[2:] + cate_cont_val_dict[cate_attr_val] = cont_attr_list + + # print(ate_cont_val_dict) + + passed = True + + for t in range(num_tests): + ( + gender_attr_val, + income_attr_val, + ) = gender_income_comp_attr.create_attribute_values() + + if gender_attr_val not in cate_cont_val_dict: + passed = False + else: + income_attr_list = cate_cont_val_dict[gender_attr_val] + function_name = income_attr_list[0] + try: + income_val = float(income_attr_val) + if function_name == 'uniform': + min_val_uniform = float(income_attr_list[1]) + max_val_uniform = float(income_attr_list[2]) + if (income_val > max_val_uniform) or ( + income_val < min_val_uniform + ): + passed = False + elif function_name == 'normal': + if income_attr_list[3] != u'None': + min_val_normal = float(income_attr_list[3]) + if income_val < min_val_normal: + passed = False + if income_attr_list[4] != u'None': + max_val_normal = float(income_attr_list[4]) + if income_val > max_val_normal: + passed = False + except: + passed = False + + if passed == True: + num_passed += 1 + else: + num_failed += 1 + + assert num_passed + num_failed == num_tests + + test_result_str = ( + 'generator,GenerateCateContCompoundAttribute,create_' + + 'attribute_values,n/a,funct,%d,' % (num_tests) + ) + if num_failed == 0: + test_result_str += 'all tests passed' + else: + test_result_str += '%d tests failed' % (num_failed) + + return [test_result_str, ''] + + # --------------------------------------------------------------------------- + + def testFunct_GenerateCateCateContCompoundAttribute(self): + """Test that this method returns three correct string values for the + compound attribute of two categorical attributes and one continuous + attribute. + """ + + print('Testing functionality of "GenerateCateCateContCompoundAttribute"') + + num_passed = 0 + num_failed = 0 + + # Load the lookup file and store the values in a dictionary + # + header_list, file_data = basefunctions.read_csv_file( + '../lookup-files/gender-city-income.csv', 'ascii', False + ) + + cate_cate_cont_dict = {} # attr1 values are the keys and the values are + # dictionaries with the corresponding attr2 + # values being the keys and the values are lists + # that contain the corresponding attr3 values. + + list_counter = 0 # Counter in the list of file data + + num_file_rows = len(file_data) + rec_list = file_data[list_counter] + + while list_counter < num_file_rows: # Process one row after another + cate_attr1_val = rec_list[0].strip() + + # Loop to process values of the second categorical attribute and the + # corresponding continuous functions + # + list_counter += 1 + rec_list = file_data[list_counter] # Get values from next line + + this_cont_funct_dict = {} # Values of categorical attribute 2 + + # As long as there are data from the second categorical attribute + # + while len(rec_list) > 2: + cate_attr2_val = rec_list[0].strip() + + cont_attr_funct = rec_list[2].strip() + + if cont_attr_funct == 'uniform': + cont_attr_funct_min_val = float(rec_list[3]) + cont_attr_funct_max_val = float(rec_list[4]) + this_cont_funct_dict[cate_attr2_val] = [ + cont_attr_funct, + cont_attr_funct_min_val, + cont_attr_funct_max_val, + ] + elif cont_attr_funct == 'normal': + cont_attr_funct_mu = float(rec_list[3]) + cont_attr_funct_sigma = float(rec_list[4]) + try: + cont_attr_funct_min_val = float(rec_list[5]) + except: + cont_attr_funct_min_val = None + try: + cont_attr_funct_max_val = float(rec_list[6]) + except: + cont_attr_funct_max_val = None + this_cont_funct_dict[cate_attr2_val] = [ + cont_attr_funct, + cont_attr_funct_mu, + cont_attr_funct_sigma, + cont_attr_funct_min_val, + cont_attr_funct_max_val, + ] + list_counter += 1 + if list_counter < num_file_rows: + rec_list = file_data[list_counter] + else: + rec_list = [] + cate_cate_cont_dict[cate_attr1_val] = this_cont_funct_dict + + # print(ate_cate_cont_dict) + + passed = True + + for t in range(num_tests): + ( + gender_attr_val, + city_attr_val, + income_attr_val, + ) = gender_city_income_comp_attr.create_attribute_values() + if gender_attr_val not in cate_cate_cont_dict: + passed = False + else: + city_attr_vals = cate_cate_cont_dict[gender_attr_val] + if city_attr_val not in city_attr_vals: + passed = False + else: + income_attr_list = city_attr_vals[city_attr_val] + function_name = income_attr_list[0] + try: + income_val = float(income_attr_val) + if function_name == 'uniform': + min_val_uniform = float(income_attr_list[1]) + max_val_uniform = float(income_attr_list[2]) + if (income_val > max_val_uniform) or ( + income_val < min_val_uniform + ): + passed = False + elif function_name == 'normal': + if income_attr_list[3] != None: + min_val_normal = float(income_attr_list[3]) + if income_val < min_val_normal: + passed = False + if income_attr_list[4] != None: + max_val_normal = float(income_attr_list[4]) + if income_val > max_val_normal: + passed = False + except: + passed = False + + if passed == True: + num_passed += 1 + else: + num_failed += 1 + + assert num_passed + num_failed == num_tests + + test_result_str = ( + 'generator,GenerateCateCateContCompound' + + 'Attribute,create_attribute_values,n/a,funct,%d,' % (num_tests) + ) + if num_failed == 0: + test_result_str += 'all tests passed' + else: + test_result_str += '%d tests failed' % (num_failed) + + return [test_result_str, ''] + + # --------------------------------------------------------------------------- + + def testFunct_GenerateContContCompoundAttribute(self): + """Test that this method returns two correct string values for the + compound attribute of two continuous attributes. + """ + + print('Testing functionality of "GenerateContContCompoundAttribute"') + + num_passed = 0 + num_failed = 0 + + passed = True + + for t in range(num_tests): + ( + age_attr_val, + bp_attr_val, + ) = age_blood_pressure_comp_attr.create_attribute_values() + try: + age_val = int(age_attr_val) + if not isinstance(age_val, int): + passed = False + elif (age_val < 10) or (age_val > 110): + passed = False + except: + passed = False + try: + bp_val = float(bp_attr_val) + if basefunctions.float_to_str(bp_val, 'float3') != bp_attr_val: + passed = False + except: + passed = False + + if passed == True: + num_passed += 1 + else: + num_failed += 1 + + assert num_passed + num_failed == num_tests + + test_result_str = ( + 'generator,GenerateContContCompoundAttribute,create_' + + 'attribute_values,n/a,funct,%d,' % (num_tests) + ) + if num_failed == 0: + test_result_str += 'all tests passed' + else: + test_result_str += '%d tests failed' % (num_failed) + + return [test_result_str, ''] + + +# ============================================================================= +# Generate a time string to be used for the log file +# +curr_time_tuple = time.localtime() +curr_time_str = ( + str(curr_time_tuple[0]) + + str(curr_time_tuple[1]).zfill(2) + + str(curr_time_tuple[2]).zfill(2) + + '-' + + str(curr_time_tuple[3]).zfill(2) + + str(curr_time_tuple[4]).zfill(2) +) + +# Write test output header line into the log file +# +out_file_name = './logs/generatorTest-%s.csv' % (curr_time_str) + +out_file = open(out_file_name, 'w') + +out_file.write('Test results generated by generatorTest.py' + os.linesep) + +out_file.write('Test started: ' + curr_time_str + os.linesep) + +out_file.write(os.linesep) + +out_file.write( + 'Module name,Class name,Method name,Arguments,Test_type,' + + 'Patterns tested,Summary,Failure description' + + os.linesep +) +out_file.write(os.linesep) + +# Create instances for the testcase class that calls all tests +# +test_res_list = [] +test_case_ins = TestCase('testArguments') +test_res_list += test_case_ins.testArguments(test_argument_data_dict) + +# Add inidividual functionality tests here +# +test_case_ins = TestCase('testFunct_GenerateFreqAttribute') +test_res_list += test_case_ins.testFunct_GenerateFreqAttribute() + +test_case_ins = TestCase('testFunct_GenerateFuncAttribute') +test_res_list += test_case_ins.testFunct_GenerateFuncAttribute() + +test_case_ins = TestCase('testFunct_GenerateCateCateCompoundAttribute') +test_res_list += test_case_ins.testFunct_GenerateCateCateCompoundAttribute() + +test_case_ins = TestCase('testFunct_GenerateCateContCompoundAttribute') +test_res_list += test_case_ins.testFunct_GenerateCateContCompoundAttribute() + +test_case_ins = TestCase('testFunct_GenerateCateCateContCompoundAttribute') +test_res_list += test_case_ins.testFunct_GenerateCateCateContCompoundAttribute() + +test_case_ins = TestCase('testFunct_GenerateContContCompoundAttribute') +test_res_list += test_case_ins.testFunct_GenerateContContCompoundAttribute() + +# Write test output results into the log file +# +for line in test_res_list: + out_file.write(line + os.linesep) + +out_file.close() + +print('Test results are written to', out_file_name) + +for line in test_res_list: + print(line) + +# ============================================================================= diff --git a/tests/logs/basefunctionsTest-20230130-1746.csv b/tests/logs/basefunctionsTest-20230130-1746.csv new file mode 100644 index 0000000000000000000000000000000000000000..f3880df067ae7925945f40b0a875ec111e2fe1d3 --- /dev/null +++ b/tests/logs/basefunctionsTest-20230130-1746.csv @@ -0,0 +1,140 @@ +Test results generated by basefunctionsTest.py +Test started: 20230130-1746 + +Module name,Class name,Method name,Arguments,Test_type,Patterns tested,Summary,Failure description + +basefunctions,n/a,check_is_not_none,variable,normal,3,all tests passed +basefunctions,n/a,check_is_not_none,variable,exception,6,all tests passed +basefunctions,n/a,check_is_not_none,value,normal,5,all tests passed +basefunctions,n/a,check_is_not_none,value,exception,1,all tests passed + +basefunctions,n/a,check_is_string,variable,normal,3,all tests passed +basefunctions,n/a,check_is_string,variable,exception,6,all tests passed +basefunctions,n/a,check_is_string,value,normal,7,all tests passed +basefunctions,n/a,check_is_string,value,exception,4,all tests passed + +basefunctions,n/a,check_is_unicode_string,variable,normal,3,all tests passed +basefunctions,n/a,check_is_unicode_string,variable,exception,6,all tests passed +basefunctions,n/a,check_is_unicode_string,value,normal,4,all tests passed +basefunctions,n/a,check_is_unicode_string,value,exception,6,6 tests failed,"Failed test for input '['testArgument', None]'; Failed test for input '['testArgument', '']'; Failed test for input '['testArgument', -123]'; Failed test for input '['testArgument', 123]'; Failed test for input '['testArgument', 1.87]'; Failed test for input '['testArgument', 'ascii']'" + +basefunctions,n/a,check_is_string_or_unicode_string,variable,normal,4,all tests passed +basefunctions,n/a,check_is_string_or_unicode_string,variable,exception,6,all tests passed +basefunctions,n/a,check_is_string_or_unicode_string,value,normal,6,all tests passed +basefunctions,n/a,check_is_string_or_unicode_string,value,exception,6,all tests passed + +basefunctions,n/a,check_is_non_empty_string,variable,normal,3,all tests passed +basefunctions,n/a,check_is_non_empty_string,variable,exception,6,all tests passed +basefunctions,n/a,check_is_non_empty_string,value,normal,6,all tests passed +basefunctions,n/a,check_is_non_empty_string,value,exception,7,all tests passed + +basefunctions,n/a,check_is_number,variable,normal,3,all tests passed +basefunctions,n/a,check_is_number,variable,exception,6,all tests passed +basefunctions,n/a,check_is_number,value,normal,6,all tests passed +basefunctions,n/a,check_is_number,value,exception,8,all tests passed + +basefunctions,n/a,check_is_positive,variable,normal,3,all tests passed +basefunctions,n/a,check_is_positive,variable,exception,6,all tests passed +basefunctions,n/a,check_is_positive,value,normal,7,all tests passed +basefunctions,n/a,check_is_positive,value,exception,8,all tests passed + +basefunctions,n/a,check_is_not_negative,variable,normal,3,all tests passed +basefunctions,n/a,check_is_not_negative,variable,exception,6,all tests passed +basefunctions,n/a,check_is_not_negative,value,normal,9,all tests passed +basefunctions,n/a,check_is_not_negative,value,exception,8,all tests passed + +basefunctions,n/a,check_is_normalised,variable,normal,3,all tests passed +basefunctions,n/a,check_is_normalised,variable,exception,6,all tests passed +basefunctions,n/a,check_is_normalised,value,normal,10,all tests passed +basefunctions,n/a,check_is_normalised,value,exception,10,all tests passed + +basefunctions,n/a,check_is_percentage,variable,normal,3,all tests passed +basefunctions,n/a,check_is_percentage,variable,exception,6,all tests passed +basefunctions,n/a,check_is_percentage,value,normal,14,all tests passed +basefunctions,n/a,check_is_percentage,value,exception,10,all tests passed + +basefunctions,n/a,check_is_integer,variable,normal,3,all tests passed +basefunctions,n/a,check_is_integer,variable,exception,6,all tests passed +basefunctions,n/a,check_is_integer,value,normal,8,all tests passed +basefunctions,n/a,check_is_integer,value,exception,10,all tests passed + +basefunctions,n/a,check_is_float,variable,normal,3,all tests passed +basefunctions,n/a,check_is_float,variable,exception,6,all tests passed +basefunctions,n/a,check_is_float,value,normal,6,all tests passed +basefunctions,n/a,check_is_float,value,exception,10,all tests passed + +basefunctions,n/a,check_is_dictionary,variable,normal,3,all tests passed +basefunctions,n/a,check_is_dictionary,variable,exception,6,all tests passed +basefunctions,n/a,check_is_dictionary,value,normal,3,all tests passed +basefunctions,n/a,check_is_dictionary,value,exception,4,all tests passed + +basefunctions,n/a,check_is_list,variable,normal,3,all tests passed +basefunctions,n/a,check_is_list,variable,exception,6,all tests passed +basefunctions,n/a,check_is_list,value,normal,4,all tests passed +basefunctions,n/a,check_is_list,value,exception,4,all tests passed + +basefunctions,n/a,check_is_set,variable,normal,3,all tests passed +basefunctions,n/a,check_is_set,variable,exception,6,all tests passed +basefunctions,n/a,check_is_set,value,normal,4,all tests passed +basefunctions,n/a,check_is_set,value,exception,6,all tests passed + +basefunctions,n/a,check_is_tuple,variable,normal,3,all tests passed +basefunctions,n/a,check_is_tuple,variable,exception,6,all tests passed +basefunctions,n/a,check_is_tuple,value,normal,5,all tests passed +basefunctions,n/a,check_is_tuple,value,exception,8,all tests passed + +basefunctions,n/a,check_is_flag,variable,normal,3,all tests passed +basefunctions,n/a,check_is_flag,variable,exception,6,all tests passed +basefunctions,n/a,check_is_flag,value,normal,6,all tests passed +basefunctions,n/a,check_is_flag,value,exception,6,all tests passed + +basefunctions,n/a,check_unicode_encoding_exists,unicode_encoding_string,normal,3,all tests passed +basefunctions,n/a,check_unicode_encoding_exists,unicode_encoding_string,exception,4,all tests passed + +basefunctions,n/a,check_is_function_or_method,variable,normal,3,all tests passed +basefunctions,n/a,check_is_function_or_method,variable,exception,6,all tests passed +basefunctions,n/a,check_is_function_or_method,value,normal,4,all tests passed +basefunctions,n/a,check_is_function_or_method,value,exception,6,all tests passed + +basefunctions,n/a,char_set_ascii,string_variable,normal,5,all tests passed +basefunctions,n/a,char_set_ascii,string_variable,exception,6,all tests passed + +basefunctions,n/a,check_is_valid_format_str,variable,normal,3,all tests passed +basefunctions,n/a,check_is_valid_format_str,variable,exception,6,all tests passed +basefunctions,n/a,check_is_valid_format_str,value,normal,10,all tests passed +basefunctions,n/a,check_is_valid_format_str,value,exception,8,all tests passed + +basefunctions,n/a,float_to_str,number_variable,normal,5,all tests passed +basefunctions,n/a,float_to_str,number_variable,exception,6,all tests passed +basefunctions,n/a,float_to_str,format_string,normal,10,all tests passed +basefunctions,n/a,float_to_str,format_string,exception,8,all tests passed + +basefunctions,n/a,str2comma_separated_list,string_variable,normal,8,all tests passed +basefunctions,n/a,str2comma_separated_list,string_variable,exception,6,1 tests failed,"Failed test for input '['']'" + +basefunctions,n/a,read_csv_file,file_name,normal,3,all tests passed +basefunctions,n/a,read_csv_file,file_name,exception,6,all tests passed +basefunctions,n/a,read_csv_file,encoding,normal,4,all tests passed +basefunctions,n/a,read_csv_file,encoding,exception,6,all tests passed +basefunctions,n/a,read_csv_file,header_line,normal,6,all tests passed +basefunctions,n/a,read_csv_file,header_line,exception,6,all tests passed + +basefunctions,n/a,write_csv_file,file_name,normal,4,all tests passed +basefunctions,n/a,write_csv_file,file_name,exception,6,all tests passed +basefunctions,n/a,write_csv_file,encoding,normal,4,all tests passed +basefunctions,n/a,write_csv_file,encoding,exception,6,all tests passed +basefunctions,n/a,write_csv_file,header_list,normal,6,all tests passed +basefunctions,n/a,write_csv_file,header_list,exception,6,all tests passed +basefunctions,n/a,write_csv_file,file_data,normal,6,all tests passed +basefunctions,n/a,write_csv_file,file_data,exception,7,all tests passed + +basefunctions,n/a,char_set_ascii,n/a,funct,26,all tests passed + +basefunctions,n/a,float_to_str,n/a,funct,44,all tests passed + +basefunctions,n/a,str2comma_separated_list,n/a,funct,10,all tests passed + +basefunctions,n/a,read_csv_file,n/a,funct,3,all tests passed + +basefunctions,n/a,write_csv_file,n/a,funct,8,all tests passed + diff --git a/tests/logs/contdepfunctTest-20230130-1748.csv b/tests/logs/contdepfunctTest-20230130-1748.csv new file mode 100644 index 0000000000000000000000000000000000000000..b809ebb85bfdb72116813e2a5a73a1ce59ea2168 --- /dev/null +++ b/tests/logs/contdepfunctTest-20230130-1748.csv @@ -0,0 +1,5 @@ +Test results generated by contdepfunctTest.py +Test started: 20230130-1748 + +Module name,Class name,Method name,Arguments,Test_type,Patterns tested,Summary,Failure description + diff --git a/tests/logs/contdepfunctTest-20230130-1749.csv b/tests/logs/contdepfunctTest-20230130-1749.csv new file mode 100644 index 0000000000000000000000000000000000000000..d50c192a31d098aa4ab7d4bfe6dcbc94109099e4 --- /dev/null +++ b/tests/logs/contdepfunctTest-20230130-1749.csv @@ -0,0 +1,15 @@ +Test results generated by contdepfunctTest.py +Test started: 20230130-1749 + +Module name,Class name,Method name,Arguments,Test_type,Patterns tested,Summary,Failure description + +contdepfunct,n/a,blood_pressure_depending_on_age,age,normal,10,all tests passed +contdepfunct,n/a,blood_pressure_depending_on_age,age,exception,10,all tests passed + +contdepfunct,n/a,salary_depending_on_age,age,normal,10,all tests passed +contdepfunct,n/a,salary_depending_on_age,age,exception,10,all tests passed + +contdepfunct,n/a,blood_pressure_depending_on_age,n/a,funct,100000,all tests passed + +contdepfunct,n/a,salary_depending_on_age,n/a,funct,100000,all tests passed + diff --git a/tests/main_test.py b/tests/main_test.py new file mode 100644 index 0000000000000000000000000000000000000000..6ab68fb84614c969c0fab8071d144dd6d1978271 --- /dev/null +++ b/tests/main_test.py @@ -0,0 +1,793 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +from pathlib import Path + +from geco_data_generator import ( + attrgenfunct, + contdepfunct, + basefunctions, + generator, + corruptor, +) + +do_large_tests = False # Set to True to run tests to generate large +# datasets - warning is time consuming +import os +import time +import unittest + +import random + +random.seed(42) + +# ============================================================================= + +# Define test cases, each being a list containing the main parameters required +# for generating a data set: +# 1) rec_id_attr_name +# 2) num_org_rec +# 3) num_dup_rec +# 4) max_duplicate_per_record +# 5) num_duplicates_distribution ('uniform', 'poisson', 'zipf') +# 6) max_modification_per_attr +# 7) num_modification_per_record +# +test_cases = [ + ['rec_id', 100, 100, 1, 'uniform', 1, 1], + ['rec_id', 100, 100, 1, 'poisson', 1, 1], + ['rec_id', 100, 100, 1, 'zipf', 1, 1], + ['rec_id', 10000, 10000, 1, 'uniform', 1, 1], + ['rec_id', 10000, 10000, 1, 'poisson', 1, 1], + ['rec_id', 10000, 10000, 1, 'zipf', 1, 1], +] +if do_large_tests == True: + test_cases += [ + ['rec_id', 100000, 100000, 1, 'uniform', 1, 1], + ['rec_id', 100000, 100000, 1, 'poisson', 1, 1], + ['rec_id', 100000, 100000, 1, 'zipf', 1, 1], + ] +# +test_cases += [ + ['rec_id', 100, 20, 1, 'uniform', 1, 1], + ['rec_id', 100, 20, 1, 'poisson', 1, 1], + ['rec_id', 100, 20, 1, 'zipf', 1, 1], + ['rec_id', 10000, 2000, 1, 'uniform', 1, 1], + ['rec_id', 10000, 2000, 1, 'poisson', 1, 1], + ['rec_id', 10000, 2000, 1, 'zipf', 1, 1], +] +if do_large_tests == True: + test_cases += [ + ['rec_id', 100000, 20000, 1, 'uniform', 1, 1], + ['rec_id', 100000, 20000, 1, 'poisson', 1, 1], + ['rec_id', 100000, 20000, 1, 'zipf', 1, 1], + ] +# +test_cases += [ + ['rec_num', 123, 321, 5, 'uniform', 1, 3], + ['rec_num', 123, 321, 5, 'poisson', 1, 3], + ['rec_num', 123, 321, 5, 'zipf', 1, 3], + ['rec_num', 12345, 14321, 5, 'uniform', 1, 3], + ['rec_num', 12345, 14321, 5, 'poisson', 1, 3], + ['rec_num', 12345, 14321, 5, 'zipf', 1, 3], +] +if do_large_tests == True: + test_cases += [ + ['rec_num', 123456, 154321, 5, 'uniform', 1, 3], + ['rec_num', 123456, 154321, 5, 'poisson', 1, 3], + ['rec_num', 123456, 154321, 5, 'zipf', 1, 3], + ] +# +test_cases += [ + ['rec_num', 123, 321, 3, 'uniform', 3, 9], + ['rec_num', 123, 321, 3, 'poisson', 3, 9], + ['rec_num', 123, 321, 3, 'zipf', 3, 9], + ['rec_num', 12345, 14321, 3, 'uniform', 3, 9], + ['rec_num', 12345, 14321, 3, 'poisson', 3, 9], + ['rec_num', 12345, 14321, 3, 'zipf', 3, 9], +] +if do_large_tests == True: + test_cases += [ + ['rec_num', 123456, 154321, 3, 'uniform', 3, 9], + ['rec_num', 123456, 154321, 3, 'poisson', 3, 9], + ['rec_num', 123456, 154321, 3, 'zipf', 3, 9], + ] +# +test_cases += [ + ['rec_num', 321, 123, 11, 'uniform', 2, 7], + ['rec_num', 321, 123, 11, 'poisson', 2, 7], + ['rec_num', 321, 123, 11, 'zipf', 2, 7], + ['rec_num', 43210, 14321, 11, 'uniform', 2, 7], + ['rec_num', 43210, 14321, 11, 'poisson', 2, 7], + ['rec_num', 43210, 14321, 11, 'zipf', 2, 7], +] +if do_large_tests == True: + test_cases += [ + ['rec_num', 654321, 123456, 11, 'uniform', 2, 7], + ['rec_num', 654321, 123456, 11, 'poisson', 2, 7], + ['rec_num', 654321, 123456, 11, 'zipf', 2, 7], + ] + +# Set the Unicode encoding for all test data generation +# +unicode_encoding_used = 'ascii' + +# Check the unicode encoding selected is valid +# +basefunctions.check_unicode_encoding_exists(unicode_encoding_used) + +# ============================================================================= + + +class TestCase(unittest.TestCase): + + # Initialise test case - - - - - - - - - - - - - - - - - - - - - - - - - - - + # + def setUp(self): + pass # Nothing to initialize + + # Clean up test case - - - - - - - - - - - - - - - - - - - - - - - - - - - - + # + def tearDown(self): + pass # Nothing to clean up + + # --------------------------------------------------------------------------- + # Start test cases + + def testDataGeneration(self, test_case): + """Test the overall generation of a data set according to the parameters + given by checking if the generated data sets follows the parameter + specification given. + """ + + rec_id_attr_name = test_case[0] + num_org_rec = test_case[1] + num_dup_rec = test_case[2] + max_duplicate_per_record = test_case[3] + num_duplicates_distribution = test_case[4] + max_modification_per_attr = test_case[5] + num_modification_per_record = test_case[6] + + test_res_list = ['', 'Test case parameters:'] + test_res_list.append(' rec_id_attr_name = %s' % (rec_id_attr_name)) + test_res_list.append(' num_org_rec = %s' % (num_org_rec)) + test_res_list.append(' num_dup_rec = %s' % (num_dup_rec)) + test_res_list.append( + ' max_duplicate_per_record = %s' % (max_duplicate_per_record) + ) + test_res_list.append( + ' num_duplicates_distribution = %s' % (num_duplicates_distribution) + ) + test_res_list.append( + ' max_modification_per_attr = %s' % (max_modification_per_attr) + ) + test_res_list.append( + ' num_modification_per_record = %s' % (num_modification_per_record) + ) + test_res_list.append('') + + # Define the attributes to be generated (based on methods from - - - - - + # the generator.py module) + + # Individual attributes + # + given_name_attr = generator.GenerateFreqAttribute( + attribute_name='given-name', + freq_file_name='../lookup-files/givenname_freq.csv', + has_header_line=False, + unicode_encoding=unicode_encoding_used, + ) + + surnname_attr = generator.GenerateFreqAttribute( + attribute_name='surname', + freq_file_name='../lookup-files/surname-freq.csv', + has_header_line=False, + unicode_encoding=unicode_encoding_used, + ) + + postcode_attr = generator.GenerateFreqAttribute( + attribute_name='postcode', + freq_file_name='../lookup-files/postcode_act_freq.csv', + has_header_line=False, + unicode_encoding=unicode_encoding_used, + ) + + oz_phone_num_attr = generator.GenerateFuncAttribute( + attribute_name='oz-phone-number', + function=attrgenfunct.generate_phone_number_australia, + ) + + credit_card_attr = generator.GenerateFuncAttribute( + attribute_name='credit-card-number', + function=attrgenfunct.generate_credit_card_number, + ) + + age_uniform_attr = generator.GenerateFuncAttribute( + attribute_name='age-uniform', + function=attrgenfunct.generate_uniform_age, + parameters=[0, 120], + ) + + age_death_normal_attr = generator.GenerateFuncAttribute( + attribute_name='age-death-normal', + function=attrgenfunct.generate_normal_age, + parameters=[80, 20, 0, 120], + ) + + income_normal_attr = generator.GenerateFuncAttribute( + attribute_name='income-normal', + function=attrgenfunct.generate_normal_value, + parameters=[75000, 20000, 0, 1000000, 'float2'], + ) + + rating_normal_attr = generator.GenerateFuncAttribute( + attribute_name='rating-normal', + function=attrgenfunct.generate_normal_value, + parameters=[2.5, 1.0, 0.0, 5.0, 'int'], + ) + + # Compund (dependent) attributes + # + gender_city_comp_attr = generator.GenerateCateCateCompoundAttribute( + categorical1_attribute_name='gender', + categorical2_attribute_name='city', + lookup_file_name='../lookup-files/gender-city.csv', + has_header_line=True, + unicode_encoding=unicode_encoding_used, + ) + + gender_income_comp_attr = generator.GenerateCateContCompoundAttribute( + categorical_attribute_name='alt-gender', + continuous_attribute_name='income', + continuous_value_type='float1', + lookup_file_name='gender-income.csv', + has_header_line=False, + unicode_encoding=unicode_encoding_used, + ) + + gender_city_salary_comp_attr = generator.GenerateCateCateContCompoundAttribute( + categorical1_attribute_name='alt-gender-2', + categorical2_attribute_name='town', + continuous_attribute_name='salary', + continuous_value_type='float4', + lookup_file_name='gender-city-income.csv', + has_header_line=False, + unicode_encoding=unicode_encoding_used, + ) + + age_blood_pressure_comp_attr = generator.GenerateContContCompoundAttribute( + continuous1_attribute_name='medical-age', + continuous2_attribute_name='blood-pressure', + continuous1_funct_name='uniform', + continuous1_funct_param=[10, 110], + continuous2_function=contdepfunct.blood_pressure_depending_on_age, + continuous1_value_type='int', + continuous2_value_type='float3', + ) + + age_salary_comp_attr = generator.GenerateContContCompoundAttribute( + continuous1_attribute_name='medical-age-2', + continuous2_attribute_name='medical-salary', + continuous1_funct_name='normal', + continuous1_funct_param=[45, 20, 25, 130], + continuous2_function=contdepfunct.salary_depending_on_age, + continuous1_value_type='int', + continuous2_value_type='float1', + ) + + # Define how attribute values are to be modified (corrupted) - - - - - - + # (based on methods from the corruptor.py module) + # + average_edit_corruptor = corruptor.CorruptValueEdit( + position_function=corruptor.position_mod_normal, + char_set_funct=basefunctions.char_set_ascii, + insert_prob=0.25, + delete_prob=0.25, + substitute_prob=0.25, + transpose_prob=0.25, + ) + + sub_tra_edit_corruptor = corruptor.CorruptValueEdit( + position_function=corruptor.position_mod_uniform, + char_set_funct=basefunctions.char_set_ascii, + insert_prob=0.0, + delete_prob=0.0, + substitute_prob=0.5, + transpose_prob=0.5, + ) + + ins_del_edit_corruptor = corruptor.CorruptValueEdit( + position_function=corruptor.position_mod_normal, + char_set_funct=basefunctions.char_set_ascii, + insert_prob=0.5, + delete_prob=0.5, + substitute_prob=0.0, + transpose_prob=0.0, + ) + + surname_misspell_corruptor = corruptor.CorruptCategoricalValue( + lookup_file_name='surname-misspell.csv', + has_header_line=False, + unicode_encoding=unicode_encoding_used, + ) + + ocr_corruptor = corruptor.CorruptValueOCR( + position_function=corruptor.position_mod_uniform, + lookup_file_name='ocr-variations.csv', + has_header_line=False, + unicode_encoding=unicode_encoding_used, + ) + + keyboard_corruptor = corruptor.CorruptValueKeyboard( + position_function=corruptor.position_mod_normal, row_prob=0.5, col_prob=0.5 + ) + + phonetic_corruptor = corruptor.CorruptValuePhonetic( + position_function=corruptor.position_mod_uniform, + lookup_file_name='phonetic-variations.csv', + has_header_line=False, + unicode_encoding=unicode_encoding_used, + ) + + missing_val_empty_corruptor = corruptor.CorruptMissingValue() + missing_val_miss_corruptor = corruptor.CorruptMissingValue(missing_value='miss') + missing_val_unkown_corruptor = corruptor.CorruptMissingValue( + missing_value='unknown' + ) + + # Define the attributes to be generated for this data set, and the data + # set itself + # + attr_name_list = [ + 'given-name', + 'surname', + 'city', + 'postcode', + 'oz-phone-number', + 'credit-card-number', + 'age-uniform', + 'age-death-normal', + 'income-normal', + 'rating-normal', + 'gender', + 'alt-gender', + 'alt-gender-2', + 'town', + 'income', + 'salary', + 'medical-age', + 'blood-pressure', + 'medical-age-2', + 'medical-salary', + ] + + attr_data_list = [ + given_name_attr, + surnname_attr, + postcode_attr, + oz_phone_num_attr, + credit_card_attr, + age_uniform_attr, + age_death_normal_attr, + income_normal_attr, + rating_normal_attr, + gender_city_comp_attr, + gender_income_comp_attr, + gender_city_salary_comp_attr, + age_blood_pressure_comp_attr, + age_salary_comp_attr, + ] + + # Initialise the main data generator + # + test_data_generator = generator.GenerateDataSet( + output_file_name='no-file-name', + write_header_line=True, + rec_id_attr_name=rec_id_attr_name, + number_of_records=num_org_rec, + attribute_name_list=attr_name_list, + attribute_data_list=attr_data_list, + unicode_encoding=unicode_encoding_used, + ) + + # Define distribution of how likely an attribute will be selected for + # modification (sum of probabilities must be 1.0) + # + attr_mod_prob_dictionary = { + 'given-name': 0.1, + 'surname': 0.1, + 'city': 0.1, + 'postcode': 0.1, + 'oz-phone-number': 0.1, + 'age-death-normal': 0.1, + 'income-normal': 0.1, + 'gender': 0.1, + 'town': 0.1, + 'income': 0.1, + } + + # For each attribute, a distribution of which corruptors to apply needs + # to be given, with the sum ofprobabilities to be 1.0 for each attribute + # + attr_mod_data_dictionary = { + 'given-name': [ + (0.25, average_edit_corruptor), + (0.25, ocr_corruptor), + (0.25, phonetic_corruptor), + (0.25, missing_val_miss_corruptor), + ], + 'surname': [(0.5, surname_misspell_corruptor), (0.5, average_edit_corruptor)], + 'city': [(0.5, keyboard_corruptor), (0.5, missing_val_empty_corruptor)], + 'postcode': [ + (0.3, missing_val_unkown_corruptor), + (0.7, sub_tra_edit_corruptor), + ], + 'oz-phone-number': [ + (0.2, missing_val_empty_corruptor), + (0.4, sub_tra_edit_corruptor), + (0.4, keyboard_corruptor), + ], + 'age-death-normal': [(1.0, missing_val_unkown_corruptor)], + 'income-normal': [ + (0.3, keyboard_corruptor), + (0.3, ocr_corruptor), + (0.4, missing_val_empty_corruptor), + ], + 'gender': [(0.5, sub_tra_edit_corruptor), (0.5, ocr_corruptor)], + 'town': [ + (0.2, average_edit_corruptor), + (0.3, ocr_corruptor), + (0.2, keyboard_corruptor), + (0.3, phonetic_corruptor), + ], + 'income': [(1.0, missing_val_miss_corruptor)], + } + + # Initialise the main data corruptor + # + test_data_corruptor = corruptor.CorruptDataSet( + number_of_org_records=num_org_rec, + number_of_mod_records=num_dup_rec, + attribute_name_list=attr_name_list, + max_num_dup_per_rec=max_duplicate_per_record, + num_dup_dist=num_duplicates_distribution, + max_num_mod_per_attr=max_modification_per_attr, + num_mod_per_rec=num_modification_per_record, + attr_mod_prob_dict=attr_mod_prob_dictionary, + attr_mod_data_dict=attr_mod_data_dictionary, + ) + + passed = True # Assume the test will pass :-) + + # Start the generation process + # + try: + rec_dict = test_data_generator.generate() + + except Exception as exce_value: # Something bad happened + test_res_list.append( + ' generator.generate() raised Exception: "%s"' % (str(exce_value)) + ) + return test_res_list # Abandon test + + num_org_rec_gen = len(rec_dict) + + if num_org_rec_gen != num_org_rec: + passed = False + test_res_list.append( + ' Wrong number of original records generated:' + + ' %d, expected %d' % (num_org_rec_gen, num_org_rec) + ) + + # Corrupt (modify) the original records into duplicate records + # + try: + rec_dict = test_data_corruptor.corrupt_records(rec_dict) + except Exception as exce_value: # Something bad happened + test_res_list.append( + ' corruptor.corrupt_records() raised ' + + 'Exception: "%s"' % (str(exce_value)) + ) + return test_res_list # Abandon test + + num_dup_rec_gen = len(rec_dict) - num_org_rec_gen + + if num_dup_rec_gen != num_dup_rec: + passed = False + test_res_list.append( + ' Wrong number of duplicate records generated:' + + ' %d, expected %d' % (num_dup_rec_gen, num_dup_rec) + ) + + num_dup_counts = {} # Count how many records have a certain number of + # duplicates + + # Do tests on all generated records + # + for (rec_id, rec_list) in rec_dict.iteritems(): + if len(rec_list) != len(attr_name_list): + passed = False + test_res_list.append( + ' Record with identifier "%s" contains wrong' % (rec_id) + + ' number of attributes: ' + + ' %d, expected %d' % (len(rec_list), len(attr_name_list)) + ) + + if 'org' in rec_id: # An original record + + # Check the number of duplicates for this record is what is expected + # + num_dups = 0 + rec_num = rec_id.split('-')[1] + + for d in range(max_duplicate_per_record * 2): + tmp_rec_id = 'rec-%s-dup-%d' % (rec_num, d) + if tmp_rec_id in rec_dict: + num_dups += 1 + if num_dups > max_duplicate_per_record: + passed = False + test_res_list.append( + ' Too many duplicate records for original' + + ' record "%s": %d' % (rec_id), + num_dups, + ) + + d_count = num_dup_counts.get(num_dups, 0) + 1 + num_dup_counts[num_dups] = d_count + + # Check no duplicate number is outside expected range + # + for d in range(max_duplicate_per_record, max_duplicate_per_record * 2): + tmp_rec_id = 'rec-%s-dup-%d' % (rec_num, d) + if tmp_rec_id in rec_dict: + passed = False + test_res_list.append( + ' Illegal duplicate number: %s' % (tmp_rec_id) + + ' (larger than max. number ' + + 'of duplicates per record %sd' % (max_duplicate_per_record) + ) + + # Check values in certain attributes only contain letters + # + for i in [0, 1, 2, 10, 11, 12, 13]: + test_val = rec_list[i].replace(' ', '') + test_val = test_val.replace('-', '') + test_val = test_val.replace("'", '') + if test_val.isalpha() == False: + passed = False + test_res_list.append( + ' Value in attribute "%s" is not only ' % (attr_name_list[i]) + + 'letters:' + ) + test_res_list.append(' Org: %s' % (str(rec_list))) + + # Check values in certain attributes only contain digits + # + for i in [3, 4, 5, 6, 7, 8, 9, 14, 15, 16, 17, 18, 19]: + test_val = rec_list[i].replace(' ', '') + test_val = test_val.replace('.', '') + if test_val.isdigit() == False: + passed = False + test_res_list.append( + ' Value in attribute "%s" is not only ' % (attr_name_list[i]) + + 'digits:' + ) + test_res_list.append(' Org: %s' % (str(rec_list))) + + # Check age values are in range + # + for i in [6, 7, 16]: + test_val = int(rec_list[i].strip()) + if (test_val < 0) or (test_val > 130): + passed = False + test_res_list.append( + ' Age value in attribute "%s" is out of' % (attr_name_list[i]) + + ' range:' + ) + test_res_list.append(' Org: %s' % (str(rec_list))) + + # Check length of postcode, telephone and credit card numbers + # + if len(rec_list[3]) != 4: + passed = False + test_res_list.append(' Postcode has not 4 digits:') + test_res_list.append(' Org: %s' % (str(rec_list))) + + if (len(rec_list[4]) != 12) or (rec_list[4][0] != '0'): + passed = False + test_res_list.append(' Australian phone number has wrong format:') + test_res_list.append(' Org: %s' % (str(rec_list))) + + # Check 'rating' is between 0 and 5 + # + test_val = int(rec_list[9].strip()) + if (test_val < 0) or (test_val > 5): + passed = False + test_res_list.append(' "rating-normal" value is out of range:') + test_res_list.append(' Org: %s' % (str(rec_list))) + + # Check gender values + # + test_val = rec_list[10] + if test_val not in ['male', 'female']: + passed = False + test_res_list.append(' "gender" value is out of range:') + test_res_list.append(' Org: %s' % (str(rec_list))) + + test_val = rec_list[11] + if test_val not in ['m', 'f', 'na']: + passed = False + test_res_list.append(' "alt-gender" value is out of range:') + test_res_list.append(' Org: %s' % (str(rec_list))) + + test_val = rec_list[12] + if test_val not in ['male', 'female']: + passed = False + test_res_list.append(' "alt-gender-2" value is out of range:') + test_res_list.append(' Org: %s' % (str(rec_list))) + + if 'dup' in rec_id: # A duplicate record + + # Get the corresponding original record + # + org_rec_id = 'rec-%s-org' % (rec_id.split('-')[1]) + org_rec_list = rec_dict[org_rec_id] + + # Check the duplicate number + # + dup_num = int(rec_id.split('-')[-1]) + if (dup_num < 0) or (dup_num > max_duplicate_per_record - 1): + passed = False + test_res_list.append( + ' Duplicate record with identifier "%s" ' % (rec_id) + + ' has an illegal duplicate number:' + + ' %d' % (dup_num) + ) + test_res_list.append(' Org: %s' % (str(org_rec_list))) + test_res_list.append(' Dup: %s' % (str(rec_list))) + + # Check that a duplicate record contains the expected - - - - - - - - - + # number of modifications + + num_diff_val = 0 # Count how many values are different + + for i in range(len(rec_list)): # Check all attribute values + if rec_list[i] != org_rec_list[i]: + num_diff_val += 1 + + if num_diff_val == 0: # No differences between org and dup record + passed = False + test_res_list.append( + ' Duplicate record with identifier "%s" ' % (rec_id) + + 'is the same as it original record' + ) + test_res_list.append(' Org: %s' % (str(org_rec_list))) + test_res_list.append(' Dup: %s' % (str(rec_list))) + + if num_diff_val < num_modification_per_record: + passed = False + test_res_list.append( + ' Duplicate record with identifier "%s" ' % (rec_id) + + 'contains less modifications ' + + 'than expected (%d instead of %d)' + % (num_diff_val, num_modification_per_record) + ) + test_res_list.append(' Org: %s' % (str(org_rec_list))) + test_res_list.append(' Dup: %s' % (str(rec_list))) + + # Check that certain attributes have not been modified + # + for i in [5, 6, 9, 11, 12, 15, 16, 17, 18, 19]: + if rec_list[i] != org_rec_list[i]: + passed = False + test_res_list.append( + ' Duplicate record with identifier "%s" ' % (rec_id) + + 'contains modified attribute ' + + 'values that should not be modified' + ) + test_res_list.append(' Org: %s' % (str(org_rec_list))) + test_res_list.append(' Dup: %s' % (str(rec_list))) + + # Check the content of certain attribute values, and how they + # differ between original and duplicate records + # + # Due to the possibility thatmultiple modifications are applied on the + # same attribute these tests are limited + + test_org_val = org_rec_list[2] # City + test_dup_val = rec_list[2] + if test_dup_val != '': + if len(test_org_val) != len(test_dup_val): + passed = False + test_res_list.append(' "city" values have different length:') + test_res_list.append(' Org: %s' % (str(org_rec_list))) + test_res_list.append(' Dup: %s' % (str(rec_list))) + + test_org_val = org_rec_list[4] # Australian phone number + test_dup_val = rec_list[4] + if test_dup_val != '': + if len(test_org_val) != len(test_dup_val): + passed = False + test_res_list.append( + ' "oz-phone-number" values have different' + ' length:' + ) + test_res_list.append(' Org: %s' % (str(org_rec_list))) + test_res_list.append(' Dup: %s' % (str(rec_list))) + + test_org_val = org_rec_list[7] # Age-death-normal + test_dup_val = rec_list[7] + if test_dup_val != 'unknown': + if test_org_val != test_dup_val: + passed = False + test_res_list.append(' Wrong value for "age-death-normal":') + test_res_list.append(' Org: %s' % (str(org_rec_list))) + test_res_list.append(' Dup: %s' % (str(rec_list))) + + test_org_val = org_rec_list[14] # Income + test_dup_val = rec_list[14] + if test_dup_val != 'miss': + if test_org_val != test_dup_val: + passed = False + test_res_list.append(' Wrong value for "income":') + test_res_list.append(' Org: %s' % (str(org_rec_list))) + test_res_list.append(' Dup: %s' % (str(rec_list))) + + test_res_list.append( + ' Distribution of duplicates: ("%s" expected)' % num_duplicates_distribution + ) + dup_keys = num_dup_counts.keys() + dup_keys.sort() + for d in dup_keys: + test_res_list.append(' %d: %d records' % (d, num_dup_counts[d])) + test_res_list.append('') + + if passed == True: + test_res_list.append(' All tests passed') + test_res_list.append('') + + return test_res_list + + +# ============================================================================= +# Generate a time string to be used for the log file +# +curr_time_tuple = time.localtime() +curr_time_str = ( + str(curr_time_tuple[0]) + + str(curr_time_tuple[1]).zfill(2) + + str(curr_time_tuple[2]).zfill(2) + + '-' + + str(curr_time_tuple[3]).zfill(2) + + str(curr_time_tuple[4]).zfill(2) +) + +# Write test output header line into the log file +# +Path('./logs').mkdir(exist_ok=True) +out_file_name = './logs/mainTest-%s.txt' % (curr_time_str) + +out_file = open(out_file_name, 'w') + +out_file.write('Test results generated by mainTest.py' + os.linesep) + +out_file.write('Test started: ' + curr_time_str + os.linesep) + +out_file.write(os.linesep) + +for test_case in test_cases: + + # Create instances for the testcase class that calls all tests + # + test_case_ins = TestCase('testDataGeneration') + test_res_list = test_case_ins.testDataGeneration(test_case) + + # Write test output results into the log file + # + for line in test_res_list: + out_file.write(line + os.linesep) + + for line in test_res_list: + print(line) + +out_file.close() + +print('Test results are written to', out_file_name) diff --git a/tests/test.csv b/tests/test.csv new file mode 100644 index 0000000000000000000000000000000000000000..e24a8eb67990bbb80b5a0d57a33e83e62fff23d4 --- /dev/null +++ b/tests/test.csv @@ -0,0 +1,4 @@ +attr1,attr2,attr3 +id1,peter,lyneham +id2,miller,dickson +id3,smith,hackett diff --git a/tests/test.txt b/tests/test.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/test1.csv b/tests/test1.csv new file mode 100644 index 0000000000000000000000000000000000000000..e24a8eb67990bbb80b5a0d57a33e83e62fff23d4 --- /dev/null +++ b/tests/test1.csv @@ -0,0 +1,4 @@ +attr1,attr2,attr3 +id1,peter,lyneham +id2,miller,dickson +id3,smith,hackett diff --git a/tests/test2.txt b/tests/test2.txt new file mode 100644 index 0000000000000000000000000000000000000000..14129a0b347c6c1985c4d3cb5c6466267c79eabd --- /dev/null +++ b/tests/test2.txt @@ -0,0 +1,17 @@ +attr1,attr2,attr3,attr 4 +# header line mustbe the first line in file +# test2.txt - small test file usedby basefunctionsTest.py +# + +# + +# + +1,todo,3,four +two,None,3,4 +test,test,test,test +long string1 long string1 long string1 long string1 long string1,short string,nop,99 + +# +# end of test file + diff --git a/tests/test3.csv b/tests/test3.csv new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/test4.csv b/tests/test4.csv new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391