package gannuWSD.bowmodifiers;
import java.util.ArrayList;
import gannuNLP.data.Lemma;
import gannuNLP.data.Relation;
import gannuNLP.data.Sense;
/**
*
* Filter for extending the bag of words of all the target lemma' senses with the
* bag of words of the related senses of each sense.
* @author Francisco Viveros-Jiménez
*
*/
public class AddRelatedConcepts extends BoWModifier {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* Instantiate this filter.
*/
public AddRelatedConcepts() {
super("AddRelatedConcepts");
}
@Override
/**
* This filter does not have to initiate anything.
*/
public void init() {
}
@Override
/**
* Method for extending all the sense' bag of words of a target lemma. Each sense is extended
* with the corresponding bag of words of its related senses.
* @param lemma Target lemma
*/
public void modifyBow(Lemma lemma)throws Exception{
System.out.println("\n\n"+lemma.getLemma());
for(Sense s:lemma.getSenses())
{
System.out.println("\n"+s.getSid());
for(ArrayList<Relation> rels:s.getRelations().values())
{
for(Relation rel:rels)
{
Sense relsense=this.dict.getSense(rel.getSid());
if(relsense!=null)
{
System.out.print("!");
for(int i=0;i<relsense.getSamples().size();i++)
{
s.addBagOfWords(relsense.getSamples().get(i), relsense.getParsedSamples().get(i),relsense.getSources().get(i));
s.getBagOfWords().addAll(relsense.getSynonyms());
}
}
else
{
System.out.println(rel.getSid());
}
}
}
}
}
}