package gannuWSD.algorithms;
import gannuNLP.corpus.Corpus;
import gannuNLP.corpus.KeywordSimilarityFilter;
import gannuNLP.data.AmbiguousWord;
import gannuNLP.data.Input;
import gannuNLP.data.Sense;
import gannuWSD.testing.Decision;
import java.util.ArrayList;
/**
* Under construction please do not use.
* @author Francisco Viveros-Jiménez
*
*/
public class CorpusMFS extends WSDAlgorithm {
/**
* Original base corpus.
*/
static Corpus corpus;
/**
* Filtered corpus.
*/
Corpus current;
boolean osd;
@Override
public Decision disambiguate(AmbiguousWord target, ArrayList<AmbiguousWord> window) throws Exception
{
ArrayList<Sense> senses=target.getSenses();
Decision decision=new Decision(target,window);
int i;
if (!osd || this.current.isOneSensePerDiscourse(target.getLemma()))
{
int index=this.current.getMFS(target.getLemma());
for(i=0;i<senses.size();i++)
{
ArrayList<String> dwords=new ArrayList<String>();
if (index==i&&index>=0)
decision.setSense(i, 1.0, dwords);
else
decision.setSense(i, 0.0, dwords);
}
}
decision.calculateAnswer();
return decision;
}
public CorpusMFS()
{
super();
this.name="CorpusMFS";
}
@Override
public void init(Input document) throws Exception {
if (CorpusMFS.corpus==null)
CorpusMFS.corpus=new Corpus(this.getValue("corpus"),this.dict,Boolean.parseBoolean(this.getValue("includeNoTags")));
if(this.getValue("osd")==null)
{
this.osd=true;
}
else
{
this.osd=Boolean.parseBoolean(this.getValue("osd"));
}
this.current=new Corpus(CorpusMFS.corpus);
if(this.getValue("setup")!=null&&this.getValue("setup").equals("filterMFS"))
{
this.current=new Corpus(CorpusMFS.corpus);
String parameters="";
if(this.getValue("threshold")==null)
{
parameters+="threshold:0.2;";
}
else
{
parameters+="threshold:"+this.getValue("threshold")+";";
}
if(this.getValue("keywords")==null)
{
parameters+="keywords:10;";
}
else
{
parameters+="keywords:"+this.getValue("keywords")+";";
}
if(this.getValue("measure")==null)
{
parameters+="measure:gannu.corpus.CosineSimilarity;";
}
else
{
parameters+="measure:"+this.getValue("measure")+";";
}
if(this.getValue("keywordExtraction")==null)
{
parameters+="keywordExtraction:gannu.corpus.KeywordsByTFIDF;";
}
else
{
parameters+="keywordExtraction:"+this.getValue("keywordExtraction")+";";
}
(new KeywordSimilarityFilter(parameters)).filter(this.current, document);
}
}
@Override
public boolean IsUseful(AmbiguousWord target, AmbiguousWord windowWord)
throws Exception {
// TODO Auto-generated method stub
return true;
}
}