當前位置: 首頁>>代碼示例>>Java>>正文


Java OWLOntology類代碼示例

本文整理匯總了Java中org.semanticweb.owlapi.model.OWLOntology的典型用法代碼示例。如果您正苦於以下問題:Java OWLOntology類的具體用法?Java OWLOntology怎麽用?Java OWLOntology使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


OWLOntology類屬於org.semanticweb.owlapi.model包,在下文中一共展示了OWLOntology類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: OntologyBrowser

import org.semanticweb.owlapi.model.OWLOntology; //導入依賴的package包/類
public OntologyBrowser(OWLOntology ontology, Set<String> rootsToRemove) {
  super();
  this.ontology = ontology;
  this.rootConcept = "Thing";
  this.buildTreeModel();
  for (String concept : rootsToRemove) {
    DefaultMutableTreeNode node = getNodeFromName(concept);
    this.dtm.removeNodeFromParent(node);
  }

  this.setModel(this.dtm);
  // set the tree selection model
  DefaultTreeSelectionModel dtsm = new DefaultTreeSelectionModel();
  dtsm.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  this.setSelectionModel(dtsm);
  // set the tree renderer
  OntologyRenderer myRenderer = new OntologyRenderer();
  this.setCellRenderer(myRenderer);
  this.setRootVisible(false);
}
 
開發者ID:IGNF,項目名稱:geoxygene,代碼行數:21,代碼來源:OntologyBrowser.java

示例2: export

import org.semanticweb.owlapi.model.OWLOntology; //導入依賴的package包/類
@UITopiaVariant(
  author = "onprom team",
  affiliation = "Free University of Bozen-Bolzano",
  email = "[email protected]",
  website = "http://onprom.inf.unibz.it"
)
@PluginVariant(requiredParameterLabels = {0, 1})
public void export(PluginContext context, OWLOntology ontology, File file) {
  try {
    //default format is RDF/XML format for the ontology
    RDFDocumentFormat format = new RDFXMLDocumentFormat();
    //save the given ontology using the format to the file
    OWLManager.createOWLOntologyManager().saveOntology(ontology, format, new FileOutputStream(file));
    context.log("Exported ontology to the file: " + file.getName());
  } catch (Exception e) {
    context.log("Couldn't export ontology to the file: " + file.getName() + " ->" + e.getMessage());
  }
}
 
開發者ID:onprom,項目名稱:onprom,代碼行數:19,代碼來源:OWLOntologyExportPlugin.java

示例3: importFromStream

import org.semanticweb.owlapi.model.OWLOntology; //導入依賴的package包/類
@UITopiaVariant(
  author = "onprom team",
  affiliation = "Free University of Bozen-Bolzano",
  email = "[email protected]",
  website = "http://onprom.inf.unibz.it"
)
@Override
protected OWLOntology importFromStream(final PluginContext context, final InputStream input, final String filename,
                                       final long fileSizeInBytes) {
  try {
    context.getFutureResult(0).setLabel("OWL ontology imported from " + filename);
    return OWLManager.createOWLOntologyManager().loadOntologyFromOntologyDocument(input);
  } catch (final Throwable e) {
    context.log("Couldn't import ontology:" + e.getMessage(), Logger.MessageLevel.ERROR);
  }
  return null;
}
 
開發者ID:onprom,項目名稱:onprom,代碼行數:18,代碼來源:OWLOntologyImportPlugin.java

示例4: open

import org.semanticweb.owlapi.model.OWLOntology; //導入依賴的package包/類
public static LoadedObjects open(File selectedFile, FileType... allowedFileType) {
    if (selectedFile == null) {
        selectedFile = IOUtility.selectFileToOpen(allowedFileType);
    }
    switch (IOUtility.getFileType(selectedFile)) {
        case ONTOLOGY:
            OWLOntology ontology = OWLImporter.loadOntologyFromFile(selectedFile);
            if (ontology != null) {
                return new LoadedObjects(selectedFile, ontology, OWLImporter.getShapes(ontology));
            }
            break;
        case ANNOTATION:
        case UML:
        case QUERIES:
        case JSON:
            return new LoadedObjects(selectedFile, null, IOUtility.importJSON(selectedFile));
    }
    return null;
}
 
開發者ID:onprom,項目名稱:onprom,代碼行數:20,代碼來源:IOUtility.java

示例5: extractXESLog

import org.semanticweb.owlapi.model.OWLOntology; //導入依賴的package包/類
/**
 * Generates XES log based on the given inputs, namely: 
 * Domain Ontology, OBDA Model, and annotation information
 * 
 * @author Ario Santoso ([email protected] / [email protected])
 * @param domainOntology
 * @param obdaModel
 * @param annotation
 * @return event log - XLog
 * @throws InvalidDataSourcesNumberException 
 * @throws OWLException 
 * @throws InvalidAnnotationException 
 * @throws XESLogExtractionFailureException 
 * @deprecated this one is only maintained for backward compatibility with the other OnProm plug in, at some point it should be removed
 */
@Deprecated
public static XLog extractXESLog(OWLOntology domainOntology, OBDAModel obdaModel, AnnotationQueries annotation) 
		throws InvalidDataSourcesNumberException, InvalidAnnotationException, OWLException, XESLogExtractionFailureException, OBDAException, MalformedQueryException{

	List<OBDADataSource> odsList = obdaModel.getSources();
	if(odsList.size() > 1)
		throw new InvalidDataSourcesNumberException(odsList.size());
	
	//Construct EBDA Model
	logger.info(String.format(LEConstants.LOG_INFO_TEMPLATE, "Start constucting an EBDA Model"));
	LEObjectFactory leFact = LEObjectFactory.getInstance();
	EBDAModelNaiveImpl ebdaModel = leFact.createEBDAModelNaiveImpl();
	
	//add data source information to the EBDA Model
	ebdaModel.addSource(odsList.get(0));
	
	logger.info(String.format(LEConstants.LOG_INFO_TEMPLATE, "Construct the mappings for the EBDA Model"));
	//add new mapping based on the annotation information
	ebdaModel.addMapping(domainOntology, obdaModel, annotation);
	
	logger.info(String.format(LEConstants.LOG_INFO_TEMPLATE, "Finish constucting an EBDA Model"));

	return extractXESLog(ebdaModel);
}
 
開發者ID:onprom,項目名稱:onprom,代碼行數:40,代碼來源:XESLogExtractorExperimental.java

示例6: createEBDAModelNaiveImpl

import org.semanticweb.owlapi.model.OWLOntology; //導入依賴的package包/類
/**
 * Generates EBDA Model based on the given inputs, namely: 
 * Domain Ontology, OBDA Model, and annotation information
 * 
 * @author Ario Santoso ([email protected] / [email protected])
 * @param domainOntology
 * @param obdaModel
 * @param annotation
 * @return EBDA Model
 * @throws InvalidDataSourcesNumberException 
 * @throws OWLException 
 * @throws InvalidAnnotationException 
 * @throws XESLogExtractionFailureException 
 */
public EBDAModelNaiveImpl createEBDAModelNaiveImpl(OWLOntology domainOntology, OBDAModel obdaModel, AnnotationQueries annotation) 
		throws InvalidDataSourcesNumberException, InvalidAnnotationException, OWLException, XESLogExtractionFailureException, OBDAException, MalformedQueryException{
	
	List<OBDADataSource> odsList = obdaModel.getSources();
	if(odsList.size() > 1)
		throw new InvalidDataSourcesNumberException(odsList.size());
	
	//Construct EBDA Model
	logger.info(String.format(LEConstants.LOG_INFO_TEMPLATE, "Start constucting an EBDA Model"));
	LEObjectFactory leFact = LEObjectFactory.getInstance();
	EBDAModelNaiveImpl ebdaModel = leFact.createEBDAModelNaiveImpl();
	
	//add data source information to the EBDA Model
	ebdaModel.addSource(odsList.get(0));
	
	logger.info(String.format(LEConstants.LOG_INFO_TEMPLATE, "Construct the mappings for the EBDA Model"));
	//add new mapping based on the annotation information
	ebdaModel.addMapping(domainOntology, obdaModel, annotation);
	
	logger.info(String.format(LEConstants.LOG_INFO_TEMPLATE, "Finish constucting an EBDA Model"));
	
	return ebdaModel;	
}
 
開發者ID:onprom,項目名稱:onprom,代碼行數:38,代碼來源:XESLogExtractorExperimental.java

示例7: createEBDAModelImpl2

import org.semanticweb.owlapi.model.OWLOntology; //導入依賴的package包/類
/**
 * Generates EBDA Model based on the given inputs, namely: 
 * Domain Ontology, OBDA Model, and annotation information
 * 
 * @author Ario Santoso ([email protected] / [email protected])
 * @param domainOntology
 * @param obdaModel
 * @param annotation
 * @return EBDA Model
 * @throws InvalidDataSourcesNumberException 
 * @throws OWLException 
 * @throws InvalidAnnotationException 
 * @throws XESLogExtractionFailureException 
 */
public EBDAModelImpl2 createEBDAModelImpl2(OWLOntology domainOntology, OBDAModel obdaModel, AnnotationQueries annotation) 
		throws InvalidDataSourcesNumberException, InvalidAnnotationException, OWLException, XESLogExtractionFailureException, OBDAException, MalformedQueryException{
	
	List<OBDADataSource> odsList = obdaModel.getSources();
	if(odsList.size() > 1)
		throw new InvalidDataSourcesNumberException(odsList.size());
	
	//Construct EBDA Model
	logger.info(String.format(LEConstants.LOG_INFO_TEMPLATE, "Start constucting an EBDA Model"));
	LEObjectFactory leFact = LEObjectFactory.getInstance();
	EBDAModelImpl2 ebdaModel = leFact.createEBDAModelImpl2();
	
	//add data source information to the EBDA Model
	ebdaModel.addSource(odsList.get(0));
	
	//add new mapping based on the annotation information
	logger.info(String.format(LEConstants.LOG_INFO_TEMPLATE, "Construct the mappings for the EBDA Model"));
	ebdaModel.addMapping(domainOntology, obdaModel, annotation);
	
	logger.info(String.format(LEConstants.LOG_INFO_TEMPLATE, "Finish constucting an EBDA Model"));
	
	return ebdaModel;	
}
 
開發者ID:onprom,項目名稱:onprom,代碼行數:38,代碼來源:XESLogExtractorExperimental.java

示例8: createEBDAModelImpl3

import org.semanticweb.owlapi.model.OWLOntology; //導入依賴的package包/類
/**
 * Generates EBDA Model based on the given inputs, namely: 
 * Domain Ontology, OBDA Model, and annotation information
 * 
 * @author Ario Santoso ([email protected] / [email protected])
 * @param domainOntology
 * @param obdaModel
 * @param annotation
 * @return EBDA Model
 * @throws InvalidDataSourcesNumberException 
 * @throws OWLException 
 * @throws InvalidAnnotationException 
 * @throws XESLogExtractionFailureException 
 */
public EBDAModelImpl3 createEBDAModelImpl3(OWLOntology domainOntology, OBDAModel obdaModel, AnnotationQueries annotation) 
		throws InvalidDataSourcesNumberException, InvalidAnnotationException, OWLException, XESLogExtractionFailureException, OBDAException, MalformedQueryException{
	
	List<OBDADataSource> odsList = obdaModel.getSources();
	if(odsList.size() > 1)
		throw new InvalidDataSourcesNumberException(odsList.size());
	
	//Construct EBDA Model
	logger.info(String.format(LEConstants.LOG_INFO_TEMPLATE, "Start constucting an EBDA Model"));
	LEObjectFactory leFact = LEObjectFactory.getInstance();
	EBDAModelImpl3 ebdaModel = leFact.createEBDAModelImpl3();
	
	//add data source information to the EBDA Model
	ebdaModel.addSource(odsList.get(0));
	
	//add new mapping based on the annotation information
	logger.info(String.format(LEConstants.LOG_INFO_TEMPLATE, "Construct the mappings for the EBDA Model"));
	ebdaModel.addMapping(domainOntology, obdaModel, annotation);
	
	logger.info(String.format(LEConstants.LOG_INFO_TEMPLATE, "Finish constucting an EBDA Model"));
	
	return ebdaModel;	
}
 
開發者ID:onprom,項目名稱:onprom,代碼行數:38,代碼來源:XESLogExtractorExperimental.java

示例9: createEBDAModelWithOptimizedXAttributesEncoding

import org.semanticweb.owlapi.model.OWLOntology; //導入依賴的package包/類
/**
 * Generates EBDA Model based on the given inputs, namely: 
 * Domain Ontology, OBDA Model, and annotation information
 * 
 * @author Ario Santoso ([email protected] / [email protected])
 * @param domainOntology
 * @param obdaModel
 * @param annotation
 * @return EBDA Model
 * @throws InvalidDataSourcesNumberException 
 * @throws OWLException 
 * @throws InvalidAnnotationException 
 * @throws XESLogExtractionFailureException 
 */
public EBDAModelWithOptimizedXAttributesEncoding createEBDAModelWithOptimizedXAttributesEncoding(OWLOntology domainOntology, OBDAModel obdaModel, AnnotationQueries annotation) 
		throws InvalidDataSourcesNumberException, InvalidAnnotationException, OWLException, XESLogExtractionFailureException, OBDAException, MalformedQueryException{
	
	List<OBDADataSource> odsList = obdaModel.getSources();
	if(odsList.size() > 1)
		throw new InvalidDataSourcesNumberException(odsList.size());
	
	//Construct EBDA Model
	logger.info(String.format(LEConstants.LOG_INFO_TEMPLATE, "Start constucting an EBDA Model"));
	LEObjectFactory leFact = LEObjectFactory.getInstance();
	EBDAModelWithOptimizedXAttributesEncoding ebdaModel = leFact.createEBDAModelWithOptimizedXAttributesEncoding();
	
	//add data source information to the EBDA Model
	ebdaModel.addSource(odsList.get(0));
	
	//add new mapping based on the annotation information
	logger.info(String.format(LEConstants.LOG_INFO_TEMPLATE, "Construct the mappings for the EBDA Model"));
	ebdaModel.addMapping(domainOntology, obdaModel, annotation);
	
	logger.info(String.format(LEConstants.LOG_INFO_TEMPLATE, "Finish constucting an EBDA Model"));
	
	return ebdaModel;	
}
 
開發者ID:onprom,項目名稱:onprom,代碼行數:38,代碼來源:XESLogExtractorExperimental.java

示例10: createSQLGeneratorExt

import org.semanticweb.owlapi.model.OWLOntology; //導入依賴的package包/類
private SQLGeneratorExt createSQLGeneratorExt(OWLOntology ontology, OBDAModel inputOBDAModel) throws InvalidDataSourcesNumberException {

		//Get the data source
			Collection<OBDADataSource> sources = inputOBDAModel.getSources();
			if (sources == null || !(sources.size() == 1))
				throw new InvalidDataSourcesNumberException(sources.size());
			OBDADataSource obdaSource = sources.iterator().next();
		//END OF Get the data source

		DBMetadata metadata = this.getDBMetadata();
		String jdbcClassName = obdaSource.getParameter(RDBMSourceParameterConstants.DATABASE_DRIVER);
		String jdbcDatabaseName = metadata.getDbmsVersion();
		
	    SQLDialectAdapter sqladapter = SQLAdapterFactory.getSQLDialectAdapter(jdbcClassName, jdbcDatabaseName);
			
		return new SQLGeneratorExt(metadata, sqladapter, this.isSqlGenerateReplace(), this.hasDistinctResultSet(), this.getUriMap());
	}
 
開發者ID:onprom,項目名稱:onprom,代碼行數:18,代碼來源:QuestOWLReasonerExt.java

示例11: fromOntology

import org.semanticweb.owlapi.model.OWLOntology; //導入依賴的package包/類
/**
 * Returns a list of rules extracted from the given OWL-2 ontology document.
 * 
 * @param src an ontology document
 * @return a list of rules
 */
public static List<Rule> fromOntology(OWLOntologyDocumentSource src) {
	try {
		// use OWL-API to get a OWLOntology document from source
		OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
		manager.loadOntologyFromOntologyDocument(src);
		Set<OWLOntology> ontologies = manager.getOntologies();
		if (ontologies.isEmpty()) {
			return Collections.EMPTY_LIST;
		} else {
			// use first ontology from given source
			return fromOntology(ontologies.iterator().next());
		}
	} catch (OWLOntologyCreationException ex) {
		throw new IllegalArgumentException(
				"Loading ontology stream failed", ex);
	}
}
 
開發者ID:lszeremeta,項目名稱:neo4j-sparql-extension-yars,代碼行數:24,代碼來源:Rules.java

示例12: getOntologyFromName

import org.semanticweb.owlapi.model.OWLOntology; //導入依賴的package包/類
/**
 * Open the OWL ontology (from the ontology resources of CartAGen) whose name
 * is passed as parameter.
 * @param name
 * @return
 * @throws OWLOntologyCreationException
 */
public static OWLOntology getOntologyFromName(String name)
    throws OWLOntologyCreationException {
  // create the URI from the name and the CartAGen ontologies folder path
  String uri = FOLDER_PATH + "/" + name + ".owl";
  InputStream stream = OwlUtil.class.getResourceAsStream(uri);
  File file = new File(stream.toString());
  String path = file.getAbsolutePath().substring(0,
      file.getAbsolutePath().lastIndexOf('\\'));
  path = path.replaceAll(new String("\\\\"), new String("//"));
  path = path + "//src/main//resources//ontologies//" + name + ".owl";
  // create the ontology from the URI using an OWLOntologyManager
  OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
  IRI physicalURI = IRI.create(new File(path));
  OWLOntology ontology = manager
      .loadOntologyFromOntologyDocument(physicalURI);

  return ontology;
}
 
開發者ID:IGNF,項目名稱:geoxygene,代碼行數:26,代碼來源:OwlUtil.java

示例13: train

import org.semanticweb.owlapi.model.OWLOntology; //導入依賴的package包/類
/**
 * Train on resources of a given class.
 * 
 * @param filename
 * @param strategy
 * @param classname
 * @return
 */
public static R2VModel train(String filename,
		TfidfFEXStrategy strategy, String classname) {
	
	OWLOntology o = getOntology(filename);
	R2VModel model = new R2VModel(o, strategy);
	
	for(OWLIndividual ind : getIndividuals(classname, o)) {
		model.add(ind.asOWLNamedIndividual());
	}
	
	model.stringFeatures();
	model.normalize();
	
	return model;
}
 
開發者ID:AKSW,項目名稱:Resource2Vec,代碼行數:24,代碼來源:R2VManager.java

示例14: getOntology

import org.semanticweb.owlapi.model.OWLOntology; //導入依賴的package包/類
/**
 * @param filename
 * @return
 */
private static OWLOntology getOntology(String filename) {
	File file = new File(filename);
	
	OWLOntologyManager m = OWLManager.createOWLOntologyManager();

	OWLOntology o;
	try {
		o = m.loadOntologyFromOntologyDocument(IRI.create(file.toURI()));
	} catch (OWLOntologyCreationException e) {
		fail("Cannot load ontology.");
		return null;
	}
	assertNotNull(o);

	return o;
}
 
開發者ID:AKSW,項目名稱:Resource2Vec,代碼行數:21,代碼來源:R2VManager.java

示例15: getIndividuals

import org.semanticweb.owlapi.model.OWLOntology; //導入依賴的package包/類
/**
 * @param superclass
 * @param o
 * @return
 */
private static Set<OWLIndividual> getIndividuals(String superclass,
		OWLOntology o) {
	
	OWLReasoner reasoner = PelletReasonerFactory.getInstance()
			.createReasoner(o);
	Set<OWLNamedIndividual> instances = reasoner.getInstances(
			OWL.Class(IRI.create(superclass)), false).getFlattened();
	
	// filter out all owl:sameAs instances...
	Set<OWLIndividual> ind = new TreeSet<>();
	for (OWLNamedIndividual i : instances) {
		ind.add(i);
	}
	logger.info("|I| = " + ind.size());
	logger.debug("I = " + ind);

	return ind;

}
 
開發者ID:AKSW,項目名稱:Resource2Vec,代碼行數:25,代碼來源:R2VManager.java


注:本文中的org.semanticweb.owlapi.model.OWLOntology類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。