Exemple #1
0
    def calculate_inter_string_salience(self):
        """Return the inter string salience.

        This value represents how much the object is crying out for attention
        from codelets that build structures between strings."""
        if self.clamp_salience:
            return 100
        else:
            weights = [8, 2]
            values = [self.relative_importance, self.inter_string_unhappiness]
            return round(toolbox.weighted_average(weights, values))
Exemple #2
0
    def calculate_inter_string_salience(self):
        """Return the inter string salience.

        This value represents how much the object is crying out for attention
        from codelets that build structures between strings."""
        if self.clamp_salience:
            return 100
        else:
            weights = [8, 2]
            values = [self.relative_importance, self.inter_string_unhappiness]
            return round(toolbox.weighted_average(weights, values))
Exemple #3
0
    def calculate_internal_strength(self):
        """Return the rule's internal strength."""
        if self.has_no_change():
            return 100

        conceptual_depth1 = self.descriptor1.conceptual_depth
        if self.relation:
            conceptual_depth2 = self.relation.conceptual_depth
        else:
            conceptual_depth2 = self.descriptor2.conceptual_depth

        conceptual_difference = abs(conceptual_depth1 - conceptual_depth2)

        for obj in self.workspace.initial_string.get_objects():
            if obj.is_changed:
                i_object = obj
                break

        if i_object.correspondence:
            i_object_corresponding_object = i_object.correspondence.object2
        else:
            i_object_corresponding_object = None

        if not i_object_corresponding_object:
            shared_descriptor_term = 0
        else:
            slipped_descriptors = []
            for description in i_object_corresponding_object.relevant_descriptions(
            ):
                slips = description.apply_slippages(
                    i_object_corresponding_object, self.workspace.slippages())
                slipped_descriptors.append(slips.descriptor)
            if self.descriptor1 in slipped_descriptors:
                shared_descriptor_term = 100
            else:
                return 0

        depth = (100 - self.descriptor1.conceptual_depth) / 10.
        shared_descriptor_weight = round(depth**1.4)
        weights = [18, 12, shared_descriptor_weight]
        items = [
            toolbox.average(conceptual_depth1, conceptual_depth2),
            100 - conceptual_difference, shared_descriptor_term
        ]
        rule_strength = round(toolbox.weighted_average(weights, items))
        return min(rule_strength, 100)
Exemple #4
0
    def calculate_internal_strength(self):
        """Return the rule's internal strength."""
        if self.has_no_change():
            return 100

        conceptual_depth1 = self.descriptor1.conceptual_depth
        if self.relation:
            conceptual_depth2 = self.relation.conceptual_depth
        else:
            conceptual_depth2 = self.descriptor2.conceptual_depth

        conceptual_difference = abs(conceptual_depth1 - conceptual_depth2)

        for obj in self.workspace.initial_string.get_objects():
            if obj.is_changed:
                i_object = obj
                break

        if i_object.correspondence:
            i_object_corresponding_object = i_object.correspondence.object2
        else:
            i_object_corresponding_object = None

        if not i_object_corresponding_object:
            shared_descriptor_term = 0
        else:
            slipped_descriptors = []
            for description in i_object_corresponding_object.relevant_descriptions():
                slips = description.apply_slippages(i_object_corresponding_object,
                                                    self.workspace.slippages())
                slipped_descriptors.append(slips.descriptor)
            if self.descriptor1 in slipped_descriptors:
                shared_descriptor_term = 100
            else:
                return 0

        depth = (100 - self.descriptor1.conceptual_depth) / 10.
        shared_descriptor_weight = round(depth ** 1.4)
        weights = [18, 12, shared_descriptor_weight]
        items = [toolbox.average(conceptual_depth1, conceptual_depth2),
                 100 - conceptual_difference,
                 shared_descriptor_term]
        rule_strength = round(toolbox.weighted_average(weights, items))
        return min(rule_strength, 100)
Exemple #5
0
    def calculate_internal_strength(self):
        """For now, groups based on letter category are stronger than groups
        based on other facets. This should be fixed; a more general mechanism is
        needed."""
        if self.bond_facet == self.slipnet.plato_letter_category:
            bond_facet_factor = 1
        else:
            bond_facet_factor = .5

        related = self.slipnet.get_related_node(
            self.group_category, self.slipnet.plato_bond_category)
        bond_component = related.degree_of_association() * bond_facet_factor
        length_component = {1: 5, 2: 20, 3: 60}.get(self.length(), 90)

        bond_component_weight = bond_component**.98
        length_component_weight = 100 - bond_component_weight
        return toolbox.weighted_average(
            (bond_component_weight, length_component_weight),
            (bond_component, length_component))
Exemple #6
0
    def calculate_internal_strength(self):
        """For now, groups based on letter category are stronger than groups
        based on other facets. This should be fixed; a more general mechanism is
        needed."""
        if self.bond_facet == self.slipnet.plato_letter_category:
            bond_facet_factor = 1.0
        else:
            bond_facet_factor = .5

        related = self.slipnet.get_related_node(self.group_category,
                                                self.slipnet.plato_bond_category)
        bond_component = related.degree_of_association() * bond_facet_factor
        length_component = {1:5, 2:20, 3:60}.get(self.length(), 90)

        bond_component_weight = bond_component ** .98
        length_component_weight = 100 - bond_component_weight
        return toolbox.weighted_average((bond_component_weight,
                                         length_component_weight),
                                        (bond_component,
                                         length_component))
Exemple #7
0
 def update_total_strength(self):
     """Update the total strength."""
     weights = [self.internal_strength, 100 - self.internal_strength]
     values = [self.internal_strength, self.external_strength]
     self.total_strength = toolbox.weighted_average(weights, values)
Exemple #8
0
 def update_total_strength(self):
     """Update the total strength."""
     weights = [self.internal_strength, 100 - self.internal_strength]
     values = [self.internal_strength, self.external_strength]
     self.total_strength = toolbox.weighted_average(weights, values)