lowest_common_subsumer method
returning the first point where the hypernym path of both synsets match
Implementation
Set lowest_common_subsumer(Synset other){
Set lcs = {};
if(other == this){
lcs.add(this);
return lcs;
}
if(direct_hypernyms().contains(other) || other.is_root()){
lcs.add(other);
return lcs;
}
if(direct_hypernyms().contains(this) || is_root()){
lcs.add(this);
return lcs;
}
Set common_hypernyms = this._common_hypernyms(other);
Map dist_dict1 = get_distances_hypernym_dic();
Map dist_dict2 = other.get_distances_hypernym_dic();
int dist = 0x7fffffffffffffff;
for (var hypernym in common_hypernyms) {
var dist1 = dist_dict1[hypernym];
var dist2 = dist_dict2[hypernym];
if(dist1 + dist2 < dist){
lcs.clear();
lcs.add(hypernym);
dist = dist1 + dist2;
}
if(dist1 + dist2 == dist){
lcs.add(hypernym);
}
}
return lcs;
}