/** * True if the passed knowledge is a direct observable, i.e., an object * (see @{link isObject}) or a relationship. * * @param o * @return true if directly observable */ public static boolean isDirect(ISemantic o) { IKnowledge observable = o.getType(); return isObject(observable) || isRelationship(observable); }
} else if (NS.isObject(obs) || NS.isRelationship(obs)) { if (last != null) { ret.add(last);
/** * Constructor that will set the observation type to the most general for the passed * observed concept. * * @param concept */ public ObservableSemantics(IConcept concept) { if (concept != null) { mainType = concept; obsType = NS.isObject(concept) ? KLAB.c(NS.DIRECT_OBSERVATION) : KLAB.c(NS.INDIRECT_OBSERVATION); formalName = CamelCase.toLowerCase(NS.getDisplayName(concept), '-'); } }
public static IConcept makeDistance(IConcept concept) { if (concept.is(KLAB.c(NS.CORE_DISTANCE))) { return concept; } if (!NS.isObject(concept)) { throw new KlabRuntimeException("cannot compute the distance to a quality"); } String cName = "DistanceTo" + cleanInternalId(concept.getLocalName()); /* * make a ConceptCount if not there, and ensure it's a continuously quantifiable * quality. Must be in same ontology as the original concept. */ IConcept ret = concept.getOntology().getConcept(cName); if (ret == null) { ArrayList<IAxiom> ax = new ArrayList<>(); ax.add(Axiom.ClassAssertion(cName)); ax.add(Axiom.SubClass(NS.CORE_DISTANCE, cName)); ax.add(Axiom .AnnotationAssertion(cName, NS.CONCEPT_DEFINITION_PROPERTY, Qualities.DISTANCE .name() .toLowerCase() + " " + ((Concept) concept).getAssertedDefinition())); ax.add(Axiom.AnnotationAssertion(cName, NS.BASE_DECLARATION, "true")); concept.getOntology().define(ax); ret = concept.getOntology().getConcept(cName); } return ret; }
if (!NS.isObject(concept)) { throw new KlabRuntimeException("cannot observe the presence of a quality");
/** * TODO use reasoner for better resolution of physical properties etc. * * @param observable * @return observation type */ public static IConcept getObservationTypeFor(IConcept observable) { if (observable.is(KLAB.c(CORE_PHYSICAL_PROPERTY))) { return KLAB.c(MEASUREMENT); } else if (observable.is(KLAB.c(CORE_PREFERENCE_VALUE))) { return KLAB.c(RANKING); } else if (isClass(observable) || isTrait(observable)) { return KLAB.c(CLASSIFICATION); } else if (isObject(observable)) { return KLAB.c(DIRECT_OBSERVATION); } return KLAB.c(INDIRECT_OBSERVATION); }
public KIMClassificationObserver(KIMScope context, KIMModel model, Observer statement) { super(context, model, statement); isDiscretization = statement.isDiscretizer(); metadataProperty = statement.getMetadataProperty(); authority = statement.getAuthority(); if (observable != null) { // ((ObservableSemantics) observable) // .setType(this.getObservedType(context, this.observable.getType())); if (metadataProperty != null) { try { classification = Types .createClassificationFromMetadata(getObservable() .getType(), metadataProperty); } catch (KlabValidationException e) { context.error(e.getMessage(), lineNumber(statement)); } } else if (statement.getClassification() != null) { classification = new KIMClassification(context .get(KIMScope.Type.CLASSIFICATION), statement .getClassification(), this.observable); } } if (observable != null && NS.isObject(observable.getType())) { context.error("cannot classify an object unless it's 'by' a trait", getFirstLineNumber()); } validate(context); }
.get(KIMScope.Type.MODEL_OBSERVABLE), observable, null); if (!ko.isNothing()) { if (!NS.isObject(ko)) { context.error("observables of instantiator models must be direct: subjects, events or processes", ko .getFirstLineNumber());
if (NS.isObject(this.observable)) { ((ObservableSemantics) this.observable).setModel(null);