Package gannuWSD.algorithms

Source Code of gannuWSD.algorithms.RandomSense

package gannuWSD.algorithms;

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

import java.util.ArrayList;
import java.util.Random;


/**
* A simple Random Sense heuristic. It randomly selects the answers.
* @author Francisco Viveros-Jiménez
*
*/
public class RandomSense extends WSDAlgorithm {

  public RandomSense()
  {
    super();
    this.name="RandomSense";
  }
   @Override
  public Decision disambiguate(AmbiguousWord target, ArrayList<AmbiguousWord> window) throws Exception
  {
    ArrayList<Sense> senses=target.getSenses();
    Decision decision=new Decision(target,window);
    int i;
    Random r=new Random();
   
   
    for(i=0;i<senses.size();i++)
    {
      ArrayList<String> dwords=new ArrayList<String>();
      decision.setSense(i, r.nextDouble(), 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 {
  return true;
}


 

}
TOP

Related Classes of gannuWSD.algorithms.RandomSense

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.