/// <summary>Create a polarity from a list of operators in scope</summary>
 protected internal Polarity(IList <Pair <Monotonicity, MonotonicityType> > operatorsInNarrowingScopeOrder)
 {
     if (operatorsInNarrowingScopeOrder.IsEmpty())
     {
         for (byte i = 0; ((sbyte)i) < projectionFunction.Length; ++i)
         {
             projectionFunction[i] = i;
         }
     }
     else
     {
         for (int rel = 0; rel < 7; ++rel)
         {
             NaturalLogicRelation relation = NaturalLogicRelation.ByFixedIndex(rel);
             for (int op = operatorsInNarrowingScopeOrder.Count - 1; op >= 0; --op)
             {
                 relation = Project(relation, operatorsInNarrowingScopeOrder[op].first, operatorsInNarrowingScopeOrder[op].second);
             }
             projectionFunction[rel] = unchecked ((byte)relation.fixedIndex);
         }
     }
 }
Пример #2
0
 /// <summary>Project the given natural logic lexical relation on this word.</summary>
 /// <remarks>
 /// Project the given natural logic lexical relation on this word. So, for example, if we want to go up the
 /// Hypernymy hierarchy (
 /// <see cref="NaturalLogicRelation.ForwardEntailment"/>
 /// ) on this word,
 /// then this function will tell you what relation holds between the new mutated fact and this fact.
 /// </remarks>
 /// <param name="lexicalRelation">The lexical relation we are applying to this word.</param>
 /// <returns>The relation between the mutated sentence and the original sentence.</returns>
 public virtual NaturalLogicRelation ProjectLexicalRelation(NaturalLogicRelation lexicalRelation)
 {
     return(NaturalLogicRelation.ByFixedIndex(projectionFunction[lexicalRelation.fixedIndex]));
 }