Beispiel #1
0
 private void Verify <T>(FST <T> fst, string[] inputs, T[] outputs)
 {
     for (int i = 0; i < inputs.Length; ++i)
     {
         Assert.True(fst.TryMatch(inputs[i], out var v));
         Assert.Equal(outputs[i], v);
     }
 }
        public DictionaryTerm GetTerm(string term)
        {
            int offset = 0;

            if (!fst.TryMatch(term, out offset))
            {
                throw new InvalidOperationException();
            }

            if (offset < 0)
            {
                throw new InvalidOperationException();
            }

            return(new DictionaryTerm(term, new PostingListAddress(offset)));
        }
 private void Validate(FST <int> fst)
 {
     for (int i = 0; i < input.Count; ++i)
     {
         if (fst.TryMatch(input[i], out var offset))
         {
             if (offset != output[i])
             {
                 throw new Exception($"Bad output {input[i]} {offset} != {output[i]}");
             }
         }
         else
         {
             throw new Exception($"No match {input[i]}");
         }
     }
 }