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


Java OWLDataFactory类代码示例

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


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

示例1: verbalizeAndAdd

import org.semanticweb.owl.model.OWLDataFactory; //导入依赖的package包/类
/**
 * <p>Note that we do not add the axiom into the ontology, because
 * we expect it to be there already, as it is one of the tangling
 * axioms.</p>
 * 
 * @param acetext ACE text
 * @param ont OWL ontology
 * @param axiomVerbalizer AxiomVerbalizer
 * @param axiom OWL axiom
 */
private static void verbalizeAndAdd(ACEText<OWLEntity, OWLLogicalAxiom> acetext, OWLOntology ont, AxiomVerbalizer axiomVerbalizer, OWLLogicalAxiom axiom) {
	ACESnippet snippet = null;
	try {
		snippet = axiomVerbalizer.verbalizeAxiom(ont.getURI(), axiom);
	} catch (Exception e) {
		e.printStackTrace();
	}
	if (snippet != null) {
		acetext.add(snippet);
		OWLDataFactory df = owlModelManager.getOWLDataFactory();
		OWLAxiomAnnotationAxiom annAcetext = OntologyUtils.createAxiomAnnotation(df, axiom, acetextURI, snippet.toString());
		OWLAxiomAnnotationAxiom annTimestamp = OntologyUtils.createAxiomAnnotation(df, axiom, timestampURI, snippet.getTimestamp().toString());
		List<OWLAxiomChange> changes = Lists.newArrayList();
		changes.add(new AddAxiomByACEView(ont, annAcetext));
		changes.add(new AddAxiomByACEView(ont, annTimestamp));
		changeOntology(changes);
	}
	else {
		logger.warn("AxiomVerbalizer produced a null-snippet for: " + axiom.toString());
	}
}
 
开发者ID:Kaljurand,项目名称:aceview,代码行数:32,代码来源:ACETextManager.java

示例2: createMorphAnnotations

import org.semanticweb.owl.model.OWLDataFactory; //导入依赖的package包/类
/**
 * <p>Creates morphological annotations from the lemma, using English morphological
 * synthesis. The lemma should normally be the rendering of the given OWL entity.</p>
 * 
 * @param df OWL data factory
 * @param entity OWL entity
 * @param lemma OWL entity rendering
 * @return Set of OWL entity annotation axioms
 */
public static Set<OWLEntityAnnotationAxiom> createMorphAnnotations(OWLDataFactory df, OWLEntity entity, String lemma) {
	Set<OWLEntityAnnotationAxiom> axioms = Sets.newHashSet();

	if (! Showing.isShow(entity)) {
		return axioms;
	}

	if (entity instanceof OWLClass) {
		Noun noun = new Noun(lemma);
		axioms.add(df.getOWLEntityAnnotationAxiom(entity, FieldType.SG.getURI(), df.getOWLUntypedConstant(lemma)));
		axioms.add(df.getOWLEntityAnnotationAxiom(entity, FieldType.PL.getURI(), df.getOWLUntypedConstant(noun.getPlural())));
	}
	else if (isVerblike(entity)) {
		ACEVerb verb = new ACEVerb(lemma);
		axioms.add(df.getOWLEntityAnnotationAxiom(entity, FieldType.SG.getURI(), df.getOWLUntypedConstant(verb.getPresent3SG())));
		axioms.add(df.getOWLEntityAnnotationAxiom(entity, FieldType.PL.getURI(), df.getOWLUntypedConstant(lemma)));
		axioms.add(df.getOWLEntityAnnotationAxiom(entity, FieldType.VBG.getURI(), df.getOWLUntypedConstant(verb.getPastParticiple())));
	}
	else if (entity instanceof OWLIndividual) {
		axioms.add(df.getOWLEntityAnnotationAxiom(entity, FieldType.SG.getURI(), df.getOWLUntypedConstant(lemma)));
	}

	return axioms;
}
 
开发者ID:Kaljurand,项目名称:aceview,代码行数:34,代码来源:MorphAnnotation.java

示例3: addMorfAnnotations

import org.semanticweb.owl.model.OWLDataFactory; //导入依赖的package包/类
private static List<OWLAxiomChange> addMorfAnnotations(OWLDataFactory df, OWLOntology ont, OWLEntity entity, String lemma) {
	List<OWLAxiomChange> addList = Lists.newArrayList();
	Set<OWLEntityAnnotationAxiom> entityAnnotationAxioms = MorphAnnotation.createMorphAnnotations(df, entity, lemma);
	if (entityAnnotationAxioms.isEmpty()) {
		logger.info("Init: entity " + entity + " is already annotated");
	}
	else {
		logger.info("Init: entity " + entity + " adding annotations: " + entityAnnotationAxioms);
		for (OWLEntityAnnotationAxiom ax : entityAnnotationAxioms) {
			addList.add(new AddAxiom(ont, ax));
		}
	}
	return addList;
}
 
开发者ID:Kaljurand,项目名称:aceview,代码行数:15,代码来源:ACEViewTab.java

示例4: verbalizeWithWS

import org.semanticweb.owl.model.OWLDataFactory; //导入依赖的package包/类
/**
 * <p>Verbalizes the OWL axiom using the Verbalizer webservice.</p>
 * 
 * @param uri URI
 * @param axiom OWL axiom
 * @return Verbalization of the given axiom
 * @throws OWLRendererException 
 * @throws OWLOntologyChangeException 
 * @throws OWLOntologyCreationException 
 */
private String verbalizeWithWS(URI uri, OWLLogicalAxiom axiom, OWLDataFactory df) throws OWLRendererException, OWLOntologyCreationException, OWLOntologyChangeException {
	Set<OWLAxiom> allAxioms = Sets.newHashSet((OWLAxiom) axiom);

	for (OWLEntity entity : axiom.getReferencedEntities()) {
		Set<OWLEntityAnnotationAxiom> annotationAxioms = MorphAnnotation.getMorphAnnotationsFromLexicon(df, lexicon, entity);
		allAxioms.addAll(annotationAxioms);
	}

	OWLOntologyManager ontologyManager = ACETextManager.createOWLOntologyManager();
	OWLOntology ontology = ontologyManager.createOntology(allAxioms, uri);
	return verbalizeOntology(ontologyManager, ontology);
}
 
开发者ID:Kaljurand,项目名称:aceview,代码行数:23,代码来源:AxiomVerbalizer.java

示例5: setValueAt

import org.semanticweb.owl.model.OWLDataFactory; //导入依赖的package包/类
/**
 * The delete/add is a single change i.e. one UNDO would suffice to restore
 * the original state.
 * 
 * TODO: This code is buggy as it accesses the LexiconField enum
 */
@Override
public void setValueAt(Object newValue, int row, int column) {
	String newValueAsString = (String) newValue;
	String oldValueAsString = (String) getValueAt(row, column);
	if (newValueAsString.equals(oldValueAsString)) {
		logger.info("No change");
	}
	else {
		logger.info("Changing: " + oldValueAsString + " -> " + newValueAsString);
		OWLEntity entity = (OWLEntity) entityArray[row];
		if (entity != null) {
			OWLModelManager mm = ACETextManager.getOWLModelManager();
			OWLOntology ont = mm.getActiveOntology();
			// TODO: BUG: This way of finding the URI is waiting to be broken.
			FieldType field = FieldType.values()[column - 3];
			List<OWLAxiomChange> changes = Lists.newArrayList();

			// Remove the respective annotation (if present)
			changes.addAll(ACETextManager.findEntityAnnotationAxioms(ont, entity, field.getURI()));

			// We add a new annotation only if the modification of the table cell is
			// a non-empty string.
			if (newValueAsString.length() > 0) {
				OWLDataFactory df = mm.getOWLDataFactory();
				OWLEntityAnnotationAxiom newAnnot = df.getOWLEntityAnnotationAxiom(entity, field.getURI(), df.getOWLUntypedConstant(newValueAsString));
				changes.add(new AddAxiomByACEView(ont, newAnnot));
			}

			OntologyUtils.changeOntology(mm.getOWLOntologyManager(), changes);
			fireTableCellUpdated(row, column);
		}
	}
}
 
开发者ID:Kaljurand,项目名称:aceview,代码行数:40,代码来源:LexiconTableModel.java

示例6: isCompleteIndividuals

import org.semanticweb.owl.model.OWLDataFactory; //导入依赖的package包/类
private boolean isCompleteIndividuals(OWLDataFactory df, OWLReasoner reasoner, OWLDescription desc, Set<OWLIndividual> answers) {
	OWLDescription completenessTest =
		df.getOWLObjectIntersectionOf(
				desc,
				df.getOWLObjectComplementOf(
						df.getOWLObjectOneOf(answers)));

	return (! isSatisfiable(reasoner, completenessTest));
}
 
开发者ID:Kaljurand,项目名称:aceview,代码行数:10,代码来源:ACEAnswer.java

示例7: isCompleteSubClasses

import org.semanticweb.owl.model.OWLDataFactory; //导入依赖的package包/类
private boolean isCompleteSubClasses(OWLDataFactory df, OWLReasoner reasoner, OWLDescription desc, Set<OWLClass> answers) {
	OWLDescription completenessTest =
		df.getOWLObjectIntersectionOf(
				desc,
				df.getOWLObjectComplementOf(
						df.getOWLObjectUnionOf(answers)));

	return (! isSatisfiable(reasoner, completenessTest));
}
 
开发者ID:Kaljurand,项目名称:aceview,代码行数:10,代码来源:ACEAnswer.java

示例8: ACEAnswersPane

import org.semanticweb.owl.model.OWLDataFactory; //导入依赖的package包/类
public ACEAnswersPane(OWLWorkspace ws, OWLDataFactory df) {
	setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
	setBackground(Colors.BG_COLOR);
	setEditable(false);

	this.ws = ws;
	this.df = df;
}
 
开发者ID:Kaljurand,项目名称:aceview,代码行数:9,代码来源:ACEAnswersPane.java

示例9: actionPerformed

import org.semanticweb.owl.model.OWLDataFactory; //导入依赖的package包/类
public void actionPerformed(ActionEvent actionEvent) {
	OWLModelManager mm = ACETextManager.getOWLModelManager();
	OWLDataFactory df = mm.getOWLDataFactory();
	Set<OWLOntology> ontologies = mm.getActiveOntologies();
	OWLOntologyManager ontologyManager = mm.getOWLOntologyManager();
	int ontologyCounter = 0;
	int entityCounter = 0;
	int annotatedEntityCounter = 0;
	int annotationCounter = 0;

	List<AddAxiom> additions = Lists.newArrayList();

	for (OWLOntology ont : ontologies) {
		ontologyCounter++;
		for (OWLEntity entity : ont.getReferencedEntities()) {
			entityCounter++;
			String entityRendering = getOWLModelManager().getRendering(entity);
			Set<OWLEntityAnnotationAxiom> entityAnnotationAxioms = MorphAnnotation.getMorphAnnotations(df, ont, entity, entityRendering);
			int size = entityAnnotationAxioms.size();
			if (size > 0) {
				for (OWLEntityAnnotationAxiom ax : entityAnnotationAxioms) {
					additions.add(new AddAxiom(ont, ax));
				}
				annotatedEntityCounter++;
				annotationCounter += size;
			}
		}
	}

	OntologyUtils.changeOntology(ontologyManager, additions);

	ACETextManager.fireEvent(EventType.ACELEXICON_CHANGED);
	String message = "Checked " + entityCounter + " entities in " + ontologyCounter + " active ontologies.";
	message += "\nAnnotated " + annotatedEntityCounter + " entities with " + annotationCounter + " annotations.";
	JOptionPane.showMessageDialog(null, message, "Fill Lexicon Action", JOptionPane.INFORMATION_MESSAGE);
}
 
开发者ID:Kaljurand,项目名称:aceview,代码行数:37,代码来源:FillLexiconAction.java

示例10: getMorphAnnotationsFromLexicon

import org.semanticweb.owl.model.OWLDataFactory; //导入依赖的package包/类
/**
 * <p>Creates a set of entity annotation axioms on the basis the lexicon entries
 * for the given entity.</p>
 * 
 * @param df OWLDataFactory
 * @param lexicon Lexicon from where we take the entity's surface forms
 * @param entity OWL entity to be annotated
 * @return Set of OWL entity annotation axioms
 */
public static Set<OWLEntityAnnotationAxiom> getMorphAnnotationsFromLexicon(OWLDataFactory df, ACELexicon<OWLEntity> lexicon, OWLEntity entity) {

	Set<OWLEntityAnnotationAxiom> axioms = Sets.newHashSet();

	if (! Showing.isShow(entity)) {
		return axioms;
	}

	ACELexiconEntry entry = lexicon.getEntry(entity);

	if (entry == null) {
		return axioms;
	}


	if (entity instanceof OWLClass) {
		addToAxioms(df, axioms, entity, FieldType.SG.getURI(), entry.getSg());
		addToAxioms(df, axioms, entity, FieldType.PL.getURI(), entry.getPl());
	}
	else if (isVerblike(entity)) {
		addToAxioms(df, axioms, entity, FieldType.SG.getURI(), entry.getSg());
		addToAxioms(df, axioms, entity, FieldType.PL.getURI(), entry.getPl());
		addToAxioms(df, axioms, entity, FieldType.VBG.getURI(), entry.getVbg());
	}
	else if (entity instanceof OWLIndividual) {
		addToAxioms(df, axioms, entity, FieldType.SG.getURI(), entry.getSg());
	}

	return axioms;
}
 
开发者ID:Kaljurand,项目名称:aceview,代码行数:40,代码来源:MorphAnnotation.java

示例11: verbalizeAxiom

import org.semanticweb.owl.model.OWLDataFactory; //导入依赖的package包/类
/**
 * <p>Verbalizes a single logical OWL axiom as an ACE snippet.</p>
 * 
 * @param ns Namespace for the snippet to be created
 * @param axiom OWL logical axiom to be verbalized
 * @return ACE snippet containing the verbalization of the given axiom
 * @throws OWLRendererException 
 * @throws OWLOntologyChangeException 
 * @throws OWLOntologyCreationException 
 */
public ACESnippet verbalizeAxiom(URI ns, OWLLogicalAxiom axiom) throws OWLRendererException, OWLOntologyCreationException, OWLOntologyChangeException {

	// BUG: this is a bit of a hack for performance reasons.
	// We verbalize simple axioms without having to use
	// the verbalizer webservice. It seems that about 50% of
	// the axioms in real-world ontologies are simple SubClassOf-axioms,
	// so it really pays off performancewise to verbalize them directly in Java.
	String verbalization = verbalizeSimpleSubClassAxiom(axiom);

	if (verbalization != null) {
		return new ACESnippetImpl(ns, verbalization, axiom);
	}

	logger.info("Verbalizing the axiom using WS");
	OWLDataFactory df = ACETextManager.getOWLModelManager().getOWLDataFactory();
	try {
		verbalization = verbalizeWithWS(ns, axiom, df);
	}
	catch (Exception e) {
		JOptionPane.showMessageDialog(null, "OWL verbalizer error:\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
	}

	ACESnippet snippet = null;
	if (verbalization == null) {
		// Axioms not verbalized, using Manchester Syntax rendering.
		logger.info("Axioms not verbalized, using Manchester Syntax rendering");
		String manSynRendering = ACETextManager.getOWLModelManager().getRendering(axiom);
		if (manSynRendering == null) {
			snippet = new ACESnippetImpl(ns, "", axiom, axiom.toString());
		}
		else {
			snippet = new ACESnippetImpl(ns, "", axiom, manSynRendering);
		}			
	}
	else {
		snippet = new ACESnippetImpl(ns, verbalization, axiom);
	}

	return snippet;
}
 
开发者ID:Kaljurand,项目名称:aceview,代码行数:51,代码来源:AxiomVerbalizer.java

示例12: createAxiomAnnotation

import org.semanticweb.owl.model.OWLDataFactory; //导入依赖的package包/类
public static OWLAxiomAnnotationAxiom createAxiomAnnotation(OWLDataFactory df, OWLAxiom axiom, URI uri, String str) {
	OWLAnnotation ann = df.getOWLConstantAnnotation(uri, df.getOWLUntypedConstant(str));
	return df.getOWLAxiomAnnotationAxiom(axiom, ann);
}
 
开发者ID:Kaljurand,项目名称:aceview,代码行数:5,代码来源:OntologyUtils.java

示例13: getMorphAnnotations

import org.semanticweb.owl.model.OWLDataFactory; //导入依赖的package包/类
/**
 * <p>Returns an empty set of axioms if the input entity corresponds to
 * a function word (<code>owl:Thing</code>, <code>owl:Nothing</code>, ...) which is not to be annotated
 * with surface forms.</p>
 * 
 * <p>Otherwise returns a set of entity annotation axioms for the given entity.
 * An annotation is not generated in case the entity has already been annotated
 * with the annotation. This means that surface form is a functional property of the entity.</p>
 * 
 * @param df OWLDataFactory
 * @param ontology OWL ontology in which we check if the entity has already been annotated
 * @param entity OWL entity to be annotated
 * @param lemma Lemma form of the entity which should be taken as the basis when generating surface forms
 * @return Set of OWL entity annotation axioms
 */
public static Set<OWLEntityAnnotationAxiom> getMorphAnnotations(OWLDataFactory df, OWLOntology ontology, OWLEntity entity, String lemma) {

	Set<OWLEntityAnnotationAxiom> axioms = Sets.newHashSet();

	if (! Showing.isShow(entity)) {
		return axioms;
	}

	// Existing annotation URIs for the entity.
	Set<URI> annotationURIs = OntologyUtils.getAnnotationURIs(ontology, entity);

	if (entity instanceof OWLClass) {

		if (! annotationURIs.contains(FieldType.SG.getURI())) {
			axioms.add(df.getOWLEntityAnnotationAxiom(entity, FieldType.SG.getURI(), df.getOWLUntypedConstant(lemma)));
		}

		if (! annotationURIs.contains(FieldType.PL.getURI())) {
			Noun noun = new Noun(lemma);
			axioms.add(df.getOWLEntityAnnotationAxiom(entity, FieldType.PL.getURI(), df.getOWLUntypedConstant(noun.getPlural())));
		}
	}
	else if (isVerblike(entity)) {
		ACEVerb verb = new ACEVerb(lemma);

		if (! annotationURIs.contains(FieldType.SG.getURI())) {
			axioms.add(df.getOWLEntityAnnotationAxiom(entity, FieldType.SG.getURI(), df.getOWLUntypedConstant(verb.getPresent3SG())));
		}

		if (! annotationURIs.contains(FieldType.PL.getURI())) {
			axioms.add(df.getOWLEntityAnnotationAxiom(entity, FieldType.PL.getURI(), df.getOWLUntypedConstant(lemma)));
		}

		if (! annotationURIs.contains(FieldType.VBG.getURI())) {
			axioms.add(df.getOWLEntityAnnotationAxiom(entity, FieldType.VBG.getURI(), df.getOWLUntypedConstant(verb.getPastParticiple())));
		}
	}
	else if (entity instanceof OWLIndividual) {
		if (! annotationURIs.contains(FieldType.SG.getURI())) {
			axioms.add(df.getOWLEntityAnnotationAxiom(entity, FieldType.SG.getURI(), df.getOWLUntypedConstant(lemma)));
		}
	}

	return axioms;
}
 
开发者ID:Kaljurand,项目名称:aceview,代码行数:61,代码来源:MorphAnnotation.java

示例14: addToAxioms

import org.semanticweb.owl.model.OWLDataFactory; //导入依赖的package包/类
private static void addToAxioms(OWLDataFactory df, Set<OWLEntityAnnotationAxiom> axioms, OWLEntity entity, URI uri, String form) {
	if (form != null) {
		axioms.add(df.getOWLEntityAnnotationAxiom(entity, uri, df.getOWLUntypedConstant(form)));
	}
}
 
开发者ID:Kaljurand,项目名称:aceview,代码行数:6,代码来源:MorphAnnotation.java

示例15: addToText

import org.semanticweb.owl.model.OWLDataFactory; //导入依赖的package包/类
/**
 * 
 * @param addedSnippet
 * @param ont
 * @param df
 * @param ontologyManager
 * @param acetext
 * @param logicalAxiom
 */
private static void addToText(ACESnippet snippet, OWLOntology ont, OWLDataFactory df, OWLOntologyManager ontologyManager, ACEText acetext, OWLLogicalAxiom logicalAxiom) {
	acetext.add(snippet);
	OWLAnnotation ann = df.getOWLConstantAnnotation(ACETextManager.acetextURI, df.getOWLUntypedConstant(snippet.toString()));
	OWLAxiomAnnotationAxiom axannax = df.getOWLAxiomAnnotationAxiom(logicalAxiom, ann);
	ACETextManager.addAxiomsToOntology(ontologyManager, ont, Sets.newHashSet(axannax));
}
 
开发者ID:Kaljurand,项目名称:aceview,代码行数:16,代码来源:ACEViewTab.java


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