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


Java OntClass.getURI方法代码示例

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


在下文中一共展示了OntClass.getURI方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: lookupConcept

import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的package包/类
public String lookupConcept(String fullLabel) {
		String concept = null;
		// try the map
		OntClass existingConcept = allConcepts.get(getFragment(fullLabel));
		if (existingConcept != null) {
			concept = existingConcept.getURI();
		}
		// look in current model
//		if (concept == null) {
//			concept = this.lookupConcept(fullLabel, this.m);
//		}
//		// look in existing model
//		if (concept == null) {
//			concept = this.lookupConcept(fullLabel, this.ecsoModel);
//		}
		return concept;
	}
 
开发者ID:DataONEorg,项目名称:annotator,代码行数:18,代码来源:MeasurementTypeGenerator.java

示例3: getUsage

import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的package包/类
private List<Statement> getUsage(OntClass ontClass, Model model){
	List<Statement> stmts = new ArrayList<Statement>();
	try{
		String sparql = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> "
				+ "PREFIX owl: <http://www.w3.org/2002/07/owl#> "
				+ "SELECT DISTINCT ?concept "
				+ "WHERE{"
				+ "  {?prop rdfs:range <" + ontClass.getURI() + ">; "
				+ "    rdfs:domain ?concept"
				+ "  }"
				+ "  UNION "
				+ "  { "
				+ "    ?concept rdfs:subClassOf|owl:equivalentClass ?restriction . "
				+ "    ?restriction a owl:Restriction; "
				+ "      ?p <" + ontClass.getURI() + "> "
				+ "  } "
				+ "}";
		Query query = QueryFactory.create(sparql, Syntax.syntaxARQ);
		QueryExecution queryExecution = QueryExecutionFactory.create(query, model);
		
		ResultSet resultSet = queryExecution.execSelect();
		while(resultSet.hasNext()){
			QuerySolution querySolution = resultSet.next();
			Resource concept = querySolution.getResource("concept");
			
			stmts.add(new StatementImpl(ontClass, usage, concept));
		}
	} catch(Exception e){
		log.error(e.getMessage(), e);
	}
	
	return stmts;
	
}
 
开发者ID:teamdigitale,项目名称:ontonethub,代码行数:35,代码来源:IndexingJob.java

示例4: ProductClass

import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的package包/类
ProductClass(OntClass ontClass) {
    if (!ontClass.hasSuperClass(PO.PRODUCT)) {
        throw new IllegalArgumentException("provided ontClass is not a product. uri=" + ontClass.getURI());
    }
    ;
    pCls = ontClass;
    features = new HashSet<FeatureClass>();
    top_level_features = new HashSet<FeatureClass>();
}
 
开发者ID:sasinda,项目名称:OntologyBasedInormationExtractor,代码行数:10,代码来源:ProductClass.java

示例5: findNrofSuperClasses

import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的package包/类
/** Find the number of subclasses for the indicated OntClass. 
 * Caches values to speed up determination.
 *  
 * @param oc
 * @return
 */
protected int findNrofSuperClasses (OntClass oc) {
	String classUri = oc.getURI();
	if (!numOfSuperClasses.containsKey(classUri)) {
		ExtendedIterator i = oc.listSuperClasses();
		numOfSuperClasses.put(classUri, new Integer(i.toList().size()));
	}
	return numOfSuperClasses.get(classUri).intValue();
}
 
开发者ID:brianthomas,项目名称:soml,代码行数:15,代码来源:SemanticObjectBuilder.java

示例6: extractConcepts

import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的package包/类
/**
 * Tries to match concepts to sections. Handles a list of sections. If a section cannot be matched to any concept, the section's parent
 * sections are subsequently tried until a concept can be matched or the top section is reached. Concepts from parent sections are weighted
 * less than concepts from the original section (using a milestone similarity measure). 
 * @param section
 * @param sharedConcepts
 */
private void extractConcepts(de.csw.expertfinder.document.Section section, HashMap<String, Concept> sharedConcepts) {
	PersistenceStoreFacade persistenceStore = PersistenceStoreFacade.get();
	List<OntClass> sectionConcepts = extractConcepts(section.getTitle());
	int level = section.getLevel();
	double sim = 1d;
	de.csw.expertfinder.document.Section tmpSection = section;
	
	// if no concept could be found, try to get concepts from the parent section
	while (sectionConcepts.isEmpty()) {
		tmpSection = tmpSection.getParentSection();
		if (tmpSection == null)
			break;
		sectionConcepts = extractConcepts(tmpSection.getTitle());
	}
	
	if (tmpSection == null)
		// no concept for any parent section
		return;
	
	int otherLevel = tmpSection.getLevel();
	if (otherLevel != level) {
		sim = 1 - milestones[otherLevel] + milestones[level];
	}
		
	for (OntClass ontClass : sectionConcepts) {
		String conceptURI = ontClass.getURI();
		Concept concept = persistenceStore.getConcept(conceptURI);
		if (concept == null) {
			concept = sharedConcepts.get(conceptURI);
			if (concept == null) {
				concept = new Concept(conceptURI);
				sharedConcepts.put(conceptURI, concept);
				persistenceStore.save(concept);
			}
		}
		section.addConcept(concept, sim);
	}
}
 
开发者ID:ag-csw,项目名称:ExpertFinder,代码行数:46,代码来源:MediaWikiExpertFinderConsumer.java

示例7: getSimilarity

import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的package包/类
/**
 * <p>Returns the similarity of the two given classes, based on the similarity
 * measure specified in the application property file.</p>
 * <p>
 * The value is only calculated one time and stored to a cache in the persistent store. On subsequent calls
 * to this method with the same classes, the result is retrieved from the cache.
 * </p>
 * 
 * @param c1
 *            One class.
 * @param c2
 *            The other class.
 * @return the similarity of the two given classes, based on the similarity
 *         measure specified in the application property file.
 */
public double getSimilarity(OntClass c1, OntClass c2) {
	String uri1 = c1.getURI();
	String uri2 = c2.getURI();

	PersistenceStoreFacade p = PersistenceStoreFacade.get();
	p.beginTransaction();
	
	Double sim = p.getConceptSimilarity(uri1, uri2);
	
	if (sim == null) {
		AbstractSimilarityMeasure similarityMeasure;
		try {
			similarityMeasure = similarityMeasureConstructor.newInstance(ontologyAccessor, new GraphNode(uri1), new GraphNode(uri2));
		} catch (Exception e) {
			log.error("Error instanciating similarity measure class.", e);
			p.rollbackChanges();
			return -1;
		}
		
		similarityMeasure.calculate();
		sim = similarityMeasure.getSimilarity();
		
		Concept concept1 = p.getConcept(uri1);
		Concept concept2 = p.getConcept(uri2);
		
		// this should actually not happen. We should only get called with existing concepts.
		if (concept1 == null) {
			log.warn("Concept with URI " + uri1 + " did not exist in the database. ");
			concept1 = new Concept(uri1);
			p.save(concept1);
		}
		if (concept2 == null) {
			log.warn("Concept with URI " + uri2 + " did not exist in the database. "); 
			concept2 = new Concept(uri2);
			p.save(concept2);
		}
		
		ConceptSimilarity conceptSimilarity = new ConceptSimilarity(concept1, concept2, sim);
		p.save(conceptSimilarity);
		
		p.commitChanges();
	} else {
		p.endTransaction();
	}
	
	return sim;
	
}
 
开发者ID:ag-csw,项目名称:ExpertFinder,代码行数:64,代码来源:OntologyIndex.java

示例8: checkAndAddResult

import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的package包/类
/**
 * Gets matching OntClasses from the {@link OntologyIndex} for the word
 * sequence in the given queue and adds them to the result list.
 * 
 * @param oi
 *            the OntologyIndex
 * @param queue
 *            a queue containing a sequence of words
 * @param sharedConcepts
 *            a map of concepts that were newly created during the current
 *            call of the annotation consuming method.
 */
private void checkAndAddResult(OntologyIndex oi, LinkedList<de.csw.expertfinder.document.Word> queue, HashMap<String, Concept> sharedConcepts) {
	ArrayList<String> wordsAsStrings = new ArrayList<String>(queue.size());
	for (de.csw.expertfinder.document.Word word : queue) {
		wordsAsStrings.add(word.getWordStem());
	}
	Map<OntClass, Integer> matchingOntClasses = oi.getClassesMatchingTerms(wordsAsStrings);
	
	if (matchingOntClasses.isEmpty())
		return;
	
	// Get best match (there may be more than one)
	Set<OntClass> keySet = matchingOntClasses.keySet();
	OntClass bestOntClass = null;
	int longestLength = -1;
	for (OntClass ontClass : keySet) {
		int length = matchingOntClasses.get(ontClass);
		if (length > longestLength) {
			bestOntClass = ontClass;
			longestLength = length;
		}
	}
	
	// Add concept, if it already exists, if not create it first.
	String conceptURI = bestOntClass.getURI();
	PersistenceStoreFacade persistenceStore = PersistenceStoreFacade.get();
	Concept concept = persistenceStore.getConcept(conceptURI);
	if (concept == null) {
		concept = sharedConcepts.get(conceptURI);
		if (concept == null) {
			concept = new Concept(conceptURI);
			sharedConcepts.put(conceptURI, concept);
			persistenceStore.save(concept);
		}
	}
	
	// add concept to all words that it spans
	for(int i=0; i<=longestLength; i++) {
		queue.get(i).setConcept(concept);
	}

}
 
开发者ID:ag-csw,项目名称:ExpertFinder,代码行数:54,代码来源:MediaWikiExpertFinderConsumer.java

示例9: generateTypes

import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的package包/类
public String generateTypes(String pidFile) throws Exception {
	
	// fetch the file
	URL url = new URL(pidFile);
   	InputStream inputStream = url.openStream();
	BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
	
	// parse it
	Iterable<CSVRecord> records = CSVFormat.TDF.withHeader().parse(reader);
	
	int count = 0;
	// iterate over the rows
	for (CSVRecord record : records) {
		
		// get the info from the csv file
	    String entityLabel = record.get("Entity");
	    String characteristicLabel = record.get("Characteristic");
	    String class_id_int = record.get("class_id_int");
	    
	    // skip records that already have a MeasurementType concept
	    if (class_id_int != null && class_id_int.length() > 0) {
	    	continue;
	    }
	    
	    // or that don't have enough information
	    if (entityLabel == null || entityLabel.length() == 0) {
	    	continue;
	    }
	    if (characteristicLabel == null || characteristicLabel.length() == 0) {
	    	continue;
	    }
	    
	    // construct measurement label
	    
	    String rowValue = this.getFragment(entityLabel) + " " + this.getFragment(characteristicLabel);
	    log.debug("Processing row: " + rowValue);

	    if (allConcepts.containsKey(rowValue)) {
		    log.debug("Skipping duplicate row");
	    	continue;
	    }
	    
	    OntClass mt = this.generateMeasurementType(entityLabel, characteristicLabel);
	    // log for tying it back to the source rows
	    if (mt != null) {
	    	
	    	// parse out the class id int that we made
	    	String uri = mt.getURI();
	    	String generatedClassIdInt = uri.split("_")[1];
	    	generatedClassIdInt = generatedClassIdInt.replaceFirst("^0+(?!$)", "");
	    	
		    log.debug("Generated MeasurementType: \t" 
		    		+ generatedClassIdInt + "\t" 
		    		+ uri + "\t" 
		    		+ mt.getLabel(null) + "\t" 
		    		+ entityLabel + "\t" 
		    		+ characteristicLabel
		    		);
		    // record for future iteration
		    allConcepts.put(rowValue, mt);
		    count++;
	    } else {
		    log.debug("could not generate MeasurementType for row: " + rowValue); 
	    }
	}
	log.debug("Generated class count: " + count);
	
	String rdf = this.getModelAsString();
	System.out.println(rdf);
	return rdf;
	
}
 
开发者ID:DataONEorg,项目名称:annotator,代码行数:73,代码来源:MeasurementTypeGenerator.java


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