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


Java OWLClass類代碼示例

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


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

示例1: buildTreeModel

import org.semanticweb.owlapi.model.OWLClass; //導入依賴的package包/類
private void buildTreeModel() {
  // first get all classes of the ontology
  Collection<OWLClass> classes = this.ontology.getClassesInSignature();
  // get the root of the tree model (the "Thing" OWL Class)
  DefaultMutableTreeNode root = null;
  for (OWLClass owlClass : classes) {
    if (owlClass.getIRI().getFragment().equals(rootConcept)) {
      root = new DefaultMutableTreeNode(owlClass);
      break;
    }
  }
  if (root == null) {
    return;
  }
  classes.remove(root.getUserObject());

  // now, add all remaining classes to the root by specialisation
  this.addSubClasses(root);
}
 
開發者ID:IGNF,項目名稱:geoxygene,代碼行數:20,代碼來源:OntologyBrowser.java

示例2: findEquivalentClasses

import org.semanticweb.owlapi.model.OWLClass; //導入依賴的package包/類
public LinkedList<String> findEquivalentClasses(){
    
    LinkedList<String> equivalentClasses = new LinkedList<>();
            
    //Get all equivalent classes and set LinkedList equivalentClasses
    Set<OWLClass> classes = classifier.getEquivalentClasses(owlClass).getEntities();
    
    //For each equivalent class
    Iterator it = classes.iterator();
    while(it.hasNext()){
        OWLClass oClass = (OWLClass)it.next();
        //Add to LinkedList equivalentClasses
        if(!oClass.isOWLThing())
            equivalentClasses.add(oClass.getIRI().toString());
    }
    
    return equivalentClasses;
}
 
開發者ID:usplssb,項目名稱:SemanticSCo,代碼行數:19,代碼來源:SemanticReasoner.java

示例3: findIndirectSubclasses

import org.semanticweb.owlapi.model.OWLClass; //導入依賴的package包/類
public LinkedList<String> findIndirectSubclasses(){
    
    LinkedList<String> indirectSubclasses = new LinkedList<>();
    
    //Get all subclasses and add them to LinkedList "indirectSubclasses"
    Set<OWLClass> subClasses = classifier.getSubClasses(owlClass,false).getFlattened();
    Iterator it = subClasses.iterator();
    while(it.hasNext()){
        OWLClass oClass = (OWLClass)it.next();
        //If is not the element owl:Nothing, add to LinkedList indirectSubclasses
        if(!oClass.isOWLNothing())
            indirectSubclasses.add(oClass.getIRI().toString());
    }
    
    //Remove direct subclasses from LinkedList "indirectSubclasses"
    indirectSubclasses.removeAll(findDirectSubclasses());
    
    return indirectSubclasses;
}
 
開發者ID:usplssb,項目名稱:SemanticSCo,代碼行數:20,代碼來源:SemanticReasoner.java

示例4: getMostSpecificType

import org.semanticweb.owlapi.model.OWLClass; //導入依賴的package包/類
/**
 * Returns the most specific type of a given individual.
 * 
 * @param ind
 * @return
 */
private OWLClass getMostSpecificType(OWLIndividual ind) {
	logger.debug("Getting the most specific type of " + ind);
	String query = String.format("PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
			+ "select distinct ?type where {" + " <%s> a ?type ." + "?type rdfs:label []."
			// + "?type a owl:Class ." // too strict, thus currently omitted
			+ "filter not exists {?subtype ^a <%s> ; rdfs:subClassOf ?type .filter(?subtype != ?type)}}",
			ind.toStringID(), ind.toStringID());
	SortedSet<OWLClass> types = new TreeSet<OWLClass>();

	QueryExecution qe = qef.createQueryExecution(query);
	ResultSet rs = qe.execSelect();
	while (rs.hasNext()) {
		QuerySolution qs = rs.next();
		if (qs.get("type").isURIResource()) {
			types.add(new OWLClassImpl(IRI.create(qs.getResource("type").getURI())));
		}
	}
	qe.close();

	// of more than one type exists, we have to choose one
	// TODO

	return types.first();
}
 
開發者ID:dice-group,項目名稱:BENGAL,代碼行數:31,代碼來源:Verbalizer.java

示例5: initialize

import org.semanticweb.owlapi.model.OWLClass; //導入依賴的package包/類
@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
	super.initialize(context);
	try {
		ontUtil = new OntologyUtil(ontologyFile);

		/*
		 * check that the term to remove is in the ontology -- if it is not,
		 * it could be a format issue
		 */
		OWLClass cls = ontUtil.getOWLClassFromId(termIdToRemove);
		if (cls == null) {
			String errorMessage = "Ontology term ID selected for removal is not in the given ontology. "
					+ "This could be a formatting issue. Term selected for removal: " + termIdToRemove
					+ " Example term ID from the ontology: " + ontUtil.getClassIterator().next().toStringID();
			throw new ResourceInitializationException(new IllegalArgumentException(errorMessage));
		}

	} catch (OWLOntologyCreationException e) {
		throw new ResourceInitializationException(e);
	}
	annotationDataExtractor = (AnnotationDataExtractor) ConstructorUtil
			.invokeConstructor(annotationDataExtractorClassName);
}
 
開發者ID:UCDenver-ccp,項目名稱:ccp-nlp,代碼行數:25,代碼來源:OntologyClassRemovalFilter_AE.java

示例6: addToOntology

import org.semanticweb.owlapi.model.OWLClass; //導入依賴的package包/類
@Override
public void addToOntology() {
  OWLObjectProperty property = featurePool.getExclusiveProperty(":propertyWithInfos");
  OWLClass range = featurePool.getExclusiveClass(":ClassWithInfos");
  OWLAnnotationProperty label = factory.getRDFSLabel();

  OWLAnnotation enAnnotation = factory.getOWLAnnotation(label, factory.getOWLLiteral("Label of a property", Locale.ENGLISH.getLanguage()));
  OWLAnnotation deAnnotation = factory.getOWLAnnotation(label, factory.getOWLLiteral("Bezeichnung einer Property", Locale.GERMAN.getLanguage()));
  OWLAnnotation jpAnnotation = factory.getOWLAnnotation(label, factory.getOWLLiteral("プロパティの指定", Locale.JAPANESE.getLanguage()));

  addAxiomToOntology(factory.getOWLAnnotationAssertionAxiom(property.getIRI(), deAnnotation));
  addAxiomToOntology(factory.getOWLAnnotationAssertionAxiom(property.getIRI(), enAnnotation));
  addAxiomToOntology(factory.getOWLAnnotationAssertionAxiom(property.getIRI(), jpAnnotation));

  OWLAnnotation enClassAnnotation = factory.getOWLAnnotation(label, factory.getOWLLiteral("Label of a class", Locale.ENGLISH.getLanguage()));
  OWLAnnotation deClassAnnotation = factory.getOWLAnnotation(label, factory.getOWLLiteral("Bezeichnung einer Klasse", Locale.GERMAN.getLanguage()));
  OWLAnnotation jpClassAnnotation = factory.getOWLAnnotation(label, factory.getOWLLiteral("どうもありがとうミスターロボット", Locale.JAPANESE.getLanguage()));

  addAxiomToOntology(factory.getOWLAnnotationAssertionAxiom(range.getIRI(), enClassAnnotation));
  addAxiomToOntology(factory.getOWLAnnotationAssertionAxiom(range.getIRI(), deClassAnnotation));
  addAxiomToOntology(factory.getOWLAnnotationAssertionAxiom(range.getIRI(), jpClassAnnotation));


  addToGenericDomainAndNewRange(property, range);
}
 
開發者ID:VisualDataWeb,項目名稱:OntoBench,代碼行數:26,代碼來源:RdfsLabelMultiLanguageFeature.java

示例7: addToOntology

import org.semanticweb.owlapi.model.OWLClass; //導入依賴的package包/類
@Override
public void addToOntology() {
  OWLObjectProperty property = featurePool.getExclusiveProperty(":propertyWithInfos");
  OWLClass range = featurePool.getExclusiveClass(":ClassWithInfos");
  OWLAnnotationProperty comment = factory.getRDFSComment();

  OWLAnnotation enAnnotation = factory.getOWLAnnotation(comment, factory.getOWLLiteral("Comment of a property", Locale.ENGLISH.getLanguage()));
  OWLAnnotation deAnnotation = factory.getOWLAnnotation(comment, factory.getOWLLiteral("Kommentar einer Property", Locale.GERMAN.getLanguage()));
  OWLAnnotation jpAnnotation = factory.getOWLAnnotation(comment, factory.getOWLLiteral("プロパティのコメント", Locale.JAPANESE.getLanguage()));

  addAxiomToOntology(factory.getOWLAnnotationAssertionAxiom(property.getIRI(), deAnnotation));
  addAxiomToOntology(factory.getOWLAnnotationAssertionAxiom(property.getIRI(), enAnnotation));
  addAxiomToOntology(factory.getOWLAnnotationAssertionAxiom(property.getIRI(), jpAnnotation));


  OWLAnnotation enClassAnnotation = factory.getOWLAnnotation(comment, factory.getOWLLiteral("Comment of a class", Locale.ENGLISH.getLanguage()));
  OWLAnnotation deClassAnnotation = factory.getOWLAnnotation(comment, factory.getOWLLiteral("Kommentar einer Klasse", Locale.GERMAN.getLanguage()));
  OWLAnnotation jpClassAnnotation = factory.getOWLAnnotation(comment, factory.getOWLLiteral("どうもありがとうミスターロボット", Locale.JAPANESE.getLanguage()));

  addAxiomToOntology(factory.getOWLAnnotationAssertionAxiom(range.getIRI(), enClassAnnotation));
  addAxiomToOntology(factory.getOWLAnnotationAssertionAxiom(range.getIRI(), deClassAnnotation));
  addAxiomToOntology(factory.getOWLAnnotationAssertionAxiom(range.getIRI(), jpClassAnnotation));

  addToGenericDomainAndNewRange(property, range);
}
 
開發者ID:VisualDataWeb,項目名稱:OntoBench,代碼行數:26,代碼來源:RdfsCommentMultiLanguageFeature.java

示例8: findIndirectSuperclasses

import org.semanticweb.owlapi.model.OWLClass; //導入依賴的package包/類
public LinkedList<String> findIndirectSuperclasses(){
    
    LinkedList<String> indirectSuperclasses = new LinkedList<>();
    
    //Get all superclasses and add them to LinkedList "indirectSuperclasses"
    Set<OWLClass> superClasses = classifier.getSuperClasses(owlClass,false).getFlattened();
    Iterator it = superClasses.iterator();
    while(it.hasNext()){
        OWLClass oClass = (OWLClass)it.next();
        //If is not the element owl:Thing, add to LinkedList indirectSuperclasses
        if(!oClass.isOWLThing())
            indirectSuperclasses.add(oClass.getIRI().toString());
    }
    
    //Remove direct superclasses from LinkedList "indirectSuperclasses"
    indirectSuperclasses.removeAll(findDirectSuperclasses());
    
    return indirectSuperclasses;
}
 
開發者ID:usplssb,項目名稱:SemanticSCo,代碼行數:20,代碼來源:SemanticReasoner.java

示例9: addToOntology

import org.semanticweb.owlapi.model.OWLClass; //導入依賴的package包/類
@Override
public void addToOntology() {
  OWLClass start = featurePool.getReusableClass();
  OWLClass middle = featurePool.getExclusiveClass(":PropertyChainMiddle");
  OWLClass end = featurePool.getExclusiveClass(":PropertyChainEnd");

  OWLObjectProperty singleStep = featurePool.getExclusiveProperty(":propertyChainProperty_SingleStep");
  OWLObjectProperty doubleStep = featurePool.getExclusiveProperty(":propertyChainProperty_DoubleStep");

  List<OWLObjectProperty> propertyChain = Arrays.asList(singleStep, singleStep);
  addAxiomToOntology(factory.getOWLSubPropertyChainOfAxiom(propertyChain, doubleStep));

  addProperty(end, singleStep, middle);
  addProperty(middle, singleStep, start);
  addProperty(end, doubleStep, start);
}
 
開發者ID:VisualDataWeb,項目名稱:OntoBench,代碼行數:17,代碼來源:OwlPropertyChainAxiomFeature.java

示例10: getSummaries

import org.semanticweb.owlapi.model.OWLClass; //導入依賴的package包/類
/**
 * Returns a textual summary of the given entity.
 *
 * @return
 */
public Map<OWLIndividual, String> getSummaries(Set<OWLIndividual> individuals, OWLClass nc, String namespace,
		double threshold, Cooccurrence cooccurrence, HardeningType hType) {
	Map<OWLIndividual, String> entity2Summaries = new HashMap<OWLIndividual, String>();

	Map<OWLIndividual, List<NLGElement>> verbalize = verbalize(individuals, nc, namespace, threshold, cooccurrence,
			hType);
	for (Entry<OWLIndividual, List<NLGElement>> entry : verbalize.entrySet()) {
		OWLIndividual individual = entry.getKey();
		List<NLGElement> elements = entry.getValue();
		String summary = realize(elements);
		summary = summary.replaceAll("\\s?\\((.*?)\\)", "");
		summary = summary.replace(" , among others,", ", among others,");
		entity2Summaries.put(individual, summary);
	}

	return entity2Summaries;
}
 
開發者ID:dice-group,項目名稱:BENGAL,代碼行數:23,代碼來源:Verbalizer.java

示例11: generateSubjects

import org.semanticweb.owlapi.model.OWLClass; //導入依賴的package包/類
/**
 * Returns a list of synonymous expressions as subject for the given
 * resource.
 * 
 * @param resource
 *            the resource
 * @param resourceType
 *            the type of the resource
 * @param resourceGender
 *            the gender of the resource
 * @return list of synonymous expressions
 */
public List<NPPhraseSpec> generateSubjects(Resource resource, OWLClass resourceType, Gender resourceGender) {
	List<NPPhraseSpec> result = new ArrayList<NPPhraseSpec>();
	// the textual representation of the resource itself
	result.add(nlg.getNPPhrase(resource.getURI(), false, false));
	// the class, e.g. 'this book'
	NPPhraseSpec np = nlg.getNPPhrase(resourceType.toStringID(), false);
	np.addPreModifier("This");
	result.add(np);
	// the pronoun depending on the gender of the resource
	if (resourceGender.equals(Gender.MALE)) {
		result.add(nlg.nlgFactory.createNounPhrase("he"));
	} else if (resourceGender.equals(Gender.FEMALE)) {
		result.add(nlg.nlgFactory.createNounPhrase("she"));
	} else {
		result.add(nlg.nlgFactory.createNounPhrase("it"));
	}
	return result;
}
 
開發者ID:dice-group,項目名稱:BENGAL,代碼行數:31,代碼來源:Verbalizer.java

示例12: findDirectSuperclasses

import org.semanticweb.owlapi.model.OWLClass; //導入依賴的package包/類
public LinkedList<String> findDirectSuperclasses(){
    
    LinkedList<String> directSuperclasses = new LinkedList<>();
    
    //Get all direct superclasses and set LinkedList directSuperclasses
    Set<OWLClass> superClasses = classifier.getSuperClasses(owlClass,true).getFlattened();
    
    //For each direct superclass
    Iterator it = superClasses.iterator();
    while(it.hasNext()){
        OWLClass oClass = (OWLClass)it.next();
        //If is not the element owl:Thing, add to LinkedList directSuperclasses
        if(!oClass.isOWLThing())
            directSuperclasses.add(oClass.getIRI().toString());
    }
    
    return directSuperclasses;
}
 
開發者ID:usplssb,項目名稱:SemanticSCo,代碼行數:19,代碼來源:SemanticReasoner.java

示例13: getParents

import org.semanticweb.owlapi.model.OWLClass; //導入依賴的package包/類
@Override
public Set<OWLEntity> getParents(OWLEntity cpt) {
	if(!cpt.isOWLClass()) return new HashSet<OWLEntity>();

	Set<OWLEntity> entities = new HashSet<OWLEntity>();
	Set<OWLEntity> result = new HashSet<OWLEntity>();
	OWLClass localRootClass = cpt.asOWLClass();
	entities.addAll(reasoner.getSuperClasses(localRootClass, true).getFlattened());
	for(OWLEntity parentClass : entities) {
		// Only Class
		if(!parentClass.isOWLClass())
		{
			continue;
		}
		// Not Nothing
		if(parentClass.isOWLClass() && parentClass.asOWLClass().isOWLNothing())
		{
			continue;
		}
		result.add(parentClass);
	}
	return result;
}
 
開發者ID:lmazuel,項目名稱:onagui,代碼行數:24,代碼來源:OWLAPIContainer.java

示例14: sendEvent

import org.semanticweb.owlapi.model.OWLClass; //導入依賴的package包/類
@Override
public void sendEvent(SemanticEvent se) {
    Set<String> triggeredFilters = new HashSet<String>();
    // add event to ontology
    manager.addAxioms(ontology, se.getAxioms());
    // extract types event
    reasoner.flush();

    NodeSet<OWLClass> inferedClasses = reasoner.getTypes(se.getMessage(), false);
    for (OWLClass owlclss : inferedClasses.getFlattened()) {
        String clss = owlclss.getIRI().toString();
        if (eventDefinitions.contains(clss)) {
            triggeredFilters.add(clss);
        }
    }
    se.setTriggeredFilterIRIs(triggeredFilters);

    //send event back to engie
    obep.sendEvent(se);
}
 
開發者ID:IBCNServices,項目名稱:OBEP,代碼行數:21,代碼來源:AbstracterImpl.java

示例15: addToOntology

import org.semanticweb.owlapi.model.OWLClass; //導入依賴的package包/類
@Override
public void addToOntology() {
  OWLClass domain = featurePool.getExclusiveClass(":DatatypeMapsDomain");
  OWLDatatype range = factory.getOWLDatatype(datatype);

  String namespace = datatype.getPrefixedName().split(":")[0];
  String name = datatype.getShortForm();
  String propertyIri = ":" + namespace + WordUtils.capitalize(name) + "Property";
  OWLDataProperty property = factory.getOWLDataProperty(propertyIri, pm);

  addProperty(domain, property, range);
}
 
開發者ID:VisualDataWeb,項目名稱:OntoBench,代碼行數:13,代碼來源:AbstractDatatypeMapFeature.java


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