Example #1
0
        private int RemoveSecondOrderPrefix(char[] text, int length)
        {
            if (StemmerUtil.StartsWith(text, length, "ber"))
            {
                flags |= REMOVED_BER;
                numSyllables--;
                return(StemmerUtil.DeleteN(text, 0, length, 3));
            }

            if (length == 7 && StemmerUtil.StartsWith(text, length, "belajar"))
            {
                flags |= REMOVED_BER;
                numSyllables--;
                return(StemmerUtil.DeleteN(text, 0, length, 3));
            }

            if (StemmerUtil.StartsWith(text, length, "be") && length > 4 && !IsVowel(text[2]) && text[3] == 'e' && text[4] == 'r')
            {
                flags |= REMOVED_BER;
                numSyllables--;
                return(StemmerUtil.DeleteN(text, 0, length, 2));
            }

            if (StemmerUtil.StartsWith(text, length, "per"))
            {
                numSyllables--;
                return(StemmerUtil.DeleteN(text, 0, length, 3));
            }

            if (length == 7 && StemmerUtil.StartsWith(text, length, "pelajar"))
            {
                numSyllables--;
                return(StemmerUtil.DeleteN(text, 0, length, 3));
            }

            if (StemmerUtil.StartsWith(text, length, "pe"))
            {
                flags |= REMOVED_PE;
                numSyllables--;
                return(StemmerUtil.DeleteN(text, 0, length, 2));
            }

            return(length);
        }
Example #2
0
        private int RemoveFirstOrderPrefix(char[] text, int length)
        {
            if (StemmerUtil.StartsWith(text, length, "meng"))
            {
                flags |= REMOVED_MENG;
                numSyllables--;
                return(StemmerUtil.DeleteN(text, 0, length, 4));
            }

            if (StemmerUtil.StartsWith(text, length, "meny") && length > 4 && IsVowel(text[4]))
            {
                flags  |= REMOVED_MENG;
                text[3] = 's';
                numSyllables--;
                return(StemmerUtil.DeleteN(text, 0, length, 3));
            }

            if (StemmerUtil.StartsWith(text, length, "men"))
            {
                flags |= REMOVED_MENG;
                numSyllables--;
                return(StemmerUtil.DeleteN(text, 0, length, 3));
            }

            if (StemmerUtil.StartsWith(text, length, "mem"))
            {
                flags |= REMOVED_MENG;
                numSyllables--;
                return(StemmerUtil.DeleteN(text, 0, length, 3));
            }

            if (StemmerUtil.StartsWith(text, length, "me"))
            {
                flags |= REMOVED_MENG;
                numSyllables--;
                return(StemmerUtil.DeleteN(text, 0, length, 2));
            }

            if (StemmerUtil.StartsWith(text, length, "peng"))
            {
                flags |= REMOVED_PENG;
                numSyllables--;
                return(StemmerUtil.DeleteN(text, 0, length, 4));
            }

            if (StemmerUtil.StartsWith(text, length, "peny") && length > 4 && IsVowel(text[4]))
            {
                flags  |= REMOVED_PENG;
                text[3] = 's';
                numSyllables--;
                return(StemmerUtil.DeleteN(text, 0, length, 3));
            }

            if (StemmerUtil.StartsWith(text, length, "peny"))
            {
                flags |= REMOVED_PENG;
                numSyllables--;
                return(StemmerUtil.DeleteN(text, 0, length, 4));
            }

            if (StemmerUtil.StartsWith(text, length, "pen") && length > 3 && IsVowel(text[3]))
            {
                flags  |= REMOVED_PENG;
                text[2] = 't';
                numSyllables--;
                return(StemmerUtil.DeleteN(text, 0, length, 2));
            }

            if (StemmerUtil.StartsWith(text, length, "pen"))
            {
                flags |= REMOVED_PENG;
                numSyllables--;
                return(StemmerUtil.DeleteN(text, 0, length, 3));
            }

            if (StemmerUtil.StartsWith(text, length, "pem"))
            {
                flags |= REMOVED_PENG;
                numSyllables--;
                return(StemmerUtil.DeleteN(text, 0, length, 3));
            }

            if (StemmerUtil.StartsWith(text, length, "di"))
            {
                flags |= REMOVED_DI;
                numSyllables--;
                return(StemmerUtil.DeleteN(text, 0, length, 2));
            }

            if (StemmerUtil.StartsWith(text, length, "ter"))
            {
                flags |= REMOVED_TER;
                numSyllables--;
                return(StemmerUtil.DeleteN(text, 0, length, 3));
            }

            if (StemmerUtil.StartsWith(text, length, "ke"))
            {
                flags |= REMOVED_KE;
                numSyllables--;
                return(StemmerUtil.DeleteN(text, 0, length, 2));
            }

            return(length);
        }