boolean stemWords = params.contains("-stemWords");
boolean stripDigits = params.contains("-stripDigits");
boolean createAncestry = params.contains("-createAncestry");
// start index finder terminology
IndexFinderTerminology terminology = new IndexFinderTerminology();
terminology.addPropertyChangeListener(this);
terminology.setStemWords(stemWords);
terminology.setIgnoreDigits(stripDigits);
// setup persistance directory
String name = null;
if(output != null){
File f = new File(output);
if(f.getParentFile().exists()){
if(f.isDirectory()){
IndexFinderTerminology.setPersistenceDirectory(f);
}else{
IndexFinderTerminology.setPersistenceDirectory(f.getParentFile());
name = f.getName();
}
}
}
// load approprate ontology
if(rrf != null){
File f = new File(rrf);
List<String> lang = (lng != null)?readList(lng):null;
List<String> src = (sr != null)?readList(sr):null;
List<String> hsrc = (hsr != null)?readList(hsr):null;
List<String> sem = (se != null)?readList(se):null;
// load ontology
log("Loading RRF terminology from "+f.getAbsolutePath()+"...");
log("Languages: "+lang);
log("Sources: "+src);
log("Hierarchy Sources: "+hsrc);
log("SemanticTypes: "+sem);
Map<String,List<String>> pmap = new HashMap<String,List<String>>();
pmap.put("name",Arrays.asList(name));
pmap.put("languages",lang);
pmap.put("sources",src);
pmap.put("semanticTypes",sem);
pmap.put("hierarchySources",hsrc);
terminology.loadRRF(f,pmap);
name = (name == null)?f.getName():name;
}else if(owl != null){
log("Loading OWL terminology from "+owl+"...");
IOntology ont = POntology.loadOntology(owl);
if(ont != null){
terminology.loadOntology(ont,name);
}
name = (name == null)?ont.getName():name;
}else if(obo != null){
log("Loading OBO terminology from "+obo+"...");
if(name == null){
name = (new File(obo)).getName();
if(name.endsWith(".obo"))
name = name.substring(0,name.length()-4);
}
terminology.load(name);
ConceptImporter.getInstance().addPropertyChangeListener(this);
ConceptImporter.getInstance().loadOBO(terminology,new File(obo));
ConceptImporter.getInstance().removePropertyChangeListener(this);
terminology.save();
}else if(bioportal != null){
log("Loading BioPortal terminology from "+bioportal+"...");
BioPortalRepository r = new BioPortalRepository();
IOntology ont = r.getOntology(URI.create(bioportal));
if(ont != null){
ont.addPropertyChangeListener(this);
terminology.loadOntology(ont,name);
}
name = (name == null)?ont.getName():name;
}else if(txt != null){
log("Loading Text terminology from "+txt+"...");
File f = new File(txt);
terminology.loadText(f,name);
name = (name == null)?f.getName():name;
}
//print info
log("Testing Terminology "+name+" ...");