fuzzy_dl_owl2.fuzzydl.concept.has_value_concept

Implements a specific type of existential restriction known as a has-value concept within a fuzzy description logic system.

Description

The software models a logical construct where an individual must be related to a specific value through a defined role, representing the form (b-some r v). By inheriting from a base concept class and a specific interface, the implementation manages the storage of the role and value pair while providing functionality to generate a standardized string representation for identification. Logical operations such as conjunction, disjunction, and negation are supported through delegation to an operator utility, allowing these concepts to be combined into complex expressions without modifying the original instances. Additionally, the implementation includes mechanisms for deep cloning to ensure data independence and defines a hash value based on the string representation to facilitate use in hash-based collections. To maintain structural integrity, attempts to replace internal sub-concepts are explicitly prevented, treating the entity as an atomic unit during such operations.

Classes

HasValueConcept

This class models a specific type of existential restriction, often referred to as a "has-value" concept, which asserts that an individual must be related to a specific value through a defined role. Structurally, it represents the logical form (b-some r v), meaning an entity satisfies this concept if it participates in the relationship r with a target entity that corresponds to v. To utilize this class, instantiate it by providing a string representing the role and the target value, which can be of various types such as strings or numbers. Once created, the concept can be combined with other concepts using standard logical operators like conjunction, disjunction, and negation, and it automatically generates a standardized string representation for identification. Note that attempting to replace sub-concepts within this specific concept type will result in an error, as it is treated as an atomic unit in that context.

Module Contents

UML Class Diagram for HasValueConcept

UML Class Diagram for HasValueConcept

class HasValueConcept(role: str, value: Any)[source]

Bases: fuzzy_dl_owl2.fuzzydl.concept.concept.Concept, fuzzy_dl_owl2.fuzzydl.concept.interface.has_value_interface.HasValueInterface

Inheritance diagram of fuzzy_dl_owl2.fuzzydl.concept.has_value_concept.HasValueConcept

This class models a specific type of existential restriction, often referred to as a “has-value” concept, which asserts that an individual must be related to a specific value through a defined role. Structurally, it represents the logical form (b-some r v), meaning an entity satisfies this concept if it participates in the relationship r with a target entity that corresponds to v. To utilize this class, instantiate it by providing a string representing the role and the target value, which can be of various types such as strings or numbers. Once created, the concept can be combined with other concepts using standard logical operators like conjunction, disjunction, and negation, and it automatically generates a standardized string representation for identification. Note that attempting to replace sub-concepts within this specific concept type will result in an error, as it is treated as an atomic unit in that context.

Parameters:

name (str) – String representation of the concept in the format (b-some role value).

__and__(value: Self) Self[source]

Performs a bitwise AND operation between the current instance and another value of the same type, enabling the use of the & operator. The logic is delegated to OperatorConcept.and_, which constructs and returns a new instance representing the conjunction of the two operands. This method generally does not modify the original instances, but may raise an error if the provided value is not a compatible type.

Parameters:

value (Self) – The other operand to combine with the current instance using the AND operation.

Returns:

The result of the AND operation between the current instance and the provided value.

Return type:

Self

__hash__() int[source]

Returns an integer hash value derived from the string representation of the object, allowing instances to be used as dictionary keys or stored in sets. The calculation is performed by passing the result of __str__ to the built-in hash function. Because the hash depends on the string output, any mutation of the object that alters its string representation will result in a different hash, which may cause the object to become inaccessible if it is used as a key in a hash-based collection after modification.

Returns:

An integer hash of the object’s string representation.

Return type:

int

__neg__() fuzzy_dl_owl2.fuzzydl.concept.concept.Concept[source]

Overloads the unary minus operator to provide the logical negation of the current concept. This method returns a new Concept instance representing the inverse condition of the original object, effectively wrapping it in a logical ‘NOT’ operation by delegating to OperatorConcept.not_. The operation is side-effect free, leaving the original instance unmodified.

Returns:

The logical negation of this concept.

Return type:

Concept

__or__(value: Self) Self[source]

Performs a logical OR operation between the current concept and another value using the bitwise OR operator (|). This method delegates the logic to OperatorConcept.or_, constructing and returning a new instance that represents the combination of the two operands. It allows for the chaining or composition of concepts without modifying the original objects.

Parameters:

value (Self) – The right-hand operand for the OR operation, which must be an instance of the same class.

Returns:

A new instance representing the logical OR of the current object and the provided value.

Return type:

Self

clone() Self[source]

Creates and returns a new instance of the class that is a deep copy of the current object. The new instance preserves the role attribute from the original, while the value attribute is recursively copied using copy.deepcopy to ensure that modifications to the new object’s value do not affect the original. This method is useful for creating independent duplicates of the concept without altering the source data, though it may raise an exception if the value contains objects that cannot be deep-copied.

Returns:

A new instance of the class with the same role and a deep copy of the value.

Return type:

Self

compute_atomic_concepts() set[fuzzy_dl_owl2.fuzzydl.concept.concept.Concept][source]

Returns an empty set, as a HasValueConcept does not decompose into or reference any atomic named concepts. Unlike complex class expressions that might be unions or intersections of other classes, a HasValue restriction is defined solely by a property and a specific filler value, meaning there are no atomic concepts to extract. This method has no side effects and consistently returns an empty set regardless of the internal state of the concept.

Returns:

A set of atomic concepts computed by the object.

Return type:

set[Concept]

compute_name() str | None[source]

Constructs a string identifier for the concept by interpolating its role and value attributes into a specific parenthetical format. The output follows the pattern ‘(b-some role value)’, serving as a computed name for the entity. This method does not modify the object’s state and assumes that the role and value attributes are available for string formatting.

Returns:

A string representing the computed name, formatted as “(b-some {role} {value})”.

Return type:

Optional[str]

get_roles() set[str][source]

Retrieves the set of roles associated with the current concept. This default implementation returns an empty set, signifying that no roles are inherently defined for this base concept. The method is designed to be overridden by subclasses to return specific role identifiers as strings, allowing for the extension of functionality within the broader module hierarchy. Because a new set instance is created on every invocation, the operation has no side effects on the object’s state.

Returns:

A set of strings representing the roles assigned to the object.

Return type:

set[str]

static has_value(role: str, i: Any) Self[source]

Creates and returns a new instance of the HasValueConcept class, associating a specific value with a defined role. This static method acts as a factory function, allowing for the instantiation of the concept using a role identifier and an arbitrary value of any type. Since the method simply delegates to the class constructor, it has no side effects and relies on the underlying class implementation for any input validation or processing.

Parameters:
  • role (str) – A string identifying the role or name of the value.

  • i (Any) – The value to be associated with the specified role.

Returns:

An instance of HasValueConcept initialized with the provided role and value.

Return type:

Self

replace(
a: fuzzy_dl_owl2.fuzzydl.concept.concept.Concept,
c: fuzzy_dl_owl2.fuzzydl.concept.concept.Concept,
) fuzzy_dl_owl2.fuzzydl.concept.concept.Concept[source]

This method attempts to replace a specified concept a with another concept c within the current object’s structure. However, this functionality is not supported for HasValueConcept instances; invoking it results in an error being reported and the method returning None rather than performing a substitution.

Parameters:
  • a (Concept) – The concept to be replaced within the current structure.

  • c (Concept) – The concept to use as the replacement.

Returns:

None, after logging an error indicating that the replacement operation is not supported.

Return type:

Concept

name: str

Updates the name of the Concept instance to the specified string value. This setter modifies the object’s internal state by assigning the provided value to the private _name attribute, effectively replacing any previously stored name.

Parameters:

value (str) – The new name to assign to the object.