本文整理匯總了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
}