/// <summary>
        /// Returns the LUB of the two kinds in the kind lattice
        /// </summary>
        public static CommonNoun LeastUpperBound(CommonNoun a, CommonNoun b)
        {
            if (a == null)
            {
                return(b);
            }
            if (b == null)
            {
                return(a);
            }

            if (a.IsSuperKindOf(b))
            {
                return(a);
            }

            foreach (var super in a.Superkinds)
            {
                var lub = LeastUpperBound(super, b);
                if (lub != null)
                {
                    return(lub);
                }
            }

            return(null);
        }
Example #2
0
 internal Part(Ontology ontology, string[] name, int count, CommonNoun kind, IEnumerable <MonadicConceptLiteral> modifiers) : base(ontology, name)
 {
     Name = name;
     Ontology.AllParts[name] = this;
     Count     = count;
     Kind      = kind;
     Modifiers = modifiers.ToArray();
 }
Example #3
0
 /// <summary>
 /// True if this is an adjective that can apply to an individual of the specified kind.
 /// </summary>
 /// <param name="noun">Noun representing a kind of object</param>
 /// <returns>True if this adjective is allowed to apply to objects of the specified kind.</returns>
 public bool RelevantTo(CommonNoun noun)
 {
     if (noun.RelevantAdjectives.Contains(this))
     {
         return(true);
     }
     return(noun.Superkinds.Any(RelevantTo));
 }
Example #4
0
 internal Test(CommonNoun noun, IEnumerable <MonadicConceptLiteral> modifiers, bool shouldExist, string succeedMessage, string failMessage)
 {
     Noun           = noun;
     ShouldExist    = shouldExist;
     SucceedMessage = succeedMessage;
     FailMessage    = failMessage;
     Modifiers      = modifiers.ToArray();
 }
 /// <summary>
 /// Ensure super is an immediate super-kind of this kind.
 /// Does nothing if it is already a super-kind.
 /// </summary>
 public void DeclareSuperclass(CommonNoun super, float relativeFrequency = 1)
 {
     if (!Superkinds.Contains(super))
     {
         Superkinds.Add(super);
         super.Subkinds.Add(this);
         super.SubkindFrequencies.Add(relativeFrequency);
     }
 }
 /// <summary>
 /// Returns the LUB of the three kinds in the kind lattice
 /// </summary>
 public static CommonNoun LeastUpperBound(CommonNoun a, CommonNoun b, CommonNoun c) =>
 a == null?LeastUpperBound(b, c) : LeastUpperBound(a, LeastUpperBound(b, c));
 /// <summary>
 /// This is a subkind of the specified superkind
 /// </summary>
 public bool IsSubKindOf(CommonNoun super) => super.IsSuperKindOf(this);
 /// <summary>
 /// This is a superkind of the specified subkind
 /// </summary>
 public bool IsSuperKindOf(CommonNoun sub) =>
 sub == this ||                          // A is a super kind of A
 Subkinds.Any(s => s.IsSuperKindOf(sub));
 /// <summary>
 /// True if this is an immediate subkind of the specified superkind.
 /// </summary>
 public bool IsImmediateSubKindOf(CommonNoun super) => Superkinds.Contains(super);
Example #10
0
 /// <summary>
 /// True if this is an immediate superkind of the specified subkind.
 /// </summary>
 public bool IsImmediateSuperKindOf(CommonNoun sub) => Subkinds.Contains(sub);