class documentation

class OfflineIndex(BNIndex):

View In Hierarchy

The offline version of the BNIndex.

Method __init__ init method
Method examples Get the examples of a specific Babel synset, given a BabelSynsetID and a collection of InternalBabelSynsetID.
Method glosses Get the glosses of a specific BabelSynset, given a BabelSynsetID and a collection of InternalBabelSynsetID.
Method images Get the images of a specific Babel synset, given a BabelSynsetID.
Method lexicon_iterator Create a new instance of a lexicon iterator.
Method licence_ids_from_resource_id Given a ResourceID, get a list of InternalBabelSynsetIDs.
Method license_ids_for_word Get the set of ids license for the word with the given constraints.
Method license_ids_from_dictionary_documents Get the set of license ids of Documents in all indices from a given query.
Method mapping_from_babelsynsetids Get a mapping from a list of BabelSynsetIDs
Method offset_iterator Create a new instance of a offset iterator.
Method search_old_offset_wordnet Search the old offset of wordnet
Method successors Given a Babel id, collects the successors of the concept denoted by the id.
Method synset_from_empty_document Return an instance of an empty BabelSynset.
Method synset_iterator Create a new instance of a synset iterator.
Method synsets Construct the list of BabelSynsets from a map of BabelSynsetIDs to list of InternalBabelSynsetID.
Method synsets_from_resource_id Get a list of BabelSynset from a given ResourceID.
Method synsets_from_wikipedia_title Given a Wikipedia title, get its BabelSynsets.
Method synsets_from_wordnet_offset Get the set of ids license of Documents in all indices from a given WordNetSynsetID.
Method version The version of BabelNet.
Method wordnet_iterator Create a new instance of a wordnet iterator.
Method wordnet_offsets Retrieve WordNet 3.0 offset from old-version WordNet offSet.
Method _dictionary_docs Get the list of Documents by mapping ID.
Method _doc_from_index_by_id Get a index-document lucene identifier (Babel synset ID).
Method _documents_from_glosses_and_examples Search in index Glosses and Examples for the given InternalBabelSynsetIDs.
Method _info_document Get an info Document from a BabelNet ID.
Method _load Undocumented
Method _mapping_document Get a mapping Document from a License or BabelNet ID.
Method _merge_definitions_document Merge glosses or examples.
Method _merge_dictionary_documents Merge all Lucene dictionary Documents, that have the same id. The ids are replaced initially with the final BabelNet id.
Method _multi_dictionary_docs Undocumented
Method _synset_from_all_documents Get a full-fledged BabelSynset from a Document.
Instance Variable _babelnet Undocumented
Instance Variable _dictionary Undocumented
Instance Variable _graph Undocumented
Instance Variable _image Undocumented
Instance Variable _info Undocumented
Instance Variable _languages Undocumented
Instance Variable _lexicon Undocumented
Instance Variable _license_to_dictionaries Dictionaries (other licenses).
Instance Variable _license_to_glosses_and_examples Glosses (other licenses).
Instance Variable _wordnet_info Undocumented
def __init__(self):

init method

def examples(self, id_, filter_langs, *ids):

Get the examples of a specific Babel synset, given a BabelSynsetID and a collection of InternalBabelSynsetID.

Parameters
id_:BabelSynsetIDthe BabelSynsetID form where to get the examples
filter_langs:Set[Language]the languages to filter
*ids:_InternalBabelSynsetIDthe _InternalBabelSynsetID(s)
Returns
List[BabelExample]the list of BabelExample(es) retrieved from the BabelSynset
Raises
RuntimeError
def glosses(self, id_, filter_langs, *ids):

Get the glosses of a specific BabelSynset, given a BabelSynsetID and a collection of InternalBabelSynsetID.

Parameters
id_:BabelSynsetIDthe BabelSynsetID form where to get the glosses
filter_langs:Set[Language]the languages to filter
*ids:_InternalBabelSynsetIDthe _InternalBabelSynsetID(s)
Returns
List[BabelGloss]the list of BabelGloss(es) retrieved from the BabelSynset
def images(self, id_):

Get the images of a specific Babel synset, given a BabelSynsetID.

Parameters
id_:BabelSynsetIDthe BabelSynsetID form where to get the images
Returns
List[BabelImage]the list of BabelImage(es) retrieved from the BabelSynset
def lexicon_iterator(self):

Create a new instance of a lexicon iterator.

Returns
BabelLexiconIteratorthe lexicon iterator
def licence_ids_from_resource_id(self, resource_id):

Given a ResourceID, get a list of InternalBabelSynsetIDs.

Parameters
resource_id:ResourceIDThe resource.
Returns
List[_InternalBabelSynsetID]The list of InternalBabelSynsetIDs associated to the given ResourceID.
def license_ids_for_word(self, word, poses, langs, normalizer):

Get the set of ids license for the word with the given constraints.

Parameters
word:strThe word whose senses are to be retrieved.
poses:Set[POS]The PoSes of the word to be retrieved.
langs:Set[Language]The search languages for the input word.
normalizer:boolTrue if normalization should be applied when searching.
Returns
List[_InternalBabelSynsetID]The list of InternalBabelSynsetIDs associated with the given constraints.
def license_ids_from_dictionary_documents(self, q):

Get the set of license ids of Documents in all indices from a given query.

Parameters
qa Lucene Query used to obtain the Lucene documents.
Returns
List[_InternalBabelSynsetID]the list of the license ids's (as _InternalBabelSynsetID) from the dictionary document
def mapping_from_babelsynsetids(self, *ids):

Get a mapping from a list of BabelSynsetIDs

Parameters
*ids:BabelSynsetIDCollection of BabelSynsetID
Returns
Dict[BabelSynsetID, List[_InternalBabelSynsetID]]For each BabelSynsetID returns the necessary indexes to create the BabelSynset
def offset_iterator(self):

Create a new instance of a offset iterator.

Returns
BabelOffsetIteratorthe babel offset iterator
def search_old_offset_wordnet(self, offset):

Search the old offset of wordnet

Parameters
offset:strUndocumented
Returns
Dict[WordNetVersion, List[str]]Undocumented
def successors(self, id_):

Given a Babel id, collects the successors of the concept denoted by the id.

Parameters
id_:BabelSynsetIDA concept identifier (babel synset ID)
Returns
Optional[List[str]]Return a stringified representation of the edges departing from the Babel synset denoted by the input id.
def synset_from_empty_document(self, id_, id_licenses):

Return an instance of an empty BabelSynset.

Parameters
id_:BabelSynsetIDthe id to search
id_licenses:List[_InternalBabelSynsetID]the list of _InternalBabelSynsetID
Returns
BabelSynseta BabelSynset
def synset_iterator(self):

Create a new instance of a synset iterator.

Returns
BabelSynsetIteratorAn iterator over BabelNet's synsets
def synsets(self, id2license_ids, target_languages):

Construct the list of BabelSynsets from a map of BabelSynsetIDs to list of InternalBabelSynsetID.

Parameters
id2license_ids:Dict[BabelSynsetID, List[_InternalBabelSynsetID]]Map of BabelSynsetIDs to list of InternalBabelSynsetID.
target_languages:Set[Language]The languages to include in the synsets.
Returns
List[BabelSynset]The list of constructed synsets.
def synsets_from_resource_id(self, id_, id2license_ids, target_langs):

Get a list of BabelSynset from a given ResourceID.

Parameters
id_:ResourceIDThe ResourceID.
id2license_ids:Dict[BabelSynsetID, List[_InternalBabelSynsetID]]a dict that maps BabelSynsetID to a list of _InternalBabelSynsetID
target_langs:Set[Language]The output language
Returns
List[BabelSynset]The list of BabelSynsets associated to the given ResourceID.
def synsets_from_wikipedia_title(self, language, title, id2license_ids):

Given a Wikipedia title, get its BabelSynsets.

Parameters
language:LanguageThe language of the input Wikipedia title.
title:strThe title of the Wikipedia page.
id2license_ids:Dict[BabelSynsetID, List[_InternalBabelSynsetID]]a dict that maps BabelSynsetID to a list of _InternalBabelSynsetID
Returns
List[BabelSynset]The list of BabelSynsets associated to the given Wikipedia title.
def synsets_from_wordnet_offset(self, offset):

Get the set of ids license of Documents in all indices from a given WordNetSynsetID.

Parameters
offset:WordNetSynsetIDA WordNet offset.
Returns
List[_InternalBabelSynsetID]A list of InternalBabelSynsetIDs associated to the given constraints.
def version(self):

The version of BabelNet.

Returns
BabelVersionthe version
def wordnet_iterator(self):

Create a new instance of a wordnet iterator.

Returns
WordNetSynsetIteratoran iterator over Wordnet's synsets
def wordnet_offsets(self, offset, version):

Retrieve WordNet 3.0 offset from old-version WordNet offSet.

Parameters
offset:strThe wordnet offset
version:WordNetVersionthe wordnet version
Returns
List[WordNetSynsetID]A list of WordNetSynsetID at the specified offset for that specified version
Raises
InvalidSynsetIDError
JavaError
def _dictionary_docs(self, id_, *ids):

Get the list of Documents by mapping ID.

Parameters
id_:BabelSynsetIDA BabelNetID.
*ids:_InternalBabelSynsetIDLicense IDs of the various synset pieces.
Returns
List[Document]a list of documents
def _doc_from_index_by_id(self, id_, dict_index):

Get a index-document lucene identifier (Babel synset ID).

Parameters
id_:BabelSynsetIDThe Babel synset ID for a specific concept.
dict_index:IndexSearcherIndexSearcher.
Returns
Optional[Document]The Document
def _documents_from_glosses_and_examples(self, *ids):

Search in index Glosses and Examples for the given InternalBabelSynsetIDs.

Parameters
*ids:_InternalBabelSynsetIDthe _InternalBabelSynsetID to use for the search
Returns
List[Document]THe list of Document(s) associated to the given ids
Raises
JavaError
def _info_document(self, id_):

Get an info Document from a BabelNet ID.

This function interrogates the index and returns the Document where the id_ is found.

Parameters
id_:strthe id
Returns
Documentthe Document
Raises
JavaErrorError raised from Java
def _load(self):

Undocumented

def _mapping_document(self, id_, field):

Get a mapping Document from a License or BabelNet ID.

Parameters
id_:strThe input id.
field:BabelNetIndexFieldThe kind of id.
Returns
Optional[Document]the document.
def _merge_definitions_document(self, id_, doc, docs, type_definition):

Merge glosses or examples.

Parameters
id_:BabelSynsetIDUndocumented
doc:DocumentUndocumented
docs:List[Document]Undocumented
type_definition:BabelNetIndexFieldUndocumented
Returns
DocumentUndocumented
Raises
JavaError
def _merge_dictionary_documents(self, docs_coll):

Merge all Lucene dictionary Documents, that have the same id. The ids are replaced initially with the final BabelNet id.

Parameters
docs_coll:Set[Document]Undocumented
Returns
DocumentUndocumented
def _multi_dictionary_docs(self, id2id_licenses):

Undocumented

Parameters
id2id_licenses:Dict[BabelSynsetID, List[_InternalBabelSynsetID]]Undocumented
Returns
Dict[BabelSynsetID, Set[Document]]Undocumented
def _synset_from_all_documents(self, doc, license_ids, target_langs):

Get a full-fledged BabelSynset from a Document.

Parameters
doc:DocumentA Lucene Document record for a certain Babel synset.
license_ids:List[_InternalBabelSynsetID]A list of licence IDs.
target_langs:Set[Language]The languages to use for search.
Returns
Optional[BabelSynset]An instance of a BabelSynset from a Document.
_babelnet =

Undocumented

_dictionary =

Undocumented

_graph =

Undocumented

_image =

Undocumented

_info =

Undocumented

_languages =

Undocumented

_lexicon =

Undocumented

_license_to_dictionaries: dict =

Dictionaries (other licenses).

_license_to_glosses_and_examples: dict =

Glosses (other licenses).

_wordnet_info =

Undocumented