Package gannuNLP.data

Examples of gannuNLP.data.Lemma


  public Sense getSense(String sid)throws Exception
  {
    if(!this.isWeb)
    {
      String lemma=sid.split("@")[0];
      Lemma l=this.getLemmaNoModifiers(lemma);
      if(sid.split("@").length>1)
      {
        int senseNumber=Integer.parseInt(sid.split("@")[1]);
        return l.getSenses().get(senseNumber);
      }
      else
        return null;
    }
    else
View Full Code Here


    }

  @Override
  public Lemma getLemma(String lemma) throws Exception {
        ArrayList<Sense> s=this.getSenses(lemma);
        Lemma l=null;
        if(s.size()>0)
           l=new Lemma(lemma,s.get(0).getPos(),s,this.getCounts(lemma),this.name);
    return l;
  }
View Full Code Here

   * @throws Exception
   */
  public static void readLemma(DataBroker dic,String lemma,Element word,String pos)throws Exception
  {
    String lem=lemma+"_"+pos;
    Lemma l=null;
    ArrayList<Sense> senses=dic.getSenses(lem);
    BufferedReader kb = new BufferedReader(new InputStreamReader(System.in));
    if(senses.size()==0)//
    {
      if(!SemCorCleaner.fix)
      {
        System.out.println("Lemma not found: "+lem);
        System.out.println("Please enter a lemma or no for ignoring this word!");
        String plemma=kb.readLine();
        if(plemma.equals("no"))
        {
          word.setAttribute("cmd","ignore");
        }
        else
        {
          l=dic.getLemma(plemma);
          while(l==null)
          {
            System.out.println("Please write the valid form (lemma_P where lemma is in normal form and P is the first letter of the pos tag)");
            plemma=kb.readLine();
            l=dic.getLemma(plemma);
          }       
          word.setAttribute("lemma",l.getLemma().substring(0,l.getLemma().length()-2));
          word.setAttribute("pos",l.getPos());
          word.setAttribute("wnsn","-1");
        }
      }
      else
      {
        System.out.println("Marking "+word.getValue()+" for future tagging ");
        word.setAttribute("cmd","tag");
      }
    }
    else
    {
      System.out.println("\n<"+word.getValue()+"> may not be in normal form");
      ArrayList<String> morphs=dic.Morphy(lemma, pos);
      do
      {     
        String plemma;
        if(morphs.size()==1)
        {
          plemma=morphs.get(0)+"_"+pos;
          System.out.println(lemma+" was autocorrected to "+ plemma);
        }
        else
        {
          if(!SemCorCleaner.fix)
          {
            System.out.println("Please select the valid form (lemma_P where lemma is in normal form and P is the first letter of the pos tag).\nSome suggestions are "+morphs+" just remember to add the _"+pos+" pos tagat the end of the lemma");
            plemma=kb.readLine();
          }
          else
          {
            System.out.println("Marking "+word.getValue()+" for future tagging ");
            word.setAttribute("cmd","tag");
            break;
          }
        }
        l=dic.getLemma(plemma);
      }
      while(l==null&&!SemCorCleaner.fix);
      if(l!=null)
      {
        word.setAttribute("lemma",l.getLemma().substring(0,l.getLemma().length()-2));
        word.setAttribute("pos",l.getPos());
        word.setAttribute("wnsn","-1");
      }
    }
  }
View Full Code Here

            if((word.getAttribute("cmd").getValue().equals("done"))||(tag&&(word.getAttribute("cmd").getValue().equals("tag"))))
            {
              String lemma=word.getValue();
              String pos=word.getAttribute("pos").getValue().substring(0,1);
              String lem;
              Lemma l=null;
              if(word.getAttribute("cmd").getValue().equals("done"))
                { 
                if(word.getAttribute("lemma")!=null)
                {
                  lemma=word.getAttribute("lemma").getValue();
                    pos=word.getAttribute("pos").getValue().substring(0,1);
                    lem=lemma+"_"+pos;
                    l=dic.getLemma(lem);                 
                }
                else
                {
                  lemma="";
                  pos="X";
                }
                }
              lem=lemma+"_"+pos;
 
             
              if(l==null)//lemma may not be in normal form
              {
               
                SemCorCleaner.displayWindow(words, w);
                SemCorCleaner.readLemma(dic, lemma, word, pos);
                l=dic.getLemma(word.getAttributeValue("lemma")+"_"+word.getAttributeValue("pos").substring(0,1));
              }
              if(l!=null)
              {
                if(!SemCorCleaner.isValidWNSN(word.getAttributeValue("wnsn"), l.getSenses().size()))
                {
                  SemCorCleaner.displayWindow(words, w);
                  SemCorCleaner.checkSenses(word, l);
                }
              }
View Full Code Here

          w.setDict(data);
          data.addModifier(w);
        }
      }
      data.load("all");
      Lemma l=data.getLemma(args[2]);
      if(l!=null)
      {
        System.out.println("Have "+l.getSenses().size()+" senses");
        System.out.println("Frequency: "+String.valueOf(l.getFrequency()));
        System.out.println("IDF: "+data.getIDF(l));
        for(Sense s:l.getSenses())
        {
          System.out.println(s.getSid());
          System.out.println(s.getSynonyms());       
          for(int i=0;i<s.getSamples().size();i++)
          {
View Full Code Here

TOP

Related Classes of gannuNLP.data.Lemma

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.