public QGramIndex1(IList <string> strings, int maxlen, int q) { m_Maxlen = maxlen; m_Q = q; var sb = new StringBuilder(strings.Count * maxlen); foreach (string str in strings) { sb.AppendFormat(str.PadRight(maxlen, '\u0000')); } m_Data = sb.ToString(); cmp = new StrCmp(m_Data); MakeSuffixArray(); MakeIndex(); }
public void TestInvalidThai() { String[] tests = { "\u0E44\u0E01\u0E44\u0E01", "\u0E44\u0E01\u0E01\u0E44", "\u0E01\u0E44\u0E01\u0E44", "\u0E01\u0E01\u0E44\u0E44", "\u0E44\u0E44\u0E01\u0E01", "\u0E01\u0E44\u0E44\u0E01", }; RuleBasedCollator collator; StrCmp comparator; try { collator = GetThaiCollator(); comparator = new StrCmp(); } catch (Exception e) { Warnln("could not construct Thai collator"); return; } Array.Sort(tests, comparator); for (int i = 0; i < tests.Length; i++) { for (int j = i + 1; j < tests.Length; j++) { if (collator.Compare(tests[i], tests[j]) > 0) { // inconsistency ordering found! Errln("Inconsistent ordering between strings " + i + " and " + j); } } CollationElementIterator iterator = collator.GetCollationElementIterator(tests[i]); CollationTest.BackAndForth(this, iterator); } }