{
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());
}
}
}