/// <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); }
/// <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); }
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); }
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); }