Пример #1
0
 def table_of_contents(self, node):
     functions.remove_tag(node, 'div', id='footer')
     functions.remove_tag(node, 'div', 'pageSection', 'main-content')
     functions.remove_tag(node, 'div', 'pageSectionHeader')
     functions.remove_tag(node, 'div', id='main-header')
     functions.remove_tag(node, 'img')
     return node.find('div', 'pageSection').ul
Пример #2
0
 def load(string) -> Generation:
     generation_count, string = remove_tag("generation_count", string)
     population_str, string = remove_tag("population", string)
     gene_pool_str, string = remove_tag("gene_pool", string)
     population = Population.load(population_str)
     gene_pool = GenePool.load(gene_pool_str)
     return Generation(int(generation_count), population, gene_pool)
Пример #3
0
 def table_of_contents(self, node):
     functions.remove_tag(node,'div',id='footer')
     functions.remove_tag(node,'div','pageSection','main-content')
     functions.remove_tag(node,'div','pageSectionHeader')
     functions.remove_tag(node,'div',id='main-header')
     functions.remove_tag(node,'img')
     return node.find('div','pageSection').ul
Пример #4
0
 def load(self, file_path):
     load_file = open(file_path, 'r')
     load_string = "\n".join(load_file.readlines())
     load_file.close()
     current_gen, load_string = remove_tag('current', load_string)
     self.current_generation = Generation.load(current_gen)
     past, load_string = remove_tag('past', load_string)
     past_gen, load_string = remove_tag('generation', load_string)
     self.past = []
     while past_gen is not None:
         self.past.append(Generation.load(past_gen))
         past_gen, load_string = remove_tag('generation', load_string)
Пример #5
0
    def load(string) -> Gene:
        weight_str, string = remove_tag("weight", string)
        in_node_str, string = remove_tag("in_node", string)
        out_node_str, string = remove_tag("out_node", string)
        innovation_number_str, string = remove_tag("innovation_number", string)
        enabled_str, string = remove_tag("enabled", string)

        weight = float(weight_str)
        in_node = int(in_node_str)
        out_node = int(out_node_str)
        innovation_number = int(innovation_number_str)
        enabled = bool(enabled_str)

        return Gene(weight, in_node, out_node, innovation_number, enabled)
Пример #6
0
    def load(string) -> Genome:
        input_size_str, string = remove_tag("input_size", string)
        output_size_str, string = remove_tag("output_size", string)
        raw_fitness_str, string = remove_tag("raw_fitness", string)
        genes_str, string = remove_tag("genes", string)

        input_size = int(input_size_str)
        output_size = int(output_size_str)
        raw_fitness = float(raw_fitness_str)
        genes = []
        while genes_str:
            gene_str, genes_str = remove_tag("gene", genes_str)
            gene = Gene.load(gene_str)
            genes.append(gene)
        genome = Genome(genes, input_size, output_size)
        genome.raw_fitness = raw_fitness
        return genome
Пример #7
0
    def load(string) -> GenePool:
        innovation_number_str, string = remove_tag("innovation_number", string)
        node_number_str, string = remove_tag("node_number", string)
        connection_innovations_str, string = remove_tag("connection_innovations", string)
        node_innovations_str, string = remove_tag("node_innovations", string)
        node_depths_str, string = remove_tag("node_depths", string)

        innovation_number = int(innovation_number_str)
        node_number = int(node_number_str)
        connection_innovations = load_dict(connection_innovations_str, StructureGene.StructureGene, int)
        node_innovations = load_dict(node_innovations_str, Gene.Gene, int)
        node_depths = load_dict(node_depths_str, int, int)

        gene_pool = GenePool(innovation_number, node_number, node_depths)
        gene_pool.connection_innovations = connection_innovations
        gene_pool.node_innovations = node_innovations

        return gene_pool
Пример #8
0
def page(node, depth=0, mindepth=0, singlepage=False):
    functions.remove_tag(node, 'div', id='footer')
    functions.remove_tag(node, 'head')
    node = node.find('div', 'wiki-content group', id='main-content')

    [
        x.unwrap()
        for x in node.find_all('span', 'confluence-embedded-file-wrapper')
    ]

    [image(x) for x in node.find_all('img')]

    [
        header(x, depth, mindepth)
        for x in node.find_all(['h1', 'h2', 'h3', 'h4', 'h5', 'h6'])
    ]

    if singlepage:
        fix_anchors(node)
    else:
        fix_links(node)

    return node
Пример #9
0
    def load(string) -> Specie:
        representative_str, string = remove_tag("representative", string)
        age_str, string = remove_tag("age", string)
        niche_fitness_str, string = remove_tag("niche_fitness", string)
        max_fitness_str, string = remove_tag("max_fitness", string)
        genomes_str, string = remove_tag("genomes", string)

        representative = Genome.load(representative_str)
        age = int(age_str)
        niche_fitness = float(niche_fitness_str)
        max_fitness = float(max_fitness_str)

        genomes = []
        while genomes_str:
            genome_str, genomes_str = remove_tag("genome", genomes_str)
            genome = Genome.load(genome_str)
            genomes.append(genome)
        specie = Specie(representative, genomes, age, max_fitness)
        specie.niche_fitness = niche_fitness

        return specie