filip.semantics package

Subpackages

Submodules

filip.semantics.semantics_manager module

filip.semantics.semantics_models module

filip.semantics.vocabulary_configurator module

Module providing an interface to manipulate the sources of a vocabulary, and to ability to export it to models

exception filip.semantics.vocabulary_configurator.ParsingException(value)[source]

Bases: Exception

Error Class that is raised if parsing of an ontology was unsuccessful

class filip.semantics.vocabulary_configurator.VocabularyConfigurator[source]

Bases: object

Class that provides static interfaces to manipulate the sources of a vocabulary, validate and save it.

classmethod add_ontology_to_vocabulary_as_file(vocabulary: Vocabulary, path_to_file: str, source_name: str | None = None) Vocabulary[source]

Add a source to the vocabulary with via a file path. Source name will be extracted from path, if no name is given

Parameters:
  • vocabulary (Vocabulary) – Vocabulary to which the source should

  • added (be) –

  • path_to_file (str) – Path to the source file

  • source_name (Optional[str]) – Name for the source

Raises:
  • ParsingException – If the given source was not valid and could not

  • be parsed

Returns:

New Vocabulary with the given source added to it

Add a source to the vocabulary with via a weblink. Source name will be extracted from link, if no name is given

Parameters:
  • vocabulary (Vocabulary) – Vocabulary to which the source should

  • added (be) –

  • link (str) – Weblink to the source

  • source_name (Optional[str]) – Name for the source

Raises:
  • ParsingException – If the given source was not valid and could not

  • be parsed

Returns:

New Vocabulary with the given source added to it

classmethod add_ontology_to_vocabulary_as_string(vocabulary: Vocabulary, source_name: str, source_content: str) Vocabulary[source]

Add a source to the vocabulary by giving the source content as string. Source name needs to be given

Parameters:
  • vocabulary (Vocabulary) – Vocabulary to which the source should

  • added (be) –

  • source_content (str) – Content of source

  • source_name (str) – Name for the source

Raises:
  • ParsingException – If the given source was not valid and could not

  • be parsed

Returns:

New Vocabulary with the given source added to it

classmethod create_vocabulary(settings: VocabularySettings = VocabularySettings(pascal_case_class_labels=True, pascal_case_individual_labels=True, camel_case_property_labels=True, camel_case_datatype_labels=True, pascal_case_datatype_enum_labels=True)) Vocabulary[source]

Create a new blank vocabulary with given settings

Parameters:

settings – VocabularySettings

Returns:

Vocabulary

classmethod delete_source_from_vocabulary(vocabulary: Vocabulary, source_id: str) Vocabulary[source]

Delete a source from the vocabulary

Parameters:
  • vocabulary (Vocabulary) – Vocabulary from which the source should

  • removed (be) –

  • source_id (str) – Id of source to remove

Raises:

ValueError – If no source with given Id exists in Vocabulary

Returns:

New Vocabulary without the given source

classmethod generate_vocabulary_models(vocabulary: Vocabulary, path: str | None = None, filename: str | None = None, alternative_manager_name: str | None = None) str | None[source]

Export the given vocabulary as python model file. All vocabulary classes will be converted to python classes, with their CRs as property fields. If path and filename are given, the generated file will be saved, else the file content is returned as string.

Parameters:
  • vocabulary (Vocabulary) – Vocabulary to export

  • path (Optional[str]) – Path where the file should be saved

  • filename (Optional[str]) – Name of the file

  • alternative_manager_name (Optional[str]) – alternative name for the semantic_manager. The manager of the model can than also be referenced over the object with this name

Raises:
  • Exception – if file can not be saved as specified with path and filename

  • Exception – if vocabulary has label conflicts and is thus not valid

Returns:

Optional[str], generated content if path or filename not given

classmethod get_label_conflicts_in_vocabulary(vocabulary: Vocabulary) LabelSummary[source]

Compute a summary for all labels present in the vocabulary. The summary contains all naming clashes and illegal labels.

Parameters:

vocabulary (Vocabulary) – Vocabulary to analyse

Returns:

LabelSummary

classmethod get_missing_dependencies(vocabulary: Vocabulary) List[str][source]

Get a list of all Dependencies that are currently missing in the vocabulary in form of iris

Parameters:

vocabulary (Vocabulary) – Vocabulary to analyse

Returns:

List of missing iris

Return type:

List[str]

classmethod get_missing_dependency_statements(vocabulary: Vocabulary) List[DependencyStatement][source]

Get a list of all Dependencies that are currently missing in the vocabulary in form of DependencyStatements

Parameters:

vocabulary (Vocabulary) – Vocabulary to analyse

Returns:

List[DependencyStatement]

classmethod get_parsing_logs(vocabulary: Vocabulary) List[ParsingError][source]

Get the parsing logs of a vocabulary

Parameters:

vocabulary (Vocabulary) – Vocabulary to analyse

Returns:

List[ParsingError]

classmethod is_label_blacklisted(label: str) bool[source]

Checks if the given label is forbidden for an entity to possess

Parameters:

label (str) – label to check

Returns:

bool

classmethod is_label_illegal(label: str) bool[source]

Checks if the given label contains a forbidden char

Parameters:

label (str) – label to check

Returns:

bool, True if label forbidden

classmethod is_vocabulary_valid(vocabulary: Vocabulary) bool[source]

Test if the given vocabulary is valid -> all labels are unique and correct

Parameters:

vocabulary (Vocabulary) – Vocabulary to analyse

Returns:

bool