class documentation
class OnlineAPI(AbstractAPI):
The online api
Method | iterator |
Create a new instance of BabelSynset iterator. |
Method | lexicon |
Create a new instance of a lexicon iterator. |
Method | offset |
Create a new instance of an offset iterator. |
Method | to |
Convert from ResourceID to the corresponding BabelSynset. |
Method | version |
Get the version of loaded BabelNet indices. |
Method | wordnet |
Create a new instance of a WordNet iterator. |
Method | _get |
Return the outgoing edges from a given BabelSynsetID |
Method | _get |
Private version of get_senses(). |
Method | _get |
Private method that returns a list of synset ids given a list of languages and a ResourceID. |
Method | _get |
Private version of get_synsets() |
Method | images |
Get the images of a BabelSynsetID. |
Inherited from AbstractAPI
:
Method | get |
Get the senses of synsets searched by words or by ResourceIDs, satisfying the optional constraints. |
Method | get |
Get the senses of synsets containing the word with the given constraints. |
Method | get |
Get the senses of synsets from the word with the given constraints. |
Method | get |
Return the synset identified by the ResourceID in input. |
Method | get |
Get synsets by words or by ResourceIDs, satisfying the optional constraints. |
Method | to |
Get a BabelSytnset using the languages passed as input and an id_. |
Method | _mapping |
Get the mapping from BabelSynsetID to _InternalBabelSynsetID. |
Method | _prepare |
Prepare the input data by trasforming each iterable in an ordered set. |
Method | _to |
Convert a WordNetSynsetID into a Synset. |
Method | examples |
Get the examples (in the specified languages) of a BabelSynsetID. |
Method | get |
Return the outgoing edges from a given BabelSynsetID |
Method | glosses |
Get the glosses (in the specified languages) of a BabelSysetID. |
def iterator(self):
Create a new instance of BabelSynset iterator.
Returns | |
BabelSynsetIterator | An instance of a BabelSynset iterator. |
Raises | |
NotImplementedError | Raised if the function is called using online APIs. |
def lexicon_iterator(self):
Create a new instance of a lexicon iterator.
Returns | |
BabelLexiconIterator | An instance of a lexicon iterator. |
Raises | |
NotImplementedError | Raised if the function is called using online APIs. |
def offset_iterator(self):
Create a new instance of an offset iterator.
Returns | |
BabelOffsetIterator | An instance of an offset iterator. |
Raises | |
NotImplementedError | Raised if the function is called using online APIs. |
Convert from ResourceID to the corresponding BabelSynset.
Parameters | |
resourceResourceID | The input ID. |
languages:Optional[Iterable[Language]] | The target languages to populate synsets with (default None). |
Returns | |
List[BabelSynset] | The list of corresponding synsets. |
Raises | |
NotImplementedError | if not implemented |
def version(self):
Get the version of loaded BabelNet indices.
Returns | |
BabelVersion | The BabelVersion of BabelNet indices. |
Raises | |
RuntimeError | Raised if cannot decode the response from server or if other error occured. |
def wordnet_iterator(self):
Create a new instance of a WordNet iterator.
Returns | |
WordNetSynsetIterator | An instance of a WordNetSynset iterator. |
Raises | |
NotImplementedError | Raised if the function is called using online APIs. |
def _get_outgoing_edges(self, synset_id):
Return the outgoing edges from a given BabelSynsetID
Parameters | |
synsetBabelSynsetID | The BabelSynsetID whose outgoing edges we want to retrieve. |
Returns | |
List[BabelSynsetRelation] | The list of relation edges. |
def _get_senses(self, words=None, resource_ids=None, containing=False, to_langs=None, sources=None, **kwargs):
Private version of get_senses().
Parameters | |
words:Optional[ | A set of words to look for |
resourceOptional[ | a set of resource ids to look for |
containing:Optional[ | Contaninig parameter. |
toOptional[ | If set, the results will be in these languages |
sources:Optional[ | filter on the sources |
**kwargs | keyword arguemts.s |
Returns | |
List[BabelSense] | the list of BabelSenses |
Raises | |
NotImplementedError | if not implemented |
def _get_synset_ids(self, to_langs, *resource_ids):
Private method that returns a list of synset ids given a list of languages and a ResourceID.
Parameters | |
toSequence[ | the sequence of languages to use |
*resourceResourceID | the ResourceID from where the information to construct the BabelSynsetID will be retrieved |
Returns | |
Optional[ | A list of the BabelSynsetIDs that were retreived from the ResourceIDs passed as input. |
def _get_synsets(self, words=None, resource_ids=None, from_langs=None, to_langs=None, poses=None, normalized=True, sources=None, synset_filters=None, sense_filters=None):
Private version of get_synsets()
Parameters | |
words:Optional[ | A set of words to look for |
resourceOptional[ | a set of resource ids to look for |
fromOptional[ | The language of the words passed as input |
toOptional[ | If set, the results will be in these languages |
poses:Sequence[ | Filter on poses |
normalized:Optional[ | if true, results will be normalized |
sources:Optional[ | filter on sources |
synsetOptional[ | filter on synsets |
senseOptional[ | filter on senses |
Returns | |
List[BabelSynset] | the list of BabelSynset. |
Raises | |
NotImplementedError | if not implemented |
def images(self, id):
Get the images of a BabelSynsetID.
Parameters | |
id:BabelSynsetID | the BabelSynsetID to use |
Returns | |
List[BabelImage] | A list of BabelImages |
Raises | |
NotImplementedError | Raised if the function is called using online APIs. |