@Override public boolean select(IKnowledge o) { return NS.isQuality(o); } };
public Collection<IKnowledge> getAllFundamentalQualities() { ArrayList<IKnowledge> ret = new ArrayList<>(); IOntology o = (KLAB.KM).getOntology(_coreOntology); if (o != null) { for (IConcept c : ((Ontology) o).getTopConcepts(true)) { if (NS.isQuality(c)) { ret.add(c); } } } return ret; }
protected static void createOutputStates(IDirectObservation context, IModel model) throws KlabException { for (IObservableSemantics obs : model.getObservables()) { if (NS.isQuality(obs)) { ((IActiveDirectObservation) context).getState(obs); } } }
public ResolutionScope forObservable(IObservableSemantics observable, Collection<String> scenarios) { ResolutionScope ret = new ResolutionScope(this, Type.OBSERVABLE, subject); ret.observable = observable; if (scenarios != null && scenarios.size() > 0) { ret.scenarios.clear(); ret.scenarios.addAll(scenarios); } ret.model = null; ret.attributes = mergeTraits(this.attributes, observable); // needs this as it's an entry point for the resolver and the subject // wasn't // known. // ret.resolutionStrategy = new ResolutionStrategy(subject); if (NS.isQuality(observable) || NS.isTrait(observable)) { // force explanation, which may be false from upstream context. ret.isExplanatoryModel = true; } // trace(ret); return ret; }
public ResolutionScope forObservable(IObservableSemantics observable) { ResolutionScope ret = new ResolutionScope(this, Type.OBSERVABLE, subject); ret.observable = observable; ret.attributes = mergeTraits(this.attributes, observable); ret.model = null; if (NS.isQuality(observable) || NS.isTrait(observable)) { // force explanation, which may be false from upstream context. ret.isExplanatoryModel = true; } // trace(ret); return ret; }
@Override protected IConcept getObservedType(KIMScope context, IConcept knowledge) { if (!NS.isQuality(knowledge)) { context.error("rankings must observe qualities", this.getFirstLineNumber()); } return super.getObservedType(context, knowledge); }
@Override public IState getStaticState(IObservableSemantics obs) throws KlabException { for (IState s : states) { if (obs.equals(s.getObservable().getSemantics())) { return s; } } if (!NS.isQuality(obs)) { throw new KlabValidationException("cannot create a state for a non-quality: " + obs.getType()); } // if (Observables.getInherentType(observable.getType()) == null) { // obs = ((ObservableSemantics) obs).withInherentType(this.getObservable().getSemantics().getType()); // } IState ret = States.createStatic(obs, this); states.add(ret); return ret; }
@Override public IState getState(IObservableSemantics obs, Object... data) throws KlabException { for (IState s : states) { if (obs.equals(s.getObservable().getSemantics())) { return s; } } if (!NS.isQuality(obs)) { throw new KlabValidationException("cannot create a state for a non-quality: " + obs.getType()); } // if (obs.getInherentType() == null) { // obs = ((Observable) obs).withInherentType(this.getObservable().getType()); // } IState ret = States.create(obs, this); states.add(ret); return ret; }
} else if (NS.isQuality(obs) /* FIXME should not have traits */|| NS.isTrait(obs)) { if (last == null) { last = new ArrayList<>();
public static IConcept makeProportion(IConcept concept, IConcept comparison) { if (!(NS.isQuality(concept) || NS.isTrait(concept)) && !NS.isQuality(comparison)) { return null; } String cName = cleanInternalId(concept.getLocalName()) + "ProportionIn" + cleanInternalId(comparison.getLocalName()); 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_PROPORTION, cName)); ax.add(Axiom .AnnotationAssertion(cName, NS.CONCEPT_DEFINITION_PROPERTY, Qualities.PROPORTION .name().toLowerCase() + " " + ((Concept) concept).getAssertedDefinition() + (comparison == null ? "" : ("," + ((Concept) comparison) .getAssertedDefinition())))); ax.add(Axiom.AnnotationAssertion(cName, NS.BASE_DECLARATION, "true")); concept.getOntology().define(ax); ret = concept.getOntology().getConcept(cName); } return ret; }
public static IConcept makeRatio(IConcept concept, IConcept comparison) { /* * accept only two qualities of the same physical nature (TODO) */ if (!(NS.isQuality(concept) || NS.isTrait(concept)) || !NS.isQuality(comparison)) { return null; } String cName = cleanInternalId(concept.getLocalName()) + "To" + cleanInternalId(comparison.getLocalName()) + "Ratio"; 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_RATIO, cName)); ax.add(Axiom .AnnotationAssertion(cName, NS.CONCEPT_DEFINITION_PROPERTY, Qualities.RATIO .name() .toLowerCase() + " " + ((Concept) concept).getAssertedDefinition() + (comparison == null ? "" : ("," + ((Concept) comparison) .getAssertedDefinition())))); ax.add(Axiom.AnnotationAssertion(cName, NS.BASE_DECLARATION, "true")); concept.getOntology().define(ax); ret = concept.getOntology().getConcept(cName); } return ret; }
public static IConcept makeAssessment(IConcept concept) { String cName = cleanInternalId(concept.getLocalName()) + "Assessment"; if (!NS.isQuality(concept)) { return null; } /* * make a ConceptAssessment 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_ASSESSMENT, cName)); ax.add(Axiom .AnnotationAssertion(cName, NS.CONCEPT_DEFINITION_PROPERTY, Qualities.ASSESSMENT .name() .toLowerCase() + " " + ((Concept) concept).getAssertedDefinition())); ax.add(Axiom.AnnotationAssertion(cName, NS.BASE_DECLARATION, "true")); concept.getOntology().define(ax); ret = concept.getOntology().getConcept(cName); OWL.restrictSome(ret, KLAB.p(NS.OBSERVES_PROPERTY), concept); } return ret; }
private IConcept chooseDirectAccessorType(IKnowledge ob) throws KlabValidationException { if (NS.isQuality(ob)) { return KLAB.c(NS.STATE_CONTEXTUALIZER); } else if (NS.isThing(ob)) { return KLAB.c(NS.SUBJECT_CONTEXTUALIZER); } else if (NS.isProcess(ob)) { return KLAB.c(NS.PROCESS_CONTEXTUALIZER); } else if (NS.isEvent(ob)) { return KLAB.c(NS.EVENT_INSTANTIATOR); } throw new KlabValidationException("subject model has observable that doesn't match any accessor type"); }
@Override public boolean match(IConcept o) { if (namespace != null && !o.getConceptSpace().equals(namespace.getId())) { return false; } if (match != null && !o.is(match)) { return false; } if (isAdmitted(SearchType.CONCEPT)) { return true; } boolean isProcess = NS.isProcess(o); if (isProcess && !isAdmitted(SearchType.PROCESS)) { return false; } boolean isTrait = NS.isTrait(o); if (isTrait && !isAdmitted(SearchType.TRAIT)) { return false; } boolean isQuality = NS.isQuality(o); if (isQuality && !isAdmitted(SearchType.QUALITY)) { return false; } return true; }
static IObserver defineObserver(KIMScope context, KIMModel model, ObservationGeneratorSwitch statement) { if (statement.getMediated() != null) { if (statement.getMediated().size() == 1 && statement.getMediated().get(0).getWhen() == null) { return defineObserver(context .get(KIMScope.Type.OBSERVER), model, statement.getMediated() .get(0) .getObservable()); } else { List<Pair<IObserver, IExpression>> observers = new ArrayList<>(); for (ObservationGeneratorConditional oc : statement.getMediated()) { IObserver cobs = defineObserver(context .get(KIMScope.Type.OBSERVER), model, oc .getObservable()); if (cobs.getObservable() != null && !(NS.isQuality(cobs.getObservable()))) { context.error("the observable in any observer must be a quality", lineNumber(statement)); } IExpression cexp = new KIMExpression(context .get(KIMScope.Type.OBSERVER_CONDITIONAL_EXPRESSION), model, cobs, oc .getWhen()); observers.add(new Pair<>(cobs, cexp)); } return new KIMConditional(context .get(KIMScope.Type.OBSERVER_CONDITIONAL), model, observers, statement); } } return null; }
} else if (NS.isQuality(original)) {
if (!NS.isQuality(obs)) { throw new KlabValidationException("cannot create a state for a non-quality: " + obs.getType());
if (!NS.isQuality(obs)) { throw new KlabValidationException("cannot create a state for a non-quality: " + obs.getType());
if (!NS.isQuality(obs) && !NS.isTrait(obs)) { throw new KlabValidationException("cannot create a state for a non-quality: " + obs.getType());
if (NS.isQuality(concept) && distributed) {