/* check if source and target are of type NOUN or VERB */
if(source.getType() == SynsetType.NOUN)
{
/* get all the immediate parents of u */
NounSynset nounsyn = (NounSynset)(u.synset);
hypernyms = nounsyn.getHypernyms();
}
else if(source.getType() == SynsetType.VERB)
{
VerbSynset nounsyn = (VerbSynset)(u.synset);
hypernyms = nounsyn.getHypernyms();
}
/* for each parent of u */
for(Synset v : hypernyms)
{
/* check if hashtable already contains a node for v */
// if yes
if(created.containsKey(v.hashCode()))
{
/* get the node */
Node v_node = created.get(v.hashCode());
/* check if already marked */
if(v_node.s_marked)
continue;
else
{
/* LCS is the node for v */
v_node.s_previous = u;
v_node.s_marked = true;
LCS = v_node;
return LCS;
}
}
// if no
if(!created.containsKey(v.hashCode()))
{
/* create a node for v */
Node v_node = new Node();
v_node.synset = v;
v_node.s_previous = u;
v_node.s_marked = true;
/* add v_node to hashtable */
created.put(v_node.synset.hashCode(), v_node);
/* add node to toBeExpanded */
s_toBeExpanded.add(v_node);
}
}
}
/*
* BFS from target
*/
if(!t_toBeExpanded.isEmpty())
{
Synset [] hypernyms = null;
/* remove the first element from the toBeExpanded queue */
Node u = t_toBeExpanded.remove(0);
/* check if source and target are NOUN or VERB */
if(target.getType() == SynsetType.NOUN)
{
/* get all the immediate parents of u */
NounSynset nounsyn = (NounSynset)(u.synset);
hypernyms = nounsyn.getHypernyms();
}
else if(target.getType() == SynsetType.VERB)
{
VerbSynset nounsyn = (VerbSynset)(u.synset);
hypernyms = nounsyn.getHypernyms();
}
/* for each parent of u */
for(Synset v : hypernyms)