/// <summary> /// Adds a suffix to a word /// </summary> /// <param name="word" type="string"> /// <para> /// The word to get the suffix added to /// </para> /// </param> /// <param name="rule" type="NetSpell.SpellChecker.Dictionary.Affix.AffixRule"> /// <para> /// The AffixRule to use when adding the suffix /// </para> /// </param> /// <returns> /// The word with the suffix added /// </returns> public static string AddSuffix(string word, AffixRule rule) { foreach (AffixEntry entry in rule.AffixEntries) { // check that this entry is valid if (word.Length >= entry.ConditionCount) { int passCount = 0; for (int i = 0; i < entry.ConditionCount; i++) { int charCode = (int)word[word.Length - (entry.ConditionCount - i)]; if ((entry.Condition[charCode] & (1 << i)) == (1 << i)) { passCount++; } else { break; } } if (passCount == entry.ConditionCount) { int tempLen = word.Length - entry.StripCharacters.Length; string tempWord = word.Substring(0, tempLen); tempWord += entry.AddCharacters; return(tempWord); } } } return(word); }
/// <summary> /// Determines whether the AffixRuleCollection contains a specific value. /// </summary> /// <param name="value" type="AffixRule"> /// <para> /// The value to locate in the AffixRuleCollection. The value can be a null reference (Nothing in Visual Basic). /// </para> /// </param> /// <returns> /// true if the AffixRuleCollection contains an element with the specified value; otherwise, false. /// </returns> public bool ContainsValue(AffixRule value) { return(innerHash.ContainsValue(value)); }
/// <summary> /// adds an element with the provided key and value to the AffixRuleCollection. /// </summary> /// <param name="key" type="string"> /// <para> /// The string Object to use as the key of the element to add. /// </para> /// </param> /// <param name="value" type="AffixRule"> /// <para> /// The AffixRule Object to use as the value of the element to add. /// </para> /// </param> public void Add(string key, AffixRule value) { innerHash.Add(key, value); }