resnik method

double resnik(
  1. Synset synset1,
  2. Synset synset2, {
  3. bool normalize = false,
  4. double normalized_max = 1.0,
})

Two concepts are more related the more information they share. The shared information of two concepts can be quantified by the information content of two concepts' lowest common subsumer. When several LCS are available the highest IC is returned.

Implementation

double resnik(Synset synset1, Synset synset2, {bool normalize = false, double normalized_max = 1.0}) {
  double resnik = 0;
  if(synset1 == synset2){
    resnik = _get_information_content(synset1);
  }else{
    var lcs_list = synset1.lowest_common_subsumer(synset2);
    for (var lcs in lcs_list) {
      double ic = _get_information_content(lcs);
      if(ic > resnik){
        resnik = ic;
      }
    }
  }
  if(normalize){
    this.normalize(resnik, normalized_max, SemRelMeasure.Resnik);
  }
  return resnik;
}