public void linkConcept(clsConcept concept) { if (!_concepts.Contains(concept)) { _concepts.Add(concept); concept.connectPattern(this); } }
/********************************************************************* * calls for general learning *********************************************************************/ public void learn(clsConcept subjectConcept, clsConcept typeConcept, clsConcept objectConcept) { clsRelationship relationship = subjectConcept.objectRelationship(typeConcept, objectConcept); if (relationship == null) { subjectConcept.connectObject(typeConcept, objectConcept); } }
public clsPattern(string text, clsConcept concept = null) { this._text = text; if (concept == null) { concept = new clsConcept(this); } linkConcept(concept); }
// make a parent relationship between this object and a subject (subject is object) public clsRelationship connectObject(clsConcept typeConcept, clsConcept objectConcept) { clsRelationship relationship = this.objectRelationship(typeConcept, objectConcept); if (relationship == null) { relationship = new clsRelationship(this, typeConcept, objectConcept); _objectRelationships.Add(relationship); objectConcept.connectSubject(relationship); } return(relationship); }
// make a child relationship between this subject and an object (subject is object) public clsRelationship connectSubject(clsConcept typeConcept, clsConcept subjectConcept) { clsRelationship relationship = this.subjectRelationship(typeConcept, subjectConcept); if (relationship == null) { relationship = new clsRelationship(subjectConcept, typeConcept, this); _subjectRelationships.Add(relationship); subjectConcept.connectObject(relationship); } return(relationship); }
// recall a single child relationship of this type to the specified concept public clsRelationship objectRelationship(clsConcept typeConcept, clsConcept objectConcept) { // get all relationships of this type foreach (clsRelationship relationship in this._objectRelationships) { if ((relationship.objectConcept == objectConcept) && (relationship.typeConcept == typeConcept)) { return(relationship); } } return(null); }
public List <clsRelationship> subjectRelationships(clsConcept typeConcept = null, clsConcept subjectConcept = null) { List <clsRelationship> relationships = new List <clsRelationship>(); foreach (clsConcept _concept in _concepts) { List <clsRelationship> subRelationships = _concept.subjectRelationships(typeConcept, subjectConcept); foreach (clsRelationship subRelationship in subRelationships) { relationships.Add(subRelationship); } } return(relationships); }
public List <clsRelationship> subjectRelationships(clsConcept typeConcept = null, clsConcept subjectConcept = null) { List <clsRelationship> relationships = new List <clsRelationship>(); foreach (clsRelationship relationship in _subjectRelationships) { if ((subjectConcept == null) || (subjectConcept == relationship.subjectConcept)) { if ((typeConcept == null) || (typeConcept == relationship.typeConcept)) { relationships.Add(relationship); } } } return(relationships); }
// examples // David is Great (Subject Type Object) // David is a Human (Object Type Subject) public clsRelationship(clsConcept subjectConcept, clsConcept typeConcept, clsConcept objectConcept) { this.subjectConcept = subjectConcept; this.typeConcept = typeConcept; this.objectConcept = objectConcept; }