@Override public OWLOntologyIRIMapper getOntologyIRIMapper() { return new AutoIRIMapper(baseDirectory, true); }
/** * update the map. */ public void update() { mapFiles(); }
private void mapFiles() { mapped = true; ontologyIRI2PhysicalURIMap.clear(); processFile(getDirectory()); }
private void processFile(File f) { if (f.isHidden()) { return; } // if pointed directly at a zip file, map it parseIfExtensionSupported(f); File[] files = f.listFiles(); if (files == null) { return; } for (File file : files) { if (file.isDirectory() && recursive) { processFile(file); } else { parseIfExtensionSupported(file); } } }
protected void parseIfExtensionSupported(File file) { String name = file.getName(); int lastIndexOf = name.lastIndexOf('.'); if (lastIndexOf < 0) { // no extension for the file, nothing to do return; } String extension = name.substring(lastIndexOf); if (".zip".equalsIgnoreCase(extension) || ".jar".equalsIgnoreCase(extension)) { try { ZipIRIMapper mapper = new ZipIRIMapper(file, "jar:" + file.toURI() + "!/"); mapper.oboMappings().forEach(e -> oboFileMap.put(e.getKey(), e.getValue())); mapper.iriMappings() .forEach(e -> ontologyIRI2PhysicalURIMap.put(e.getKey(), e.getValue())); } catch (IOException e) { // if we can't parse a file, then we can't map it LOGGER.debug("Exception reading file", e); } } else if (".obo".equalsIgnoreCase(extension)) { oboFileMap.put(name, IRI.create(file)); } else if (".ofn".equalsIgnoreCase(extension)) { parseFSSFile(file); } else if (".omn".equalsIgnoreCase(extension)) { parseManchesterSyntaxFile(file); } else if (fileExtensions.contains(extension.toLowerCase())) { parseFile(file); } }
private void processFile(File f) { if (f.isHidden()) { return; } for (File file : f.listFiles()) { if (file.isDirectory() && recursive) { processFile(file); } else { boolean parsedFile = false; if (file.getName().endsWith(".obo")) { oboFileMap.put(file.getName(), IRI.create(file)); } else if(file.getName().endsWith(".omn")) { parseManchesterSyntaxFile(file); } else { for (String ext : fileExtensions) { if (file.getName().endsWith(ext)) { parseFile(file); parsedFile = true; } } } } } }
@Nullable private IRI parseManLine(File file, String line) { Matcher matcher = manPattern.matcher(line); if (matcher.matches()) { IRI iri = IRI.create(matcher.group(1)); addMapping(iri, file); return iri; } return null; }
private void mapFiles() { mapped = true; ontologyIRI2PhysicalURIMap.clear(); processFile(directory); }
protected void parseIfExtensionSupported(File file) { String name = file.getName(); int lastIndexOf = name.lastIndexOf('.'); if (lastIndexOf < 0) { // no extension for the file, nothing to do return; } String extension = name.substring(lastIndexOf); if (".zip".equalsIgnoreCase(extension) || ".jar".equalsIgnoreCase(extension)) { try { ZipIRIMapper mapper = new ZipIRIMapper(file, "jar:" + file.toURI() + "!/"); mapper.oboMappings().forEach(e -> oboFileMap.put(e.getKey(), e.getValue())); mapper.iriMappings() .forEach(e -> ontologyIRI2PhysicalURIMap.put(e.getKey(), e.getValue())); } catch (IOException e) { // if we can't parse a file, then we can't map it LOGGER.debug("Exception reading file", e); } } else if (".obo".equalsIgnoreCase(extension)) { oboFileMap.put(name, IRI.create(file)); } else if (".ofn".equalsIgnoreCase(extension)) { parseFSSFile(file); } else if (".omn".equalsIgnoreCase(extension)) { parseManchesterSyntaxFile(file); } else if (fileExtensions.contains(extension.toLowerCase())) { parseFile(file); } }
private void processFile(File f) { if (f.isHidden()) { return; } // if pointed directly at a zip file, map it parseIfExtensionSupported(f); File[] files = f.listFiles(); if (files == null) { return; } for (File file : files) { if (file.isDirectory() && recursive) { processFile(file); } else { parseIfExtensionSupported(file); } } }
@Nullable private IRI parseManLine(File file, String line) { Matcher matcher = manPattern.matcher(line); if (matcher.matches()) { IRI iri = IRI.create(matcher.group(1)); addMapping(iri, file); return iri; } return null; }
public static List<OWLOntologyIRIMapper> getMappers(IRI[] dirs) { List<OWLOntologyIRIMapper> mappers = new ArrayList<OWLOntologyIRIMapper>(); if (dirs != null) { for (IRI path : dirs) { File dir = null; try { dir = new File(path.toURI()); } catch (Exception e) { // Keep dir null } if (dir != null) { if (dir.isDirectory()) mappers.add(new AutoIRIMapper(dir, true)); // We might want to construct other IRI mappers for regular files in the future... } } } return mappers; }
protected void parseIfExtensionSupported(File file) { String name = file.getName(); int lastIndexOf = name.lastIndexOf('.'); if (lastIndexOf < 0) { // no extension for the file, nothing to do return; } String extension = name.substring(lastIndexOf); if (".zip".equalsIgnoreCase(extension) || ".jar".equalsIgnoreCase(extension)) { try { ZipIRIMapper mapper = new ZipIRIMapper(file, "jar:" + file.toURI() + "!/"); mapper.oboMappings().forEach(e -> oboFileMap.put(e.getKey(), e.getValue())); mapper.iriMappings() .forEach(e -> ontologyIRI2PhysicalURIMap.put(e.getKey(), e.getValue())); } catch (IOException e) { // if we can't parse a file, then we can't map it LOGGER.debug("Exception reading file", e); } } else if (".obo".equalsIgnoreCase(extension)) { oboFileMap.put(name, IRI.create(file)); } else if (".ofn".equalsIgnoreCase(extension)) { parseFSSFile(file); } else if (".omn".equalsIgnoreCase(extension)) { parseManchesterSyntaxFile(file); } else if (fileExtensions.contains(extension.toLowerCase())) { parseFile(file); } }
/** * update the map. */ public void update() { mapFiles(); }
private void mapFiles() { mapped = true; ontologyIRI2PhysicalURIMap.clear(); processFile(getDirectory()); }
private void processFile(File f) { if (f.isHidden()) { return; } // if pointed directly at a zip file, map it parseIfExtensionSupported(f); File[] files = f.listFiles(); if (files == null) { return; } for (File file : files) { if (file.isDirectory() && recursive) { processFile(file); } else { parseIfExtensionSupported(file); } } }
@Nullable private IRI parseManLine(File file, String line) { Matcher matcher = manPattern.matcher(line); if (matcher.matches()) { IRI iri = IRI.create(matcher.group(1)); addMapping(iri, file); return iri; } return null; }
/** * Given a URI of an owl file returns the * translated OWLOntology object * @param tboxFile - the URI of the file * @return the translated OWLOntology * @throws Exception */ private OWLOntology getOntologyFromFile(URI tboxFile) throws Exception{ //get owl ontology from file OWLOntologyIRIMapper iriMapper = new AutoIRIMapper(new File(tboxFile).getParentFile(), false); man.addIRIMapper(iriMapper); OWLOntology owlontology = man.loadOntologyFromOntologyDocument(new File(tboxFile)); return owlontology; }
/** * update the map. */ public void update() { mapFiles(); }
private void mapFiles() { mapped = true; ontologyIRI2PhysicalURIMap.clear(); processFile(getDirectory()); }