当前位置: 首页>>代码示例>>Java>>正文


Java OntClass类代码示例

本文整理汇总了Java中com.hp.hpl.jena.ontology.OntClass的典型用法代码示例。如果您正苦于以下问题:Java OntClass类的具体用法?Java OntClass怎么用?Java OntClass使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


OntClass类属于com.hp.hpl.jena.ontology包,在下文中一共展示了OntClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAllClasses

import com.hp.hpl.jena.ontology.OntClass; //导入依赖的package包/类
public static List<String> getAllClasses ()
{
   List<String>classes = new ArrayList<String>();
   DrbCortexModel model;
   try
   {
      model = DrbCortexModel.getDefaultModel();
   }
   catch (IOException e)
   {
      return classes;
   }
   ExtendedIterator it= model.getCortexModel().getOntModel().listClasses();
   while (it.hasNext())
   {
      OntClass cl = (OntClass)it.next();
      String uri = cl.getURI();
      if (uri!=null)
         classes.add(uri);
   }
   return classes;
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:23,代码来源:ProcessingUtils.java

示例2: main

import com.hp.hpl.jena.ontology.OntClass; //导入依赖的package包/类
public static void main(String[] args) {
    OntoManager om = OntoManager.getInstance();
    om.load();
    OntModel model = om.getModel();
    final String NS = om.getOntologyIRI() + "#";
    logger.info(NS);

    Scanner s = new Scanner(System.in);

    while (true) {

        System.out.println("enter:");
        String clsName = s.nextLine();
        System.out.println("enhancing for: |"+clsName+"|");
        if(clsName.equalsIgnoreCase("exit"))break;
        OntClass pCls = model.getOntClass(NS + clsName);
        if(pCls==null){
            System.err.println("class does not exist");
            continue;
        }

        LinguisticEnhancer le = new LinguisticEnhancer();
        List<SynSuggestion> suggestions = le.suggestLinguisticData(pCls);


        // exclude name + labels , syn includes etc when adding syn includes

        //for suspects
        for (SynSuggestion sug : suggestions) {
            logger.debug(sug.toString());
            if (true) {
                List<String> excludeList = le.getAllExcludes(pCls, le.getClassLabels(pCls).toArray(new String[0]));
                le.addSuggestion(pCls, sug, excludeList);
            }
        }

        om.save();
    }
}
 
开发者ID:sasinda,项目名称:OntologyBasedInormationExtractor,代码行数:40,代码来源:Main.java

示例3: getClassLabels

import com.hp.hpl.jena.ontology.OntClass; //导入依赖的package包/类
/**
 * If class has a label AbraCadabraQualityPerformance --> Abra Cadabra --> abra cadabra : will be returned as a label in the set.
 *
 * @param ocls
 * @return
 */
public Set<String> getClassLabels(OntClass ocls) {
    String name = ocls.getLocalName();
    ExtendedIterator<RDFNode> iterator = ocls.listLabels(null);
    List<String> labels = new ArrayList<String>(3);
    while (iterator.hasNext()) {
        labels.add(iterator.next().asLiteral().getLexicalForm());
    }

    // get trimmed name,labels  then split camel case.
    name = trimName(name);
    name = LingUtil.splitCamelCase(name).toLowerCase();
    for (int i = 0; i < labels.size(); i++) {
        labels.set(i, LingUtil.splitCamelCase(trimName(labels.get(i))).toLowerCase());//trim then split camel case . then make lowercase
    }
    Set<String> lbls = new HashSet<String>(3);
    lbls.add(name);
    lbls.addAll(labels);
    return lbls;
}
 
开发者ID:sasinda,项目名称:OntologyBasedInormationExtractor,代码行数:26,代码来源:LinguisticEnhancer.java

示例4: getChildFeatures

import com.hp.hpl.jena.ontology.OntClass; //导入依赖的package包/类
public Set<FeatureClass> getChildFeatures(boolean direct) {

        if (direct == false) {
            Set<FeatureClass> decendatns = null;

            ExtendedIterator<OntClass> children = f.listSubClasses(false);
            if (children.hasNext()) {
                decendatns = new HashSet<FeatureClass>(15);
            }
            while (children.hasNext()) {
                decendatns.add(new FeatureClass(children.next()));
            }
            return decendatns;
        }
        return cfs;
    }
 
开发者ID:sasinda,项目名称:OntologyBasedInormationExtractor,代码行数:17,代码来源:FeatureClass.java

示例5: getListContentType

import com.hp.hpl.jena.ontology.OntClass; //导入依赖的package包/类
private OntResource getListContentType(OntClass range) throws IOException {
    if (range.asClass().getURI().equalsIgnoreCase(getExpressns() + "STRING_List") || range.asClass().hasSuperClass(expressModel.getOntClass(getExpressns() + "STRING_List")))
        return expressModel.getOntResource(getExpressns() + "STRING");
    else if (range.asClass().getURI().equalsIgnoreCase(getExpressns() + "REAL_List") || range.asClass().hasSuperClass(expressModel.getOntClass(getExpressns() + "REAL_List")))
        return expressModel.getOntResource(getExpressns() + "REAL");
    else if (range.asClass().getURI().equalsIgnoreCase(getExpressns() + "INTEGER_List") || range.asClass().hasSuperClass(expressModel.getOntClass(getExpressns() + "INTEGER_List")))
        return expressModel.getOntResource(getExpressns() + "INTEGER");
    else if (range.asClass().getURI().equalsIgnoreCase(getExpressns() + "BINARY_List") || range.asClass().hasSuperClass(expressModel.getOntClass(getExpressns() + "BINARY_List")))
        return expressModel.getOntResource(getExpressns() + "BINARY");
    else if (range.asClass().getURI().equalsIgnoreCase(getExpressns() + "BOOLEAN_List") || range.asClass().hasSuperClass(expressModel.getOntClass(getExpressns() + "BOOLEAN_List")))
        return expressModel.getOntResource(getExpressns() + "BOOLEAN");
    else if (range.asClass().getURI().equalsIgnoreCase(getExpressns() + "LOGICAL_List") || range.asClass().hasSuperClass(expressModel.getOntClass(getExpressns() + "LOGICAL_List")))
        return expressModel.getOntResource(getExpressns() + "LOGICAL");
    else if (range.asClass().getURI().equalsIgnoreCase(getExpressns() + "NUMBER_List") || range.asClass().hasSuperClass(expressModel.getOntClass(getExpressns() + "NUMBER_List")))
        return expressModel.getOntResource(getExpressns() + "NUMBER");
    else if (range.asClass().hasSuperClass(listModel.getOntClass(getListns() + "OWLList"))) {
        String listvaluepropURI = getOntNS() + range.getLocalName().substring(0, range.getLocalName().length() - 5);
        return ontModel.getOntResource(listvaluepropURI);
    } else {
   
            LOGGER.log(Level.WARNING,"did not find listcontenttype for : " + range.getLocalName() + "\r\n");

        return null;
    }
}
 
开发者ID:BenzclyZhang,项目名称:BimSPARQL,代码行数:26,代码来源:RDFWriter.java

示例6: readOwlFile

import com.hp.hpl.jena.ontology.OntClass; //导入依赖的package包/类
static void readOwlFile (String pathToOwlFile) {
        OntModel ontologyModel =
                ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, null);
        ontologyModel.read(pathToOwlFile, "RDF/XML-ABBREV");
       // OntClass myClass = ontologyModel.getOntClass("namespace+className");

        OntClass myClass = ontologyModel.getOntClass(ResourcesUri.nwr+"domain-ontology#Motion");
        System.out.println("myClass.toString() = " + myClass.toString());
        System.out.println("myClass.getSuperClass().toString() = " + myClass.getSuperClass().toString());

        //List list =
              //  namedHierarchyRoots(ontologyModel);


       Iterator i = ontologyModel.listHierarchyRootClasses()
                .filterDrop( new Filter() {
                    public boolean accept( Object o ) {
                        return ((Resource) o).isAnon();
                    }} ); ///get all top nodes and excludes anonymous classes

       // Iterator i = ontologyModel.listHierarchyRootClasses();
        while (i.hasNext()) {
            System.out.println(i.next().toString());
/*            OntClass ontClass = ontologyModel.getOntClass(i.next().toString());
            if (ontClass.hasSubClass()) {

            }*/
        }

        String q = createSparql("event", "<http://www.newsreader-project.eu/domain-ontology#Motion>");
        System.out.println("q = " + q);
        QueryExecution qe = QueryExecutionFactory.create(q,
                ontologyModel);
        for (ResultSet rs = qe.execSelect() ; rs.hasNext() ; ) {
            QuerySolution binding = rs.nextSolution();
            System.out.println("binding = " + binding.toString());
            System.out.println("Event: " + binding.get("event"));
        }

        ontologyModel.close();
    }
 
开发者ID:newsreader,项目名称:StreamEventCoreference,代码行数:42,代码来源:OwlReader.java

示例7: testSomeMethod2

import com.hp.hpl.jena.ontology.OntClass; //导入依赖的package包/类
@Test
public void testSomeMethod2() throws Exception {
  Dataset ds = TDBFactory.createDataset("/scratch/WORK2/jena/dataset2/");
  
  OntModel model1 = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, ds.getNamedModel("vijaym1"));
  OntModel model2 = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, ds.getNamedModel("vijaym2"));
  OntClass thing = model1.createClass("http://www.w3.org/2002/07/owl#Thing");
  model1.createIndividual("http://example.com/onto1#VijayRaj", thing);
  model2.createIndividual("http://example.;cegilovcom/onto2#VijayRaj", thing);
  Model m = model1.union(model2);
  
  FileWriter fw = new FileWriter("/scratch/WORK2/jena/testModels/mergetestds.xml");
  RDFDataMgr.write(fw, ds, RDFFormat.NQUADS_UTF8);
  

}
 
开发者ID:vijayrajak,项目名称:JenaKBClient,代码行数:17,代码来源:KBIndividualImplTest.java

示例8: getCredibility

import com.hp.hpl.jena.ontology.OntClass; //导入依赖的package包/类
/**
 * Calculates the given author's credibility or reputation wrt. the topic
 * represented by the given concept, based on the longevity on his/her
 * contributions to that topic, not including similar topics.
 * 
 * @param author
 *            the author
 * @param concept
 *            a concept representing a topic
 * @return the author's credibility wrt. to the given topic.
 */
public double getCredibility(String authorName, String topicName) {
	OntClass topicClass = OntologyIndex.get().getOntClass(topicName);
	if (topicClass == null) {
		return 0d;
	}
			
	persistenceStore.beginTransaction();
	Concept topic = persistenceStore.getConcept(topicClass.getURI());
	Author author = persistenceStore.getAuthor(authorName);
	persistenceStore.endTransaction();
	
	if (author == null || topic == null) {
		return 0d;
	}
	
	return getCredibility(author, topic);
	
}
 
开发者ID:ag-csw,项目名称:ExpertFinder,代码行数:30,代码来源:ExpertiseModel.java

示例9: getExpertiseScore

import com.hp.hpl.jena.ontology.OntClass; //导入依赖的package包/类
public double getExpertiseScore(String authorName, String topicName) {
	OntClass topicClass = OntologyIndex.get().getOntClass(topicName);
	if (topicClass == null) {
		return 0d;
	}
			
	persistenceStore.beginTransaction();
	Concept topic = persistenceStore.getConcept(topicClass.getURI());
	Author author = persistenceStore.getAuthor(authorName);
	persistenceStore.endTransaction();
	
	if (author == null || topic == null) {
		return 0d;
	}
	
	return getExpertiseScore(author, topic);
}
 
开发者ID:ag-csw,项目名称:ExpertFinder,代码行数:18,代码来源:ExpertiseModel.java

示例10: calculateExpertiseScore

import com.hp.hpl.jena.ontology.OntClass; //导入依赖的package包/类
/**
 * Returns the given author's consolidated expertise score for the given
 * topic and similar topics, based on the similarity metric and the
 * similarity threshold value specified in the application's configuration
 * file.
 * 
 * @param author
 * @param topic
 * @return
 */
public void calculateExpertiseScore(String authorName, String topicName) {
	OntClass topicClass = OntologyIndex.get().getOntClass(topicName);
	if (topicClass == null) {
		return;
	}
			
	persistenceStore.beginTransaction();
	Concept topic = persistenceStore.getConcept(topicClass.getURI());
	Author author = persistenceStore.getAuthor(authorName);
	persistenceStore.endTransaction();
	
	if (author == null || topic == null) {
		return;
	}
	
	calculateExpertiseScore(author, topic);
	
}
 
开发者ID:ag-csw,项目名称:ExpertFinder,代码行数:29,代码来源:ExpertiseModel.java

示例11: calcSim

import com.hp.hpl.jena.ontology.OntClass; //导入依赖的package包/类
private void calcSim() {
	OntologyIndex.get().load(OntologyIndex.class.getResource(Config.getAppProperty(Config.Key.ONTOLOGY_FILE)));
	
	OntologyIndex oi = OntologyIndex.get();
	OntModel model = oi.getModel();
	
	persistenceStore.beginTransaction();
	Query query = persistenceStore.createHQLQuery("from Concept");
	List<Concept> concepts1 = (List<Concept>)query.list();

	Query query1 = persistenceStore.createHQLQuery("from Concept");
	List<Concept> concepts2 = (List<Concept>)query1.list();
	persistenceStore.endTransaction();

	for (Concept co1 : concepts1) {
		OntClass c1 = model.getOntClass(co1.getUri());
		for (Concept co2 : concepts2) {
				OntClass c2 = model.getOntClass(co2.getUri());
		}
	}
}
 
开发者ID:ag-csw,项目名称:ExpertFinder,代码行数:22,代码来源:ExpertiseModel.java

示例12: addChildcategories

import com.hp.hpl.jena.ontology.OntClass; //导入依赖的package包/类
private static void addChildcategories(OntClass categoryClass) {
	String categoryName = categoryClass.getLocalName();
	try {
		List<String> childCategoryNames = wiki.getChildCategories(categoryName);
		for (String childCategoryName : childCategoryNames) {
			childCategoryName = URIref.encode(childCategoryName.replace(' ', '_').replace("+", "_Plus"));
			OntClass childCategoryClass = categoryClass.getOntModel().createClass(PREFIX_NS_EXPERTFINDER + childCategoryName);
			categoryClass.addSubClass(childCategoryClass);
			
			// recursively call addChildCategories
			addChildcategories(childCategoryClass);
		}
	} catch (MediaWikiAPIException e) {
		e.printStackTrace();
	}
}
 
开发者ID:ag-csw,项目名称:ExpertFinder,代码行数:17,代码来源:CategoryExtractor.java

示例13: addTripleToModel

import com.hp.hpl.jena.ontology.OntClass; //导入依赖的package包/类
/**
 * Method to add a triple to the model, either in-memory or TDB repository
 * @param subj
 * @param pred
 * @param obj
 * @param rowNum
 * @throws ConfigurationException 
 */
protected void addTripleToModel(Resource subj, Property pred, RDFNode obj,
		int rowNum, int modelArrayPosition) throws ConfigurationException {
	if (pred.equals(RDF.type) && obj instanceof Resource) {
		// if we are assigning a type, look to see if it already has a more general type and if it does
		//	remove it.
		if (subj.canAs(Individual.class) && ((Resource)obj).canAs(OntClass.class)) {
			ExtendedIterator<Resource> typeitr = subj.as(Individual.class).listRDFTypes(true);
			while (typeitr.hasNext()) {
				Resource typ = typeitr.next();
				if (!typ.equals(obj) && typ.canAs(OntClass.class)) {
					if (getSadlUtils().classIsSubclassOf(((Resource)obj).as(OntClass.class), typ.as(OntClass.class), true)) {
						subj.as(Individual.class).removeRDFType(typ.as(OntClass.class));
					}
				}
			}
		}
	}
	logger.debug("Adding triple while processing: " + subj + ", " + pred + ", " + obj);
	if (triplesLoggerOut != null) {
		logTriple(rowNum, subj, pred, obj, modelArrayPosition);
	}
	getModel(modelArrayPosition).add(subj, pred, obj);
	numTriplesImported++;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:33,代码来源:CsvImporter.java

示例14: createMaxCardinalityRestriction

import com.hp.hpl.jena.ontology.OntClass; //导入依赖的package包/类
private MaxCardinalityRestriction createMaxCardinalityRestriction(
		ConceptName prop, OntProperty p, int i,
		ClassRestrictionCondition rCond, int j) {
	if (p == null) {
		addError(2,
				"Max cardinality restriction can't tell if property '" + prop + "' is object or data property.");
		return null;
	} else {
		int card = rCond.getRestrictedToCardinality();
		MaxCardinalityRestriction cr = getJenaModel()
				.createMaxCardinalityRestriction(null, p, card);
		if (cr != null && rCond.getRestrictedToObject() != null) {
			cr.removeAll(OWL.maxCardinality);
			cr.addLiteral(OWL2.maxQualifiedCardinality, new Integer(rCond.getRestrictedToCardinality()));
			OntClass qualifiedCls = conceptIdentifierToOntClass(i, j, (ConceptIdentifier) rCond.getRestrictedToObject());
			cr.addProperty(OWL2.onClass, qualifiedCls);
		}
		return cr;
	}
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:21,代码来源:ModelManager.java

示例15: createMinCardinalityRestriction

import com.hp.hpl.jena.ontology.OntClass; //导入依赖的package包/类
private MinCardinalityRestriction createMinCardinalityRestriction(
		ConceptName prop, OntProperty p, int i,
		ClassRestrictionCondition rCond, int j) {
	if (p == null) {
		addError(2,
				"Min cardinality restriction can't tell if property '" + prop + "' is object or data property.");
		return null;
	} else {
		int card = rCond.getRestrictedToCardinality();
		MinCardinalityRestriction cr = getJenaModel()
				.createMinCardinalityRestriction(null, p, card);
		if (cr != null && rCond.getRestrictedToObject() != null) {
			cr.removeAll(OWL.minCardinality);
			cr.addLiteral(OWL2.minQualifiedCardinality, new Integer(rCond.getRestrictedToCardinality()));
			OntClass qualifiedCls = conceptIdentifierToOntClass(i, j, (ConceptIdentifier) rCond.getRestrictedToObject());
			cr.addProperty(OWL2.onClass, qualifiedCls);
		}
		return cr;
	}
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:21,代码来源:ModelManager.java


注:本文中的com.hp.hpl.jena.ontology.OntClass类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。