Package gannuNLP.dictionaries

Examples of gannuNLP.dictionaries.Dictionary


    {
      System.out.println("Usage: java -cp \"gannu.jar\" gannuWSD.DataLoader connectorClass dictionaryVersion dictFilesPath for parsing a corpora/dictionary first.");
    }
    else
    {
      Dictionary dict=(Dictionary)Class.forName(args[0]).newInstance();
      dict.setVersion(args[1]);
      File f;
      File sourceList=new File("./data/"+dict.getName()+".sl");
      f=new File("./data/"+dict.getName()+"/");
      f.mkdirs();
      f=new File("./data/"+dict.getName()+"/"+dict.getName()+".sta");
      if(f.exists())//then try to upload a corpus
      {
        DataBroker db=new DataBroker(args[0],args[1]);
        db.load("Glosses;");       
        System.out.println("Dictionary uploaded!");
        System.out.println("Loading samples from SemCor files!");
        f=new File(args[2]);
        if(f.exists())
        {
          Corpus c=new Corpus(args[2],db, true);
          DataLoader.addSourceList(sourceList,c.getName());
          c.WriteSuperLemmas("./data/"+dict.getName()+"/");         
          System.out.println("Finished!");
        }
        else
        {
          System.out.println("Corpus not found!");
        }
      }
      else//then try to upload a dictionary
      {   
       
        if(!dict.isWeb())
        {         
          dict.setPath("./Resources/"+dict.getName());
          ArrayList<File> files=Util.getAllFiles(new File(args[2]));
          File dir=new File("Resources/"+dict.getName());
          dir.mkdirs();
          for(File file:files)
          {
            FileChannel source=new FileInputStream(file).getChannel();
            File tfile=new File("Resources/"+dict.getName()+"/"+file.getName());
            tfile.createNewFile();
            FileChannel target=new FileOutputStream(tfile).getChannel();
            if (target != null && source != null) {
              target.transferFrom(source, 0, source.size());
            }
            if (source != null) {
              source.close();
            }
            if (target != null) {
              target.close();
            }

          }
          System.out.println("Uploading dictionary! Wait some minutes please!");
           dict.loadCoreData();
          dict.parseSamplesFromDictionary();                 
          dict.load("Glosses;Samples");
          dict.WriteSuperLemmas("./data/"+dict.getName()+"/");
          System.out.println("Dictionary uploaded!");

        }
        else
        {
          System.out.println("Online dictionaries cannot be uploaded with this tool!");
        }
        DataLoader.addSourceList(sourceList,dict.getName());       
      }
    }
  }
View Full Code Here


            target.add(aux);
          }
        }
      }
    }
    Dictionary dict=tests.get(0).getDictionary();
    for(Test test:tests)
    {
      for(Summary s:test.getSummaries())
      {
        for(Decision d:s.getDecisions())
        {
          for(int sense=0;sense<d.getSenseCount();sense++)
          {
            for(String word:d.getDecisionWords(sense))
            {
              KeyString aux=new KeyString(word);
              if(!target.contains(aux))
              {
                target.add(new KeyString(word,String.valueOf(dict.getIDF(word))));
              }
            }
          }
        }
      }
View Full Code Here

TOP

Related Classes of gannuNLP.dictionaries.Dictionary

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.