Пример #1
0
 /// <summary>
 /// Returns a new (deterministic and minimal) automaton that accepts the union
 /// of the given collection of <seealso cref="BytesRef"/>s representing UTF-8 encoded
 /// strings.
 /// </summary>
 /// <param name="utf8Strings">
 ///          The input strings, UTF-8 encoded. The collection must be in sorted
 ///          order.
 /// </param>
 /// <returns> An <seealso cref="Automaton"/> accepting all input strings. The resulting
 ///         automaton is codepoint based (full unicode codepoints on
 ///         transitions). </returns>
 public static Automaton MakeStringUnion(ICollection <BytesRef> utf8Strings)
 {
     if (utf8Strings.Count == 0)
     {
         return(MakeEmpty());
     }
     else
     {
         return(DaciukMihovAutomatonBuilder.Build(utf8Strings));
     }
 }
Пример #2
0
        private CompiledAutomaton Build(params string[] strings)
        {
            List <BytesRef> terms = new List <BytesRef>();

            foreach (string s in strings)
            {
                terms.Add(new BytesRef(s));
            }
            terms.Sort();
            Automaton a = DaciukMihovAutomatonBuilder.Build(terms);

            return(new CompiledAutomaton(a, true, false));
        }