Semantic descriptions

struct TmeSemDesc

Models ALN concept expressions as the conjunction of Ccn, Cgt, Clt, Cuv components.

TmeSemDesc

TmeSemDesc *tme_sem_desc_alloc(void)

Allocates a new semantic description.

Return

Semantic description instance.

TmeSemDesc *tme_sem_desc_copy(TmeSemDesc const *desc)

Copies an existing semantic description.

Return

Copied description.

Note

The copy is deep (value restrictions are recursively copied).

Parameters
  • desc: Description to copy.

void tme_sem_desc_free(TmeSemDesc *desc)

Deallocates the specified semantic description.

Parameters
  • desc: Semantic description to deallocate.

void tme_sem_desc_shrink(TmeSemDesc *desc)

Shrinks the specified semantic description instance, ensuring it takes up the least amount of memory necessary.

Parameters
  • desc: Semantic description instance.

tme_uint_t tme_sem_desc_count(TmeSemDesc const *desc)

Returns the number of conjuncts present in the specified semantic description.

Return

Number of conjuncts.

Parameters
  • desc: Semantic description instance.

bool tme_sem_desc_is_empty(TmeSemDesc const *desc)

Checks whether the specified semantic description has no conjuncts.

Return

True if the semantic description has no conjuncts, false otherwise.

Parameters
  • desc: Semantic description instance.

Vector_TmeEntityPtr const *tme_sem_desc_get_atoms(TmeSemDesc const *desc)

Returns the atomic concepts present in the semantic description.

Return

Atomic concepts.

Warning

The returned pointer becomes invalid once the description is mutated.

Parameters
  • desc: Semantic description instance.

Vector_TmeEntityPtr const *tme_sem_desc_get_negs(TmeSemDesc const *desc)

Returns the negated concepts present in the semantic description.

Return

Negated concepts.

Warning

The returned pointer becomes invalid once the description is mutated.

Parameters
  • desc: Semantic description instance.

Vector_TmeCardinalityRole const *tme_sem_desc_get_gts(TmeSemDesc const *desc)

Returns the minimum cardinality restrictions present in the semantic description.

Return

Minimum cardinality restrictions.

Warning

The returned pointer becomes invalid once the description is mutated.

Parameters
  • desc: Semantic description instance.

Vector_TmeCardinalityRole const *tme_sem_desc_get_lts(TmeSemDesc const *desc)

Returns the maximum cardinality restrictions present in the semantic description.

Return

Maximum cardinality restrictions.

Warning

The returned pointer becomes invalid once the description is mutated.

Parameters
  • desc: Semantic description instance.

Vector_TmeUniversalRole const *tme_sem_desc_get_uvs(TmeSemDesc const *desc)

Returns the value restrictions present in the semantic description.

Return

Value restrictions.

Warning

The returned pointer becomes invalid once the description is mutated.

Parameters
  • desc: Semantic description instance.

bool tme_sem_desc_is_bottom(TmeSemDesc const *desc, TmeEntityPtr bottom)

Checks whether the specified semantic description is equivalent to the bottom concept.

Return

True if the semantic description is equivalent to the bottom concept, false otherwise.

Note

The semantic description must be normalized.

Parameters
  • desc: Semantic description instance.

  • bottom: Entity identifier of the bottom concept.

bool tme_sem_desc_equals(TmeSemDesc const *desc, TmeSemDesc const *other)

Equality function for semantic descriptions.

Return

True if the equality relation holds, false otherwise.

Note

This function has no semantic meaning, as it also accounts for the order in which concepts and roles appear. It’s mainly meant to be used in data structures that require their elements to be equatable.

Parameters
  • desc: LHS of the equality relation.

  • other: RHS of the equality relation.

bool tme_sem_desc_has_atom(TmeSemDesc const *desc, TmeEntityPtr atom)

Checks whether the semantic description contains the specified atomic concept.

Return

True if the atomic concept was found, false otherwise.

Parameters
  • desc: Semantic description instance.

  • atom: Atomic concept.

bool tme_sem_desc_has_neg(TmeSemDesc const *desc, TmeEntityPtr neg)

Checks whether the semantic description contains the specified negated concept.

Return

True if the negated concept was found, false otherwise.

Parameters
  • desc: Semantic description instance.

  • neg: Negated concept.

tme_uint_t tme_sem_desc_get_gt_card(TmeSemDesc const *desc, TmeEntityPtr role)

Retrieves the minimum cardinality of the specified role.

Return

Minimum cardinality.

Parameters
  • desc: Semantic description instance.

  • role: Atomic role.

tme_uint_t tme_sem_desc_get_lt_card(TmeSemDesc const *desc, TmeEntityPtr role)

Retrieves the maximum cardinality of the specified role.

Return

Maximum cardinality.

Parameters
  • desc: Semantic description instance.

  • role: Atomic role.

TmeSemDesc *tme_sem_desc_get_uv_filler(TmeSemDesc const *desc, TmeEntityPtr role)

Retrieves the filler of the value restriction involving the specified role.

Return

Filler of the value restriction involving the role, or NULL.

Parameters
  • desc: Semantic description instance.

  • role: Atomic role.

bool tme_sem_desc_add(TmeSemDesc *desc, TmeSemDesc const *source)

Performs the intersection between two semantic descriptions.

Return

True if the description was mutated, false otherwise.

Note

Only the first semantic description is mutated.

Parameters
  • desc: Semantic description instance.

  • source: Semantic description to intersect ‘desc’ with.

bool tme_sem_desc_add_atoms(TmeSemDesc *desc, TmeSemDesc const *source)

Intersects the atomic concepts of two semantic descriptions.

Return

True if the description was mutated, false otherwise.

Note

Only the first semantic description is mutated.

Parameters
  • desc: Semantic description instance.

  • source: Semantic description to intersect ‘desc’ with.

bool tme_sem_desc_add_negs(TmeSemDesc *desc, TmeSemDesc const *source)

Intersects the negated concepts of two semantic descriptions.

Return

True if the description was mutated, false otherwise.

Note

Only the first semantic description is mutated.

Parameters
  • desc: Semantic description instance.

  • source: Semantic description to intersect ‘desc’ with.

bool tme_sem_desc_add_gts(TmeSemDesc *desc, TmeSemDesc const *source)

Intersects the minimum cardinality restrictions of two semantic descriptions.

Return

True if the description was mutated, false otherwise.

Note

Only the first semantic description is mutated.

Parameters
  • desc: Semantic description instance.

  • source: Semantic description to intersect ‘desc’ with.

bool tme_sem_desc_add_lts(TmeSemDesc *desc, TmeSemDesc const *source)

Intersects the maximum cardinality restrictions of two semantic descriptions.

Return

True if the description was mutated, false otherwise.

Note

Only the first semantic description is mutated.

Parameters
  • desc: Semantic description instance.

  • source: Semantic description to intersect ‘desc’ with.

bool tme_sem_desc_add_uvs(TmeSemDesc *desc, TmeSemDesc const *source)

Intersects the value restrictions of two semantic descriptions.

Return

True if the description was mutated, false otherwise.

Note

Only the first semantic description is mutated.

Parameters
  • desc: Semantic description instance.

  • source: Semantic description to intersect ‘desc’ with.

bool tme_sem_desc_add_atom(TmeSemDesc *desc, TmeEntityPtr atom)

Intersects the specified semantic description with an atomic concept.

Return

True if the description was mutated, false otherwise.

Parameters
  • desc: Semantic description instance.

  • atom: Atomic concept to intersect.

bool tme_sem_desc_add_neg(TmeSemDesc *desc, TmeEntityPtr neg)

Intersects the specified semantic description with a negated concept.

Return

True if the description was mutated, false otherwise.

Parameters
  • desc: Semantic description instance.

  • neg: Negated concept to intersect.

bool tme_sem_desc_add_gt(TmeSemDesc *desc, TmeEntityPtr role, tme_uint_t cardinality)

Intersects the specified semantic description with a minimum cardinality restriction.

Return

True if the description was mutated, false otherwise.

Parameters
  • desc: Semantic description instance.

  • role: Atomic role.

  • cardinality: Minimum cardinality.

bool tme_sem_desc_add_lt(TmeSemDesc *desc, TmeEntityPtr role, tme_uint_t cardinality)

Intersects the specified semantic description with a maximum cardinality restriction.

Return

True if the description was mutated, false otherwise.

Parameters
  • desc: Semantic description instance.

  • role: Atomic role.

  • cardinality: Maximum cardinality.

bool tme_sem_desc_add_uv(TmeSemDesc *desc, TmeEntityPtr role, TmeSemDesc const *filler)

Intersects the specified semantic description with a value restriction.

Return

True if the description was mutated, false otherwise.

Parameters
  • desc: Semantic description instance.

  • role: Atomic role.

  • filler: Filler of the value restriction.

bool tme_sem_desc_set_gt(TmeSemDesc *desc, TmeEntityPtr role, tme_uint_t cardinality)

Sets the minimum cardinality of the specified role.

Return

True if the description was mutated, false otherwise.

Parameters
  • desc: Semantic description instance.

  • role: Atomic role.

  • cardinality: Minimum cardinality.

bool tme_sem_desc_set_lt(TmeSemDesc *desc, TmeEntityPtr role, tme_uint_t cardinality)

Sets the maximum cardinality of the specified role.

Return

True if the description was mutated, false otherwise.

Parameters
  • desc: Semantic description instance.

  • role: Atomic role.

  • cardinality: Maximum cardinality.

bool tme_sem_desc_set_uv(TmeSemDesc *desc, TmeEntityPtr role, TmeSemDesc const *filler)

Sets the filler of the specified value restriction.

Return

True if the description was mutated, false otherwise.

Parameters
  • desc: Semantic description instance.

  • role: Atomic role.

  • filler: Filler of the value restriction.

bool tme_sem_desc_remove_atom(TmeSemDesc *desc, TmeEntityPtr concept)

Removes an atomic concept from the specified semantic description.

Return

True if the description was mutated, false otherwise.

Parameters
  • desc: Semantic description instance.

  • concept: Atomic concept to remove.

bool tme_sem_desc_remove_neg(TmeSemDesc *desc, TmeEntityPtr concept)

Removes a negated concept from the specified semantic description.

Return

True if the description was mutated, false otherwise.

Parameters
  • desc: Semantic description instance.

  • concept: Negated concept to remove.

bool tme_sem_desc_remove_gt(TmeSemDesc *desc, TmeEntityPtr role)

Removes the minimum cardinality restriction of the specified role.

Return

True if the description was mutated, false otherwise.

Parameters
  • desc: Semantic description instance.

  • role: Atomic role.

bool tme_sem_desc_remove_lt(TmeSemDesc *desc, TmeEntityPtr role)

Removes the maximum cardinality restriction of the specified role.

Return

True if the description was mutated, false otherwise.

Parameters
  • desc: Semantic description instance.

  • role: Atomic role.

bool tme_sem_desc_remove_uv(TmeSemDesc *desc, TmeEntityPtr role)

Removes the value restriction of the specified role.

Return

True if the description was mutated, false otherwise.

Parameters
  • desc: Semantic description instance.

  • role: Atomic role.

void tme_sem_desc_remove_atom_at(TmeSemDesc *desc, tme_uint_t idx)

Removes the atomic concept at the specified index.

Parameters
  • desc: Semantic description instance.

  • idx: Index of the atomic concept to remove.

void tme_sem_desc_remove_neg_at(TmeSemDesc *desc, tme_uint_t idx)

Removes the negated concept at the specified index.

Parameters
  • desc: Semantic description instance.

  • idx: Index of the negated concept to remove.

void tme_sem_desc_remove_gt_at(TmeSemDesc *desc, tme_uint_t idx)

Removes the minimum cardinality restriction at the specified index.

Parameters
  • desc: Semantic description instance.

  • idx: Index of the minimum cardinality restriction to remove.

void tme_sem_desc_remove_lt_at(TmeSemDesc *desc, tme_uint_t idx)

Removes the maximum cardinality restriction at the specified index.

Parameters
  • desc: Semantic description instance.

  • idx: Index of the maximum cardinality restriction to remove.

void tme_sem_desc_remove_uv_at(TmeSemDesc *desc, tme_uint_t idx)

Removes the value restriction at the specified index.

Parameters
  • desc: Semantic description instance.

  • idx: Index of the value restriction to remove.

bool tme_sem_desc_remove_all(TmeSemDesc *desc)

Removes all conjuncts from the semantic description.

Return

True if the description was mutated, false otherwise.

Parameters
  • desc: Semantic description instance.

bool tme_sem_desc_remove_all_atoms(TmeSemDesc *desc)

Removes all the atomic concepts.

Return

True if the description was mutated, false otherwise.

Parameters
  • desc: Semantic description instance.

bool tme_sem_desc_remove_all_negs(TmeSemDesc *desc)

Removes all the negated concepts.

Return

True if the description was mutated, false otherwise.

Parameters
  • desc: Semantic description instance.

bool tme_sem_desc_remove_all_gts(TmeSemDesc *desc)

Removes all the minimum cardinality restrictions.

Return

True if the description was mutated, false otherwise.

Parameters
  • desc: Semantic description instance.

bool tme_sem_desc_remove_all_lts(TmeSemDesc *desc)

Removes all the maximum cardinality restrictions.

Return

True if the description was mutated, false otherwise.

Parameters
  • desc: Semantic description instance.

bool tme_sem_desc_remove_all_uvs(TmeSemDesc *desc)

Removes all the value restrictions.

Return

True if the description was mutated, false otherwise.

Parameters
  • desc: Semantic description instance.

tme_sem_desc_atom_count(desc)

Returns the number of atomic concepts present in the semantic description.

Return

Number of atomic concepts.

Parameters
  • desc: Semantic description instance.

tme_sem_desc_neg_count(desc)

Returns the number of negated concepts present in the semantic description.

Return

Number of negated concepts.

Parameters
  • desc: Semantic description instance.

tme_sem_desc_gt_count(desc)

Returns the number of minimum cardinality restrictions present in the semantic description.

Return

Number of minimum cardinality restrictions.

Parameters
  • desc: Semantic description instance.

tme_sem_desc_lt_count(desc)

Returns the number of maximum cardinality restrictions present in the semantic description.

Return

Number of maximum cardinality restrictions.

Parameters
  • desc: Semantic description instance.

tme_sem_desc_uv_count(desc)

Returns the number of value restrictions present in the semantic description.

Return

Number of value restrictions.

Parameters
  • desc: Semantic description instance.

tme_sem_desc_iterate_atoms(desc, concept, i, code)

Iterates over the atoms present in the semantic description, executing the specified code block for each element.

Warning

You must not mutate the description while iterating.

Parameters
  • desc: Semantic description instance.

  • concept: Name of the variable holding the concept.

  • i: Name of the index variable.

  • code: Code block to execute.

tme_sem_desc_iterate_atoms_reverse(desc, concept, i, code)

Iterates over the atoms present in the semantic description in reverse order, executing the specified code block for each element.

Warning

You must not mutate the description while iterating.

Parameters
  • desc: Semantic description instance.

  • concept: Name of the variable holding the concept.

  • i: Name of the index variable.

  • code: Code block to execute.

tme_sem_desc_foreach_atom(desc, concept, code)

Iterates over the atoms present in the semantic description, executing the specified code block for each element.

Warning

You must not mutate the description while iterating.

Parameters
  • desc: Semantic description instance.

  • concept: Name of the variable holding the concept.

  • code: Code block to execute.

tme_sem_desc_iterate_negs(desc, neg, i, code)

Iterates over the negated concepts present in the semantic description, executing the specified code block for each element.

Warning

You must not mutate the description while iterating.

Parameters
  • desc: Semantic description instance.

  • neg: Name of the variable holding the negated concept.

  • i: Name of the index variable.

  • code: Code block to execute.

tme_sem_desc_iterate_negs_reverse(desc, neg, i, code)

Iterates over the negated concepts present in the semantic description in reverse order, executing the specified code block for each element.

Warning

You must not mutate the description while iterating.

Parameters
  • desc: Semantic description instance.

  • neg: Name of the variable holding the negated concept.

  • i: Name of the index variable.

  • code: Code block to execute.

tme_sem_desc_foreach_neg(desc, neg, code)

Iterates over the negated concepts present in the semantic description, executing the specified code block for each element.

Warning

You must not mutate the description while iterating.

Parameters
  • desc: Semantic description instance.

  • neg: Name of the variable holding the negated concept.

  • code: Code block to execute.

tme_sem_desc_iterate_gts(desc, gt_role, i, code)

Iterates over the minimum cardinality restrictions present in the semantic description, executing the specified code block for each element.

Warning

You must not mutate the description while iterating.

Parameters
  • desc: Semantic description instance.

  • gt_role: Name of the variable holding the minimum cardinality restriction.

  • i: Name of the index variable.

  • code: Code block to execute.

tme_sem_desc_iterate_gts_reverse(desc, gt_role, i, code)

Iterates over the minimum cardinality restrictions present in the semantic description in reverse order, executing the specified code block for each element.

Warning

You must not mutate the description while iterating.

Parameters
  • desc: Semantic description instance.

  • gt_role: Name of the variable holding the minimum cardinality restriction.

  • i: Name of the index variable.

  • code: Code block to execute.

tme_sem_desc_foreach_gt(desc, gt_role, code)

Iterates over the minimum cardinality restrictions present in the semantic description, executing the specified code block for each element.

Warning

You must not mutate the description while iterating.

Parameters
  • desc: Semantic description instance.

  • gt_role: Name of the variable holding the minimum cardinality restriction.

  • code: Code block to execute.

tme_sem_desc_iterate_lts(desc, lt_role, i, code)

Iterates over the maximum cardinality restrictions present in the semantic description, executing the specified code block for each element.

Warning

You must not mutate the description while iterating.

Parameters
  • desc: Semantic description instance.

  • lt_role: Name of the variable holding the maximum cardinality restriction.

  • i: Name of the index variable.

  • code: Code block to execute.

tme_sem_desc_iterate_lts_reverse(desc, lt_role, i, code)

Iterates over the maximum cardinality restrictions present in the semantic description in reverse order, executing the specified code block for each element.

Warning

You must not mutate the description while iterating.

Parameters
  • desc: Semantic description instance.

  • lt_role: Name of the variable holding the maximum cardinality restriction.

  • i: Name of the index variable.

  • code: Code block to execute.

tme_sem_desc_foreach_lt(desc, lt_role, code)

Iterates over the maximum cardinality restrictions present in the semantic description, executing the specified code block for each element.

Warning

You must not mutate the description while iterating.

Parameters
  • desc: Semantic description instance.

  • lt_role: Name of the variable holding the maximum cardinality restriction.

  • code: Code block to execute.

tme_sem_desc_iterate_uvs(desc, uv_role, i, code)

Iterates over the value restrictions present in the semantic description, executing the specified code block for each element.

Warning

You must not mutate the description while iterating.

Parameters
  • desc: Semantic description instance.

  • uv_role: Name of the variable holding the value restriction.

  • i: Name of the index variable.

  • code: Code block to execute.

tme_sem_desc_iterate_uvs_reverse(desc, uv_role, i, code)

Iterates over the value restrictions present in the semantic description in reverse order, executing the specified code block for each element.

Warning

You must not mutate the description while iterating.

Parameters
  • desc: Semantic description instance.

  • uv_role: Name of the variable holding the value restriction.

  • i: Name of the index variable.

  • code: Code block to execute.

tme_sem_desc_foreach_uv(desc, uv_role, code)

Iterates over the value restrictions present in the semantic description, executing the specified code block for each element.

Warning

You must not mutate the description while iterating.

Parameters
  • desc: Semantic description instance.

  • uv_role: Name of the variable holding the value restriction.

  • code: Code block to execute.