public List<CharsRef> stem(char word[], int length) {if (dictionary.needsInputCleaning) {scratchSegment.setLength(0);scratchSegment.append(word, 0, length);CharSequence cleaned = dictionary.cleanInput(scratchSegment, segment);scratchBuffer = ArrayUtil.grow(scratchBuffer, cleaned.length());length = segment.length();segment.getChars(0, length, scratchBuffer, 0);word = scratchBuffer;}int caseType = caseOf(word, length);if (caseType == UPPER_CASE) {caseFoldTitle(word, length);caseFoldLower(titleBuffer, length);List<CharsRef> list = doStem(word, length, false);list.addAll(doStem(titleBuffer, length, true));list.addAll(doStem(lowerBuffer, length, true));return list;} else if (caseType == TITLE_CASE) {caseFoldLower(word, length);List<CharsRef> list = doStem(word, length, false);list.addAll(doStem(lowerBuffer, length, true));return list;} else {return doStem(word, length, false);}}

public IList<CharsRef> Stem(char[] word, int length){if (dictionary.needsInputCleaning){scratchSegment.Length = 0;scratchSegment.Append(word, 0, length);string cleaned = dictionary.CleanInput(scratchSegment.ToString(), segment);scratchBuffer = ArrayUtil.Grow(scratchBuffer, cleaned.Length);length = segment.Length;segment.CopyTo(0, scratchBuffer, 0, length);word = scratchBuffer;}List<CharsRef> stems = new List<CharsRef>();Int32sRef forms = dictionary.LookupWord(word, 0, length);if (forms != null){for (int i = 0; i < forms.Length; i++){stems.Add(NewStem(word, length));}}stems.AddRange(Stem(word, length, -1, -1, -1, 0, true, true, false, false));return stems;}
