Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 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();
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 5
0
 /// <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);
     }
 }
Ejemplo n.º 6
0
 /// <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));
Ejemplo n.º 7
0
 /// <summary>
 /// This is a subkind of the specified superkind
 /// </summary>
 public bool IsSubKindOf(CommonNoun super) => super.IsSuperKindOf(this);
Ejemplo n.º 8
0
 /// <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));
Ejemplo n.º 9
0
 /// <summary>
 /// True if this is an immediate subkind of the specified superkind.
 /// </summary>
 public bool IsImmediateSubKindOf(CommonNoun super) => Superkinds.Contains(super);
Ejemplo n.º 10
0
 /// <summary>
 /// True if this is an immediate superkind of the specified subkind.
 /// </summary>
 public bool IsImmediateSuperKindOf(CommonNoun sub) => Subkinds.Contains(sub);