olaf.repository.knowledge_source package¶
Submodules¶
olaf.repository.knowledge_source.conceptnet_kg module¶
- class olaf.repository.knowledge_source.conceptnet_kg.ConceptNetKnowledgeResource(lang: str | None = None, api_resp_batch_size: int | None = 1000, check_sources: bool | None = False, validation_sources: Set[str] | None = {})[source]¶
Bases:
KnowledgeSource
Adapter for the ConceptNet KG: https://conceptnet.io/.
Attributes¶
- lang: str, optional
Language ISO code for the terms to find concepts for, by default ‘en’.
- api_resp_batch_size: int, optional
Batch size for the ConceptNet API when fetching data, by default 1000.
- check_sources: bool, optional
Wether or not to filter the concepts based on provided sources, default False.
- validation_sources: Set[str], optional
The sources to use to filter the concepts, default set().
- check_resources() None [source]¶
Method to check that the component has access to all its required resources.
- fetch_terms_antonyms(terms: Set[str]) Set[str] [source]¶
Method to fetch antonyms of a set of terms according to the knowledge source.
Parameters¶
- termsSet[str]
The set of terms to find antonyms of.
Returns¶
- Set[str]
The set of terms antonyms.
- fetch_terms_hypernyms(terms: Set[str]) Set[str] [source]¶
Method to fetch hypernyms of a set of terms according to the knowledge source.
Parameters¶
- termsSet[str]
The set of terms to find hypernyms of.
Returns¶
- Set[str]
The set of terms hypernyms.
- fetch_terms_hyponyms(terms: Set[str]) Set[str] [source]¶
Method to fetch hyponyms of a set of terms according to the knowledge source.
Parameters¶
- termsSet[str]
The set of terms to find hyponyms of.
Returns¶
- Set[str]
The set of terms hyponyms.
olaf.repository.knowledge_source.knowledge_source_schema module¶
- class olaf.repository.knowledge_source.knowledge_source_schema.KnowledgeSource[source]¶
Bases:
ABC
Knowledge sources are any external sources of knowledge.
- abstract check_resources() None [source]¶
Method to check that the component has access to all its required resources.
- abstract fetch_terms_antonyms(terms: Set[str]) Set[str] [source]¶
Method to fetch antonyms of a set of terms according to the knowledge source.
Parameters¶
- termsSet[str]
The set of terms to find antonyms of.
Returns¶
- Set[str]
The set of terms antonyms.
- abstract fetch_terms_hypernyms(terms: Set[str]) Set[str] [source]¶
Method to fetch hypernyms of a set of terms according to the knowledge source.
Parameters¶
- termsSet[str]
The set of terms to find hypernyms of.
Returns¶
- Set[str]
The set of terms hypernyms.
- abstract fetch_terms_hyponyms(terms: Set[str]) Set[str] [source]¶
Method to fetch hyponyms of a set of terms according to the knowledge source.
Parameters¶
- termsSet[str]
The set of terms to find hyponyms of.
Returns¶
- Set[str]
The set of terms hyponyms.
olaf.repository.knowledge_source.wordnet_kg module¶
- class olaf.repository.knowledge_source.wordnet_kg.WordNetKnowledgeResource(lang: str | None = None, use_domains: bool | None = False, use_pos: bool | None = False, wordnet_domains_map: Dict[str, Set[str]] | None = None, wordnet_domains_path: str | None = None, enrichment_domains: Set[str] | None = None, enrichment_domains_path: str | None = None, wordnet_pos: Set[str] | None = None)[source]¶
Bases:
KnowledgeSource
Adapter for the WordNet linguistic knowledge base: .
Attributes¶
- lang: str, optional
Language ISO code for the terms to find concepts and terms for, by default ‘en’.
- use_domains: bool, optional
Wether or not to filter the matchings on provided domains, by default False.
- use_pos: bool, optional
Wether or not to filter the matchings on provided part of speech tags, by default False.
- wordnet_domains_map: Dict[str, Set[str]], optional
The mapping between WordNet synsets ids and domains ids, by default None. The expected file can be found at <https://github.com/argilla-io/spacy-wordnet/blob/master/spacy_wordnet/data/wordnet_domains.txt>
- enrichment_domains: Set[str], optional
The set of enrichment domains strings to use for matching. Mandatory when use_domains is True, by default to None.
- wordnet_pos: Set[str], optional
The set of part of speech tags to use for matching. Mandatory when use_pos is True, by default to None.
- check_resources() None [source]¶
Method to check that the component has access to all its required resources.
- fetch_terms_antonyms(terms: Set[str]) Set[str] [source]¶
Method to fetch antonyms of a set of terms from WordNet.
Parameters¶
- termsSet[str]
The set of terms to find antonyms of.
Returns¶
- Set[str]
The set of terms antonyms.
- fetch_terms_hypernyms(terms: Set[str]) Set[str] [source]¶
Method to fetch hypernyms of a set of terms from WordNet.
Parameters¶
- termsSet[str]
The set of terms to find hypernyms of.
Returns¶
- Set[str]
The set of terms hypernyms.
- fetch_terms_hyponyms(terms: Set[str]) Set[str] [source]¶
Method to fetch hyponyms of a set of terms according to the knowledge source.
Parameters¶
- termsSet[str]
The set of terms to find hyponyms of.
Returns¶
- Set[str]
The set of terms hyponyms.