Пример #1
0
 /// <summary>
 /// Stem suffix(es) off an Arabic word. </summary>
 /// <param name="s"> input buffer </param>
 /// <param name="len"> length of input buffer </param>
 /// <returns> new length of input buffer after stemming </returns>
 public virtual int StemSuffix(char[] s, int len)
 {
     for (int i = 0; i < suffixes.Length; i++)
     {
         if (EndsWithCheckLength(s, len, suffixes[i]))
         {
             len = StemmerUtil.DeleteN(s, len - suffixes[i].Length, len, suffixes[i].Length);
         }
     }
     return(len);
 }
Пример #2
0
 /// <summary>
 /// Stem a prefix off an Arabic word. </summary>
 /// <param name="s"> input buffer </param>
 /// <param name="len"> length of input buffer </param>
 /// <returns> new length of input buffer after stemming. </returns>
 public virtual int StemPrefix(char[] s, int len)
 {
     for (int i = 0; i < prefixes.Length; i++)
     {
         if (StartsWithCheckLength(s, len, prefixes[i]))
         {
             return(StemmerUtil.DeleteN(s, 0, len, prefixes[i].Length));
         }
     }
     return(len);
 }
Пример #3
0
 /// <summary>
 /// Stem suffix(es) off an Persian word. </summary>
 /// <param name="s"> input buffer </param>
 /// <param name="len"> length of input buffer </param>
 /// <returns> new length of input buffer after stemming </returns>
 private int StemSuffix(char[] s, int len)
 {
     foreach (var suffix in Suffixes)
     {
         if (EndsWithCheckLength(s, len, suffix))
         {
             len = StemmerUtil.DeleteN(s, len - suffix.Length, len, suffix.Length);
         }
     }
     return(len);
 }
Пример #4
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);
        }
Пример #5
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);
        }