class documentation

class BabelSynsetComparator(_InternalBabelSynsetComparator):

View In Hierarchy

Comparator for BabelSynsets that:

  • puts WordNet synsets first
  • sorts WordNet synsets based on the sense number of a specific input word
  • sorting Wikipedia synsets lexicographically based on their main sense
Method __init__ init method
Method compare Compare two BabelSynset(s)
Method __synset_score Calculate the score of a BabelSynset

Inherited from _InternalBabelSynsetComparator:

Class Method _valid_degree Get a valid degree from the given BabelSynset
Static Method _compare_by_edge_then_main_sense Compare two BabelSynset based on the edges and then on the man sense.
Instance Variable _language the language to use for the comparation
Instance Variable _word the word to use for the comparation
def __init__(self, word=None, language=Language.EN):

init method

Parameters
word:Optional[str]the word to set for this instance of the comparator. It will be used to compare synsets based on the correlation with this word (default None).
language:Languagethe language to use for the comparation (default Langauge.EN).
def compare(self, b1, b2):

Compare two BabelSynset(s)

Parameters
b1:BabelSynsetFirst BabelSynset.
b2:BabelSynsetSecond BabelSynset.
Returns
intCompare result.
def __synset_score(self, synset):

Calculate the score of a BabelSynset

Parameters
synset:BabelSynsetthe synset
Returns
intthe score