本文整理汇总了Golang中github.com/kljensen/snowball/snowballword.SnowballWord.FirstPrefix方法的典型用法代码示例。如果您正苦于以下问题:Golang SnowballWord.FirstPrefix方法的具体用法?Golang SnowballWord.FirstPrefix怎么用?Golang SnowballWord.FirstPrefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/kljensen/snowball/snowballword.SnowballWord
的用法示例。
在下文中一共展示了SnowballWord.FirstPrefix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: findRegions
// Find the starting point of the regions R1, R2, & RV
//
func findRegions(word *snowballword.SnowballWord) (r1start, r2start, rvstart int) {
// R1 & R2 are defined in the standard manner.
r1start = romance.VnvSuffix(word, isLowerVowel, 0)
r2start = romance.VnvSuffix(word, isLowerVowel, r1start)
// Set RV, by default, as empty.
rvstart = len(word.RS)
// Handle the three special cases: "par", "col", & "tap"
//
prefix, prefixRunes := word.FirstPrefix("par", "col", "tap")
if prefix != "" {
rvstart = len(prefixRunes)
return
}
// If the word begins with two vowels, RV is the region after the third letter
if len(word.RS) >= 3 && isLowerVowel(word.RS[0]) && isLowerVowel(word.RS[1]) {
rvstart = 3
return
}
// Otherwise the region after the first vowel not at the beginning of the word.
for i := 1; i < len(word.RS); i++ {
if isLowerVowel(word.RS[i]) {
rvstart = i + 1
return
}
}
return
}
示例2: r1r2
// Find the starting point of the two regions R1 & R2.
//
// R1 is the region after the first non-vowel following a vowel,
// or is the null region at the end of the word if there is no
// such non-vowel.
//
// R2 is the region after the first non-vowel following a vowel
// in R1, or is the null region at the end of the word if there
// is no such non-vowel.
//
// See http://snowball.tartarus.org/texts/r1r2.html
//
func r1r2(word *snowballword.SnowballWord) (r1start, r2start int) {
specialPrefix, _ := word.FirstPrefix("gener", "commun", "arsen")
if specialPrefix != "" {
r1start = len(specialPrefix)
} else {
r1start = romance.VnvSuffix(word, isLowerVowel, 0)
}
r2start = romance.VnvSuffix(word, isLowerVowel, r1start)
return
}