// Remove adjectival endings and return true if one was removed. // func removeAdjectivalEnding(word *snowballword.SnowballWord) bool { // Remove adjectival endings. Start by looking for // an adjective ending. // suffix, _ := word.RemoveFirstSuffixIn(word.RVstart, "ими", "ыми", "его", "ого", "ему", "ому", "ее", "ие", "ые", "ое", "ей", "ий", "ый", "ой", "ем", "им", "ым", "ом", "их", "ых", "ую", "юю", "ая", "яя", "ою", "ею", ) if suffix != "" { // We found an adjective ending. Remove optional participle endings. // newSuffix, newSuffixRunes := word.FirstSuffixIn(word.RVstart, len(word.RS), "ивш", "ывш", "ующ", "ем", "нн", "вш", "ющ", "щ", ) switch newSuffix { case "ем", "нн", "вш", "ющ", "щ": // These are "Group 1" participle endings. // Group 1 endings must follow а (a) or я (ia) in RV. if precededByARinRV(word, len(newSuffixRunes)) == false { newSuffix = "" } } if newSuffix != "" { word.RemoveLastNRunes(len(newSuffixRunes)) } return true } return false }
// Step 2 is the removal of the "и" suffix. // func step2(word *snowballword.SnowballWord) bool { suffix, _ := word.RemoveFirstSuffixIn(word.RVstart, "и") if suffix != "" { return true } return false }
// Step 3 is the removal of the derivational suffix. // func step3(word *snowballword.SnowballWord) bool { // Search for a DERIVATIONAL ending in R2 (i.e. the entire // ending must lie in R2), and if one is found, remove it. suffix, _ := word.RemoveFirstSuffixIn(word.R2start, "ост", "ость") if suffix != "" { return true } return false }
// Step 1 is the removal of standard suffixes, all of which must // occur in RV. // // // Search for a PERFECTIVE GERUND ending. If one is found remove it, and // that is then the end of step 1. Otherwise try and remove a REFLEXIVE // ending, and then search in turn for (1) an ADJECTIVAL, (2) a VERB or // (3) a NOUN ending. As soon as one of the endings (1) to (3) is found // remove it, and terminate step 1. // func step1(word *snowballword.SnowballWord) bool { // `stop` will be used to signal early termination var stop bool // Search for a PERFECTIVE GERUND ending stop = removePerfectiveGerundEnding(word) if stop { return true } // Next remove reflexive endings word.RemoveFirstSuffixIn(word.RVstart, "ся", "сь") // Next remove adjectival endings stop = removeAdjectivalEnding(word) if stop { return true } // Next remove verb endings stop = removeVerbEnding(word) if stop { return true } // Next remove noun endings suffix, _ := word.RemoveFirstSuffixIn(word.RVstart, "иями", "ями", "иях", "иям", "ием", "ией", "ами", "ях", "ям", "ья", "ью", "ье", "ом", "ой", "ов", "ия", "ию", "ий", "ии", "ие", "ем", "ей", "еи", "ев", "ах", "ам", "я", "ю", "ь", "ы", "у", "о", "й", "и", "е", "а", ) if suffix != "" { return true } return false }