Esempio n. 1
0
        public static string[] GetContexts(string sourceText, string key, int len)
        {
            int           N        = sourceText.Length;
            SuffixArray   suffix   = new SuffixArray(sourceText);
            List <string> contexts = new List <string>();

            for (int i = suffix.Rank(key); i < N && suffix.Select(i).StartsWith(key); i++)
            {
                int from  = Math.Max(0, suffix.Index(i) - len);
                int count = Math.Min(N - 1, key.Length + 2 * len);
                contexts.Add(sourceText.Substring(from, count));
            }
            return(contexts.ToArray());
        }
Esempio n. 2
0
        private static bool TestSuffixArray(string str)
        {
            var array = new SuffixArray.SuffixArray();

            return(AddString(array, str));
        }
Esempio n. 3
0
 private static bool AddChar(SuffixArray.SuffixArray array, char c)
 {
     array.AddCharAtEnd(c);
     return(IsSuffixArrayCorrect(array));
 }