Esempio n. 1
0
        private CharsRef NewStem(char[] buffer, int length, Int32sRef forms, int formID)
        {
            string exception;

            if (dictionary.hasStemExceptions)
            {
                int exceptionID = forms.Int32s[forms.Offset + formID + 1];
                if (exceptionID > 0)
                {
                    exception = dictionary.GetStemException(exceptionID);
                }
                else
                {
                    exception = null;
                }
            }
            else
            {
                exception = null;
            }

            if (dictionary.needsOutputCleaning)
            {
                scratchSegment.Length = 0;
                if (exception != null)
                {
                    scratchSegment.Append(exception);
                }
                else
                {
                    scratchSegment.Append(buffer, 0, length);
                }
                try
                {
                    Dictionary.ApplyMappings(dictionary.oconv, scratchSegment);
                }
                catch (Exception bogus) when(bogus.IsIOException())
                {
                    throw RuntimeException.Create(bogus);
                }
                char[] cleaned = new char[scratchSegment.Length];
                scratchSegment.CopyTo(0, cleaned, 0, cleaned.Length);
                return(new CharsRef(cleaned, 0, cleaned.Length));
            }
            else
            {
                if (exception != null)
                {
                    return(new CharsRef(exception));
                }
                else
                {
                    return(new CharsRef(buffer, 0, length));
                }
            }
        }