Package gannuWSD.algorithms

Source Code of gannuWSD.algorithms.NthSense

package gannuWSD.algorithms;

import gannuNLP.data.AmbiguousWord;
import gannuNLP.data.Input;
import gannuNLP.data.Sense;
import gannuWSD.testing.Decision;

import java.util.ArrayList;


/**
* A simple heuristic that always selects the Nth sense.
* Please set the "n:value;" parameter for specifying the Nth sense.
* @author Francisco Viveros-Jiménez
*
*/
public class NthSense extends WSDAlgorithm {
  /**
   * Sense number going to be selected as an answer.
   */
    int n;
  public NthSense()
  {
    super();
    this.name="NthSense";
  }
   @Override
  public Decision disambiguate(AmbiguousWord target, ArrayList<AmbiguousWord> window) throws Exception
  {
     this.n=Integer.parseInt(this.getValue("n"))-1;
    ArrayList<Sense> senses=target.getSenses();
    Decision decision=new Decision(target,window);
    int i;
    for(i=0;i<senses.size();i++)
    {
      ArrayList<String> dwords=new ArrayList<String>();
      if(i!=n)
        decision.setSense(i, 0.0, dwords);
      else
        decision.setSense(i, 1.0, dwords);
     
    }
    decision.calculateAnswer();
    return decision;
  }
@Override
public void init(Input document) {
  // TODO Auto-generated method stub
 
}
@Override
public boolean IsUseful(AmbiguousWord target, AmbiguousWord windowWord)
    throws Exception {
  // TODO Auto-generated method stub
  return true;
}


}
TOP

Related Classes of gannuWSD.algorithms.NthSense

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.