本文整理汇总了Java中org.apache.jena.riot.RDFLanguages.filenameToLang方法的典型用法代码示例。如果您正苦于以下问题:Java RDFLanguages.filenameToLang方法的具体用法?Java RDFLanguages.filenameToLang怎么用?Java RDFLanguages.filenameToLang使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.jena.riot.RDFLanguages
的用法示例。
在下文中一共展示了RDFLanguages.filenameToLang方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: analyze
import org.apache.jena.riot.RDFLanguages; //导入方法依赖的package包/类
@Override
public Iterator<byte[]> analyze(CrawleableUri curi, File data, Sink sink) {
FileInputStream fin = null;
try {
// First, try to get the language of the data
Lang lang = null;
String contentType = (String) curi.getData(HttpHeaders.CONTENT_TYPE);
if (contentType != null) {
lang = RDFLanguages.contentTypeToLang(contentType);
} else {
lang = RDFLanguages.filenameToLang(data.getName(), null);
}
FilterSinkRDF filtered = new FilterSinkRDF(curi, sink);
RDFDataMgr.parse(filtered, data.getAbsolutePath(), lang);
} catch (Exception e) {
LOGGER.error("Exception while analyzing. Aborting.");
} finally {
IOUtils.closeQuietly(fin);
}
return collector.getUris(curi);
}
示例2: reinitialiseProcessors
import org.apache.jena.riot.RDFLanguages; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void reinitialiseProcessors(){
if (!this.executor.isShutdown()){
this.executor.shutdownNow();
}
Lang lang = RDFLanguages.filenameToLang(datasetURI);
if ((lang == Lang.NQ) || (lang == Lang.NQUADS)){
this.iterator = new PipedRDFIterator<Quad>(rdfIterBufferSize, rdfIterFairBufferLock, rdfIterPollTimeout, rdfIterMaxPolls);
this.rdfStream = new PipedQuadsStream((PipedRDFIterator<Quad>) iterator);
} else {
this.iterator = new PipedRDFIterator<Triple>(rdfIterBufferSize, rdfIterFairBufferLock, rdfIterPollTimeout, rdfIterMaxPolls);
this.rdfStream = new PipedTriplesStream((PipedRDFIterator<Triple>) iterator);
}
this.isInitalised = true;
this.executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
lstMetricConsumers = new ArrayList<MetricProcess>();
for(String className : this.metricInstances.keySet()) {
this.lstMetricConsumers.add(new MetricProcess(this.metricInstances.get(className)));
}
}
示例3: setUpProcess
import org.apache.jena.riot.RDFLanguages; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void setUpProcess() {
Lang lang = RDFLanguages.filenameToLang(datasetURI);
if ((lang == Lang.NQ) || (lang == Lang.NQUADS)){
this.iterator = new PipedRDFIterator<Quad>(rdfIterBufferSize, rdfIterFairBufferLock, rdfIterPollTimeout, rdfIterMaxPolls);
this.rdfStream = new PipedQuadsStream((PipedRDFIterator<Quad>) iterator);
} else {
this.iterator = new PipedRDFIterator<Triple>(rdfIterBufferSize, rdfIterFairBufferLock, rdfIterPollTimeout, rdfIterMaxPolls);
this.rdfStream = new PipedTriplesStream((PipedRDFIterator<Triple>) iterator);
}
logger.debug("PipedRDFIterator initialized with: Buffer Size {}, Fair Lock {}, Poll Timeout {}, Max Polls {}",
rdfIterBufferSize, rdfIterFairBufferLock, rdfIterPollTimeout, rdfIterMaxPolls);
this.isInitalised = true;
try {
this.loadMetrics();
} catch (ExternalMetricLoaderException e) {
logger.error(e.getLocalizedMessage());
}
this.executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
}
示例4: setUpProcess
import org.apache.jena.riot.RDFLanguages; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void setUpProcess() {
Lang lang = RDFLanguages.filenameToLang(datasetURI);
if ((lang == Lang.NQ) || (lang == Lang.NQUADS)){
this.iterator = new PipedRDFIterator<Quad>(rdfIterBufferSize, rdfIterFairBufferLock, rdfIterPollTimeout, rdfIterMaxPolls);
this.rdfStream = new PipedQuadsStream((PipedRDFIterator<Quad>) iterator);
} else {
this.iterator = new PipedRDFIterator<Triple>(rdfIterBufferSize, rdfIterFairBufferLock, rdfIterPollTimeout, rdfIterMaxPolls);
this.rdfStream = new PipedTriplesStream((PipedRDFIterator<Triple>) iterator);
}
this.isInitalised = true;
try {
this.loadMetrics();
} catch (ExternalMetricLoaderException e) {
logger.error(e.getLocalizedMessage());
}
this.executor = Executors.newSingleThreadExecutor();
}
示例5: reinitialiseProcessors
import org.apache.jena.riot.RDFLanguages; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void reinitialiseProcessors(){
if (!this.executor.isShutdown()){
this.executor.shutdownNow();
}
Lang lang = RDFLanguages.filenameToLang(datasetURI);
if ((lang == Lang.NQ) || (lang == Lang.NQUADS)){
this.iterator = new PipedRDFIterator<Quad>(rdfIterBufferSize, rdfIterFairBufferLock, rdfIterPollTimeout, rdfIterMaxPolls);
this.rdfStream = new PipedQuadsStream((PipedRDFIterator<Quad>) iterator);
} else {
this.iterator = new PipedRDFIterator<Triple>(rdfIterBufferSize, rdfIterFairBufferLock, rdfIterPollTimeout, rdfIterMaxPolls);
this.rdfStream = new PipedTriplesStream((PipedRDFIterator<Triple>) iterator);
}
this.isInitalised = true;
this.executor = Executors.newSingleThreadExecutor();
lstMetricConsumers = new ArrayList<MetricProcess>();
for(String className : this.metricInstances.keySet()) {
this.lstMetricConsumers.add(new MetricProcess(this.metricInstances.get(className)));
}
}
示例6: setUpProcess
import org.apache.jena.riot.RDFLanguages; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void setUpProcess() {
Lang lang = RDFLanguages.filenameToLang(datasetURI);
if ((lang == Lang.NQ) || (lang == Lang.NQUADS)){
this.iterator = new PipedRDFIterator<Quad>(rdfIterBufferSize, rdfIterFairBufferLock, rdfIterPollTimeout, rdfIterMaxPolls);
this.rdfStream = new PipedQuadsStream((PipedRDFIterator<Quad>) iterator);
} else {
this.iterator = new PipedRDFIterator<Triple>(rdfIterBufferSize, rdfIterFairBufferLock, rdfIterPollTimeout, rdfIterMaxPolls);
this.rdfStream = new PipedTriplesStream((PipedRDFIterator<Triple>) iterator);
}
logger.debug("PipedRDFIterator initialized with: Buffer Size {}, Fair Lock {}, Poll Timeout {}, Max Polls {}",
rdfIterBufferSize, rdfIterFairBufferLock, rdfIterPollTimeout, rdfIterMaxPolls);
this.isInitalised = true;
try {
this.loadMetrics();
} catch (ExternalMetricLoaderException e) {
logger.error(e.getLocalizedMessage());
}
this.executor = Executors.newSingleThreadExecutor();
}
示例7: setUpProcess
import org.apache.jena.riot.RDFLanguages; //导入方法依赖的package包/类
public void setUpProcess() {
Lang lang = RDFLanguages.filenameToLang(datasetURI);
if ((lang == Lang.NQ) || (lang == Lang.NQUADS)){
} else {
}
this.isInitalised = true;
// try {
// this.loadMetrics();
// } catch (ExternalMetricLoaderException e) {
// logger.error(e.getLocalizedMessage());
// }
this.executor = Executors.newSingleThreadExecutor();
}
示例8: getFormatFromExtension
import org.apache.jena.riot.RDFLanguages; //导入方法依赖的package包/类
public static String getFormatFromExtension(String filename) {
String format = "TURTLE";
try {
// try to get if from Jena first
String extension;
Lang jenaLang = RDFLanguages.filenameToLang(filename);
if (jenaLang != null) {
extension = jenaLang.getFileExtensions().get(0);
} else {
int index = filename.lastIndexOf('.');
extension = filename.substring(index + 1, filename.length());
}
SerializationFormat f = FormatService.getInputFormat(extension);
if (f != null) {
format = f.getName();
}
} catch (Exception e) {
log.debug("No format found, using the default one", e);
return "TURTLE";
}
return format;
}
示例9: toPatch
import org.apache.jena.riot.RDFLanguages; //导入方法依赖的package包/类
protected RDFPatch toPatch(String fn) {
// .gz??
Lang lang = RDFLanguages.filenameToLang(fn);
if ( lang != null && ( RDFLanguages.isTriples(lang) || RDFLanguages.isQuads(lang) ) ) {
RDFChangesCollector x = new RDFChangesCollector();
StreamRDF dest = new RDF2Patch(x);
// dest will do the start-finish on the RDFChangesCollector via parsing.
RDFDataMgr.parse(dest, fn);
return x.getRDFPatch();
}
// Not RDF - assume a text patch.
// String ext = FileOps.extension(fn);
// switch(ext) {
// case RDFPatchConst.EXT:
// break;
// case RDFPatchConst.EXT_B:
// break;
// default:
// Log.warn(addpatch.class, "Conventionally, patches have file extension ."+RDFPatchConst.EXT);
// }
Path path = Paths.get(fn);
try(InputStream in = Files.newInputStream(path) ) {
return RDFPatchOps.read(in);
} catch (IOException ex ) { throw IOX.exception(ex); }
}
示例10: getRdfLangFromFilePath
import org.apache.jena.riot.RDFLanguages; //导入方法依赖的package包/类
public static Lang getRdfLangFromFilePath(String filePath) {
filePath = filePath.toLowerCase();
if (filePath.endsWith(".gzip")) {
filePath = filePath.substring(0, filePath.length() - 5);
} else if (filePath.endsWith(".gz")) {
filePath = filePath.substring(0, filePath.length() - 3);
}
return RDFLanguages.filenameToLang(filePath);
}
示例11: annotationDatasetFor
import org.apache.jena.riot.RDFLanguages; //导入方法依赖的package包/类
public Dataset annotationDatasetFor(Child<?> workflowBean) {
Dataset dataset = DatasetFactory.createMem();
for (Annotation ann : scufl2Tools.annotationsFor(workflowBean)) {
WorkflowBundle bundle = ann.getParent();
URI annUri = uritools.uriForBean(ann);
String bodyUri = bundle.getGlobalBaseURI().resolve(ann.getBody())
.toASCIIString();
if (ann.getBody().isAbsolute()) {
logger.info("Skipping absolute annotation body URI: "
+ ann.getBody());
// TODO: Optional loading of external annotation bodies
continue;
}
String path = ann.getBody().getPath();
ResourceEntry resourceEntry = bundle.getResources()
.getResourceEntry(path);
if (resourceEntry == null) {
logger.warning("Can't find annotation body: " + path);
continue;
}
String contentType = resourceEntry.getMediaType();
Lang lang = RDFLanguages.contentTypeToLang(contentType);
if (lang == null) {
lang = RDFLanguages.filenameToLang(path);
}
if (lang == null) {
logger.warning("Can't find media type of annotation body: "
+ ann.getBody());
continue;
}
Model model = ModelFactory.createDefaultModel();
try (InputStream inStream = bundle.getResources()
.getResourceAsInputStream(path)) {
RDFDataMgr.read(model, inStream, bodyUri, lang);
} catch (IOException e) {
logger.warning("Can't read annotation body: " + path);
continue;
}
dataset.addNamedModel(annUri.toString(), model);
}
return dataset;
}
示例12: loadModel
import org.apache.jena.riot.RDFLanguages; //导入方法依赖的package包/类
/**
* Loads the data to be added
*
* @param baseDir
* Base Directory
* @param file
* Filename
* @return Model
* @throws IOException
*/
protected Model loadModel(File baseDir, String file) throws IOException {
File rdfFile = this.resolveFile(baseDir, file);
Lang rdfLang = RDFLanguages.filenameToLang(rdfFile.getAbsolutePath(), null);
if (rdfLang == null)
throw new IOException("No known RDF reader for file " + rdfFile.getAbsolutePath());
return RDFDataMgr.loadModel(rdfFile.getAbsolutePath(), rdfLang);
}
示例13: convert
import org.apache.jena.riot.RDFLanguages; //导入方法依赖的package包/类
/**
* @param inputFile File path of the IFC STEP file.
* @param outputFile Output file path of the RDF file. RDF syntax is determined by the extension of output file, supported extensions are *.ttl (Turtle) and *.nt (N-Triple).
* @param ifcVersion Set the IFC version of the input IFC file, supported IFC versions are IFC2X3_TC1, IFC2X3_FINAL, IFC4, IFC4X1_RC3, IFC4_ADD1 and IFC4_ADD2. If it is null, the converter parses the header in IFC file to automatically determine the IFC version. Only three IFC versions are supported using this way, they are IFC2X3_TC1 (if header contains "IFC2X3"), IFC4x1_RC3 (if header contains "IFC4x1") and IFC4_ADD1 (if header contains "IFC4").
* @param baseURI Namespace for the output RDF file. If it is null, the default value is "http://linkedbuildingdata.net/ifc/resources" + timeLog+"/".
* @param logToFile Set whether log to file, default is false. If it is true, the log file is generated in the same directory of the output file.
* @param expid Set whether generate express id as a separate property for instances. Default is false.
* @param merge Set whether to remove duplicate objects. Default is false. If it is set to true, the round trip IFC file might have less objects.
* @param updateNS Set whether to update namespace for the ifcOWL ontology. Defaut value is false. If it is true, the converter will look up the namespace from the corresponding ifcOWL file in the resources folder and use it. Therefore the corresponding ifcOWL file must be updated before, otherwise it will still use the old namespace.
*/
public void convert(String inputFile, String outputFile, String ifcVersion,String baseURI, boolean logToFile,boolean expid,boolean merge,boolean updateNS)
throws IOException {
Lang lang=RDFLanguages.filenameToLang(outputFile);
convert(inputFile,outputFile,lang,ifcVersion,baseURI,logToFile,expid,merge,updateNS);
}