analysis/synthetic_dset_generator.py
def generate_synthetic_with_order(num_samples, p_noise=.7):
    """
    Generate a random synthetic dataset using the above mapping
    :param num_samples:
    :param p_noise:
    :return:
    """
    samples = []
    for i in xrange(num_samples):
        current_elements = target_names_order.keys()[random.randint(0, len(target_names_order) - 1)]
        name = target_names_order[current_elements]
        tokens = []
        current_idx = 0
        add_noise = random.random() < p_noise
        while add_noise or current_idx < len(current_elements):
            if add_noise:
                element = str(random.randint(0, 100))
            else:
                element = current_elements[current_idx]
                if random.random() < p_noise:
                    current_idx += 1
            tokens.append(element)
            add_noise = random.random() < p_noise
        samples.append({"tokens": tokens, "name": name})
    return samples

    Generate a random synthetic dataset using the above mapping
    :param num_samples:
    :param p_noise:
    :return:
    
Generate a random synthetic dataset using the above mapping
Generate a random synthetic dataset using the above mapping
def generate_synthetic_with_order(num_samples, p_noise=.7):
    samples = []
    for i in xrange(num_samples):
        current_elements = target_names_order.keys()[random.randint(0, len(target_names_order) - 1)]
        name = target_names_order[current_elements]
        tokens = []
        current_idx = 0
        add_noise = random.random() < p_noise
        while add_noise or current_idx < len(current_elements):
            if add_noise:
                element = str(random.randint(0, 100))
            else:
                element = current_elements[current_idx]
                if random.random() < p_noise:
                    current_idx += 1
            tokens.append(element)
            add_noise = random.random() < p_noise
        samples.append({"tokens": tokens, "name": name})
    return samples
def generate_synthetic_with_order ( num_samples , p_noise = .7 ) : samples = [ ] for i in xrange ( num_samples ) : current_elements = target_names_order . keys ( ) [ random . randint ( 0 , len ( target_names_order ) - 1 ) ] name = target_names_order [ current_elements ] tokens = [ ] current_idx = 0 add_noise = random . random ( ) < p_noise while add_noise or current_idx < len ( current_elements ) : if add_noise : element = str ( random . randint ( 0 , 100 ) ) else : element = current_elements [ current_idx ] if random . random ( ) < p_noise : current_idx += 1 tokens . append ( element ) add_noise = random . random ( ) < p_noise samples . append ( { "tokens" : tokens , "name" : name } ) return samples
Generate a random synthetic dataset using the above mapping
Generate a random synthetic dataset using the above mapping
"""
    Generate a random synthetic dataset using the above mapping
    :param num_samples:
    :param p_noise:
    :return:
    """
None
num_samples
None
p_noise
None