Package gannuWSD.testing

Examples of gannuWSD.testing.Decision


      if(idx>=0)
      {
        idx=line.indexOf("wnsn=\"");
        text+=line.substring(0,idx);
        text+="wnsn=\"";
        Decision d=ds.get(index);
        if(d.isAttempted())
        {
          int wnsns[]=d.getAnswers();
          if(wnsns.length>0)
          {
            text+=String.valueOf(wnsns[0]+1);
            for(int i=1;i<wnsns.length;i++)
            {
View Full Code Here


            }
          }
          d.calculateAnswer();
        }
        ArrayList<AmbiguousWord> window=new ArrayList<AmbiguousWord>();
        Decision dx=d;
        if(d.isAttempted())
        {
          if(d.isTied()&&tie!=null)
          {
            boolean bnx=true;
View Full Code Here

        w.remove(target);
        ds.add(this.disambiguate(target, this.getWindow(target, w)));
      }
      else
      {
        Decision d=new Decision(target,window);
        d.calculateAnswer();
        ds.add(d);
      }
    }
    return ds;
  }
View Full Code Here

        siz++;
    }
    ArrayList<Report> answers=optimizer.solve(this.getValue("config"), f, (double)(siz*fes),(double)(siz*fes) ,-1e+20);
    Report answer=answers.get(answers.size()-1);
    double X[]=answer.getBestIndividual()
    Decision d=new Decision(target, window);
    int xindex=(int)Math.floor(X[0]);
    int x=0;
    for(Sense s:target.getSenses())
    {
      ArrayList<String> dwords=new ArrayList<String>();
      for(AmbiguousWord w:window)
      {
        if(this.overlap(s, w, dwords))
        {
          dwords.add(w.getLemma());
        }
      }
      double w=0.0;
      if(x==xindex)
      {
        if(dwords.size()>0)
          w=-X[X.length-1];       
      }
      else
      {
        w=((double)dwords.size())*0.001;
      }
      dwords.trimToSize();
      d.setSense(x, w, dwords);
      x++;
    }
    d.calculateAnswer();     
    return d;
  }
View Full Code Here

      System.out.print(".");
      ArrayList<AmbiguousWord> window=new ArrayList<AmbiguousWord>();
      AmbiguousWord target=sentence.get(word);
      window.addAll(sentence);
      window.remove(target);
      Decision d=new Decision(target, window);
      boolean ban=true;
      for(SkipFilter filter:this.skipFilters)
        ban=ban&&filter.shouldITry(target);
      if(ban)
      {
        int xindex=(int)Math.floor(X[word]);
        int x=0;
        for(Sense s:target.getSenses())
        {
          ArrayList<String> dwords=new ArrayList<String>();
          for(AmbiguousWord w:window)
          {
            this.overlap(s, w, dwords);
          }
          double w=0.0;
          if(x==xindex)
          {
            if(dwords.size()>0)
              w=-X[X.length-1];       
          }
          else
          {
            w=((double)dwords.size())*0.001;
          }
          dwords.trimToSize();
          d.setSense(x, w, dwords);
          x++;
        }
      }
      d.calculateAnswer();     
      ds.add(d);
    }   
    return ds;

  }
View Full Code Here

 
  @Override
  public Decision disambiguate(AmbiguousWord target,
      ArrayList<AmbiguousWord> window) throws Exception {
    System.out.print(".");
    Decision decision=new Decision(target,window);
    // TODO Auto-generated method stub
    if(target.getSenses().size()>1)
    {
      Classifier c;
      if(this.getValue("classifier")==null)
        this.addParameters("classifier:gannuCF.classifiers.NaiveBayes;");
      File f=new File("./data/classifiers/"+this.dict.getCompleteName()+"/"+Dictionary.normalizeLemmaforFile(target.getLemma())+"_"+this.getValue("classifier")+".gcl");
      if(f.exists())
      {
        c=(Classifier)Util.loadObject(f);
      }
      else
      {
       
        c=(Classifier)Class.forName(this.getValue("classifier")).newInstance();
        c.addParameters(this.getParameterString());
        c.train(target);
        File dir=new File("./data/classifiers/"+this.dict.getCompleteName()+"/");
        if(!dir.exists())
          dir.mkdirs();
        Util.writeObject(f, c);
      }
      ArrayList<String> sample=new ArrayList<String>(window.size());     
      for(AmbiguousWord word:window)
      {
        sample.add(word.getLemma());       
      }
      float w[]=c.classify(sample);
      for(int j=0;j<target.getSenses().size();j++)
      {
        ArrayList<String> dwords=new ArrayList<String>(window.size());
        for(AmbiguousWord word:window)
        {
          if(this.overlap(target.getSenses().get(j), word.getLemma()))
            if(!dwords.contains(word.getLemma()))
              dwords.add(word.getLemma());
        }
        dwords.trimToSize();
        decision.setSense(j, w[j], dwords);
      }

    }
    else
    {
      decision.setSense(0, 1.0, new ArrayList<String>());
    }
    decision.calculateAnswer();
    return decision;
  }
View Full Code Here

   @Override
    public Decision disambiguate(AmbiguousWord target, ArrayList<AmbiguousWord> window) throws Exception
    {
        ArrayList<Sense> senses=target.getSenses();
        System.out.print(".");
      Decision decision=new Decision(target,window);
      int i;
      ArrayList<Sense> relevantSynsets=new ArrayList<Sense>();
      for(AmbiguousWord word:window)
      {
        relevantSynsets.addAll(word.getSenses());
      }
      for(i=0;i<senses.size()&&(target.getPos().equals("N")||this.allPos);i++)
      {
        Graph g=this.graphs.loadGraph(senses.get(i), this.dict)
        g.prune(relations, depth);
        double w=0.0d;
        double m=0.0d;
        ArrayList<String> dwords=new ArrayList<String>();
        for(Sense s:relevantSynsets)
        {
          GraphNode gn=g.get(s, depth, relations);
          if(gn!=null)
          {
            dwords.add(s.getSynonyms().get(0));
            m+=1.0d;
          }              
        }
        w=Math.pow(m, 0.1)*Math.pow(m/((double)g.getNodes().size()),Math.log(((double)i)+1.0d));
        decision.setSense(i, w, dwords);
      }
      decision.calculateAnswer();
      return decision;
    }
View Full Code Here

   @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;
  }
View Full Code Here

  @Override
  public Decision disambiguate(AmbiguousWord target,
      ArrayList<AmbiguousWord> window) throws Exception {
    System.out.print(".");
    Decision d=new Decision(target,window);
    //System.out.print(target.getIndex());
    ArrayList<String> rels=new ArrayList<String>(1);
    rels.add("all");
    for(int i=0;i<target.getSenses().size();i++)
    {
      Sense sense=target.getSenses().get(i);
      ArrayList<String>dwords=new ArrayList<String>();
      Graph g=this.graphs.loadGraph(sense, dict);
      double w=0.0;
      for(AmbiguousWord word:window)
      {
        for(Sense s:word.getSenses())
        {
          GraphNode gn=g.get(s, deep, "all");
          if(gn!=null)
          {       
            dwords.add(word.getLemma());
            break;
          }
        }
      }
        w=g.getRootDegree(window,deep,rels);
      d.setSense(i, w, dwords);
    }
   
    d.calculateAnswer();
    return d;
  }
View Full Code Here

  @Override
  public Decision disambiguate(AmbiguousWord target, ArrayList<AmbiguousWord> window) throws Exception
  {
    System.out.print(".");
    ArrayList<Sense> senses=target.getSenses();
    Decision decision=new Decision(target,window);
    int i;
    for(i=0;i<senses.size();i++)
    {
      double w=0;
      ArrayList<String> dwords=new ArrayList<String>();
      for(AmbiguousWord winword:window)
      {
        if(winword.getSenses().size()>0)
        {
          for(Sense s:winword.getSenses())
          {
            w+=this.scoring.calculateOverlap(senses.get(i).getBagOfWords(),s.getBagOfWords(), dwords);
          }

        }
        else
        {
          if(senses.get(i).getBagOfWords().contains(winword.getLemma()))
          {
            w+=1.0;
            dwords.add(winword.getLemma());
          }
        }
         
      }
      dwords.trimToSize();
      decision.setSense(i, w, dwords);
    }
    decision.calculateAnswer();
    return decision;
  }
View Full Code Here

TOP

Related Classes of gannuWSD.testing.Decision

Copyright © 2018 www.massapicom. 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.