示例#1
0
 public void linkConcept(clsConcept concept)
 {
     if (!_concepts.Contains(concept))
     {
         _concepts.Add(concept);
         concept.connectPattern(this);
     }
 }
示例#2
0
        /*********************************************************************
        * 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);
            }
        }
示例#3
0
 public clsPattern(string text, clsConcept concept = null)
 {
     this._text = text;
     if (concept == null)
     {
         concept = new clsConcept(this);
     }
     linkConcept(concept);
 }
示例#4
0
        // 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);
        }
示例#5
0
        // 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);
        }
示例#6
0
 // 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);
 }
示例#7
0
        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);
        }
示例#8
0
        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);
        }
示例#9
0
 // 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;
 }