Esempio n. 1
0
        /// <summary>
        /// Matches an arbitrary pattern on the list of facts. If the pattern cannot be matched, an empty dictionary (results) is returned.
        /// </summary>
        /// <param name="pattern">A pattern containing items to be matched and variables, identified by ? for a single word or $? for multiple words, e.g. ?a or $?b. At least one variable must be named in the pattern.</param>
        /// <param name="results">A dictionary that contains the values of the variables, e.g. results["?a"] contains the value of that variable after the pattern matching.</param>
        public static void MatchF(this IEnumerable <string> en, string pattern, out Dictionary <string, string> results)
        {
            var s  = en.Aggregate("", (acc, val) => $"{acc} {val}");
            var em = new ExpertMatchF(s);

            em.Match(pattern, out results);
        }
Esempio n. 2
0
        /// <summary>
        /// Matches an arbitrary pattern on the list. The var_x parameters must be in the order of their appearence in the pattern.
        /// If the pattern cannot be matched, the returned var_x will be empty strings.
        /// </summary>
        /// <param name="pattern">A pattern with four variables.</param>
        /// <param name="var1">The value of the first variable after pattern matching.</param>
        /// <param name="var2">The value of the second variable after pattern matching.</param>
        /// <param name="var3">The value of the third variable after pattern matching.</param>
        /// <param name="var4">The value of the fourth variable after pattern matching.</param>
        public static void MatchF(this IEnumerable <string> en, string pattern, out string var1, out string var2, out string var3, out string var4)
        {
            var em = new ExpertMatchF(en.Aggregate("", (acc, val) => $"{acc} {val}"));

            em.MatchVar(pattern, out var1, out var2, out var3, out var4);
        }