class documentation

class OnlineAPI(AbstractAPI):

View In Hierarchy

The online api

Method iterator Create a new instance of BabelSynset iterator.
Method lexicon_iterator Create a new instance of a lexicon iterator.
Method offset_iterator Create a new instance of an offset iterator.
Method to_synsets Convert from ResourceID to the corresponding BabelSynset.
Method version Get the version of loaded BabelNet indices.
Method wordnet_iterator Create a new instance of a WordNet iterator.
Method _get_outgoing_edges Return the outgoing edges from a given BabelSynsetID
Method _get_senses Private version of get_senses().
Method _get_synset_ids Private method that returns a list of synset ids given a list of languages and a ResourceID.
Method _get_synsets Private version of get_synsets()
Method images Get the images of a BabelSynsetID.

Inherited from AbstractAPI:

Method get_senses Get the senses of synsets searched by words or by ResourceIDs, satisfying the optional constraints.
Method get_senses_containing Get the senses of synsets containing the word with the given constraints.
Method get_senses_from Get the senses of synsets from the word with the given constraints.
Method get_synset Return the synset identified by the ResourceID in input.
Method get_synsets Get synsets by words or by ResourceIDs, satisfying the optional constraints.
Method to_babelnet_synsets Get a BabelSytnset using the languages passed as input and an id_.
Method _mapping_from_ids Get the mapping from BabelSynsetID to _InternalBabelSynsetID.
Method _prepare_kwargs Prepare the input data by trasforming each iterable in an ordered set.
Method _to_wordnet_synsets Convert a WordNetSynsetID into a Synset.
Method examples Get the examples (in the specified languages) of a BabelSynsetID.
Method get_outgoing_edges 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
BabelSynsetIteratorAn instance of a BabelSynset iterator.
Raises
NotImplementedErrorRaised if the function is called using online APIs.
def lexicon_iterator(self):

Create a new instance of a lexicon iterator.

Returns
BabelLexiconIteratorAn instance of a lexicon iterator.
Raises
NotImplementedErrorRaised if the function is called using online APIs.
def offset_iterator(self):

Create a new instance of an offset iterator.

Returns
BabelOffsetIteratorAn instance of an offset iterator.
Raises
NotImplementedErrorRaised if the function is called using online APIs.
def to_synsets(self, resource_id, languages=None):

Convert from ResourceID to the corresponding BabelSynset.

Parameters
resource_id:ResourceIDThe input ID.
languages:Optional[Iterable[Language]]The target languages to populate synsets with (default None).
Returns
List[BabelSynset]The list of corresponding synsets.
Raises
NotImplementedErrorif not implemented
def version(self):

Get the version of loaded BabelNet indices.

Returns
BabelVersionThe BabelVersion of BabelNet indices.
Raises
RuntimeErrorRaised 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
WordNetSynsetIteratorAn instance of a WordNetSynset iterator.
Raises
NotImplementedErrorRaised if the function is called using online APIs.
def _get_outgoing_edges(self, synset_id):

Return the outgoing edges from a given BabelSynsetID

Parameters
synset_id:BabelSynsetIDThe 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[Set[str]]A set of words to look for
resource_ids:Optional[Set[ResourceID]]a set of resource ids to look for
containing:Optional[bool]Contaninig parameter.
to_langs:Optional[Set[Language]]If set, the results will be in these languages
sources:Optional[Set[BabelSenseSource]]filter on the sources
**kwargskeyword arguemts.s
Returns
List[BabelSense]the list of BabelSenses
Raises
NotImplementedErrorif 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
to_langs:Sequence[Language]the sequence of languages to use
*resource_ids:ResourceIDthe ResourceID from where the information to construct the BabelSynsetID will be retrieved
Returns
Optional[List[BabelSynsetID]]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[Sequence[str]]A set of words to look for
resource_ids:Optional[Sequence[ResourceID]]a set of resource ids to look for
from_langs:Optional[Sequence[Language]]The language of the words passed as input
to_langs:Optional[Sequence[Language]]If set, the results will be in these languages
poses:Sequence[Sequence[POS]]Filter on poses
normalized:Optional[bool]if true, results will be normalized
sources:Optional[Sequence[BabelSenseSource]]filter on sources
synset_filters:Optional[Sequence[Callable[[BabelSynset], bool]]]filter on synsets
sense_filters:Optional[Sequence[Callable[[BabelSense], bool]]]filter on senses
Returns
List[BabelSynset]the list of BabelSynset.
Raises
NotImplementedErrorif not implemented
def images(self, id):

Get the images of a BabelSynsetID.

Parameters
id:BabelSynsetIDthe BabelSynsetID to use
Returns
List[BabelImage]A list of BabelImages
Raises
NotImplementedErrorRaised if the function is called using online APIs.