public virtual void TestSimpleDictionary() { using (System.IO.Stream affixStream = this.GetType().getResourceAsStream("simple.aff")) { using (System.IO.Stream dictStream = this.GetType().getResourceAsStream("simple.dic")) { Dictionary dictionary = new Dictionary(affixStream, dictStream); assertEquals(3, dictionary.LookupSuffix(new char[] { 'e' }, 0, 1).Length); assertEquals(1, dictionary.LookupPrefix(new char[] { 's' }, 0, 1).Length); IntsRef ordList = dictionary.LookupWord(new char[] { 'o', 'l', 'r' }, 0, 3); assertNotNull(ordList); assertEquals(1, ordList.Length); BytesRef @ref = new BytesRef(); dictionary.flagLookup.Get(ordList.Ints[0], @ref); char[] flags = Dictionary.DecodeFlags(@ref); assertEquals(1, flags.Length); ordList = dictionary.LookupWord(new char[] { 'l', 'u', 'c', 'e', 'n' }, 0, 5); assertNotNull(ordList); assertEquals(1, ordList.Length); dictionary.flagLookup.Get(ordList.Ints[0], @ref); flags = Dictionary.DecodeFlags(@ref); assertEquals(1, flags.Length); } } }
public virtual void TestCompressedBeforeSetDictionary() { using (System.IO.Stream affixStream = this.GetType().getResourceAsStream("compressed-before-set.aff")) { using (System.IO.Stream dictStream = this.GetType().getResourceAsStream("compressed.dic")) { Dictionary dictionary = new Dictionary(affixStream, dictStream); assertEquals(3, dictionary.LookupSuffix(new char[] { 'e' }, 0, 1).Length); assertEquals(1, dictionary.LookupPrefix(new char[] { 's' }, 0, 1).Length); IntsRef ordList = dictionary.LookupWord(new char[] { 'o', 'l', 'r' }, 0, 3); BytesRef @ref = new BytesRef(); dictionary.flagLookup.Get(ordList.Ints[0], @ref); char[] flags = Dictionary.DecodeFlags(@ref); assertEquals(1, flags.Length); } } }