Beispiel #1
0
    /// <summary>
    /// Attempts to match tokens to the name of a known monadic concept (CommonNoun or Adjective)
    /// </summary>
    /// <returns>The concept, if successful, or null</returns>
    public static TReferent MatchTrie <TReferent>(TokenTrie <TReferent> trie)
        where TReferent : Referent
    {
        var old     = State;
        var concept = trie.Lookup(Input, ref Current.CurrentTokenIndex);

        if (concept != null)
        {
            return(concept);
        }
        ResetTo(old);
        return(null);
    }
 /// <summary>
 /// Search trie for a monadic concept named by some substring of tokens starting at the specified index.
 /// Updates index as it searches
 /// </summary>
 /// <param name="tokens">Sequence of tokens to search</param>
 /// <param name="index">Position within token sequence</param>
 /// <returns>Concept, if found, otherwise null.</returns>
 public static MonadicConcept Lookup(IList <string> tokens, ref int index) => Trie.Lookup(tokens, ref index);