Package gannuWSD

Source Code of gannuWSD.GetLemma

package gannuWSD;

import java.util.ArrayList;

import gannuNLP.data.Lemma;
import gannuNLP.data.Sense;
import gannuNLP.dictionaries.DataBroker;
import gannuWSD.bowmodifiers.WikiCleaner;

public class GetLemma {

  /**
   * Simple command for retrieving a Lemma from a dictionary with all the available examples.
   * Usage: java -cp "gannu.jar" gannuWSD.GetLemma dictionaryClass version lemma [URL of web dictionary]
   * @param args
   */
  public static void main(String[] args) throws Exception{
   
    if(args.length<3)
    {
      System.out.println("java -cp \"gannu.jar\" gannuWSD.GetLemma dictionaryClass version lemma [URL of web dictionary]");
    }
    else
    {
      DataBroker data=new DataBroker(args[0],args[1]);     
      if(data.isWeb())
      {
        data.setBaseURL(args[3]);
        if(args[0].contains("Wiki"))
        {
          WikiCleaner w=new WikiCleaner();
          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++)
          {
            System.out.println("From "+s.getSources().get(i)+": "+s.getSamples().get(i).trim());           
          }
          System.out.println("=================================");
          System.out.println("Press any key to continue!");
          System.in.read();
        }
      }
      else
      {
        ArrayList<Sense> senses=data.getSenses(args[2]);
        if(senses.size()>0)
        {
          System.out.println("Have "+senses.size()+" senses");
          for(Sense s:senses)
          {
            System.out.println(s.getSid());
            System.out.println(s.getSynonyms());       
            for(int i=0;i<s.getSamples().size();i++)
            {
              System.out.println("From "+s.getSources().get(i)+": "+s.getSamples().get(i).trim());
            }
            System.out.println("=================================");
            System.out.println("Press any key to continue!");
            System.in.read();           
          }

        }
        else
        {
          System.out.println("Word not found in dictionary!");
        }
      }
    }

  }

}
TOP

Related Classes of gannuWSD.GetLemma

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.