analysis/synthetic_dset_generator.py
def generate_synthetic_no_order(num_samples, p_noise=.8):
    """
    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_no_order.keys()[random.randint(0, len(target_names_no_order) - 1)]
        name = target_names_no_order[current_elements]
        tokens = []
        included_elements = set()
        add_noise = random.random() < p_noise
        while add_noise or len(included_elements) != len(current_elements):
            if add_noise:
                element = str(random.randint(0, 100))
            else:
                element = [t for t in current_elements][random.randint(0, len(current_elements) - 1)]
                included_elements.update(element)
            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_no_order(num_samples, p_noise=.8):
    samples = []
    for i in xrange(num_samples):
        current_elements = target_names_no_order.keys()[random.randint(0, len(target_names_no_order) - 1)]
        name = target_names_no_order[current_elements]
        tokens = []
        included_elements = set()
        add_noise = random.random() < p_noise
        while add_noise or len(included_elements) != len(current_elements):
            if add_noise:
                element = str(random.randint(0, 100))
            else:
                element = [t for t in current_elements][random.randint(0, len(current_elements) - 1)]
                included_elements.update(element)
            tokens.append(element)
            add_noise = random.random() < p_noise
        samples.append({"tokens": tokens, "name": name})
    return samples
def generate_synthetic_no_order ( num_samples , p_noise = .8 ) : samples = [ ] for i in xrange ( num_samples ) : current_elements = target_names_no_order . keys ( ) [ random . randint ( 0 , len ( target_names_no_order ) - 1 ) ] name = target_names_no_order [ current_elements ] tokens = [ ] included_elements = set ( ) add_noise = random . random ( ) < p_noise while add_noise or len ( included_elements ) != len ( current_elements ) : if add_noise : element = str ( random . randint ( 0 , 100 ) ) else : element = [ t for t in current_elements ] [ random . randint ( 0 , len ( current_elements ) - 1 ) ] included_elements . update ( element ) 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