當前位置: 首頁>>代碼示例>>Golang>>正文


Golang SnowballWord.ReplaceSuffix方法代碼示例

本文整理匯總了Golang中github.com/kljensen/snowball/snowballword.SnowballWord.ReplaceSuffix方法的典型用法代碼示例。如果您正苦於以下問題:Golang SnowballWord.ReplaceSuffix方法的具體用法?Golang SnowballWord.ReplaceSuffix怎麽用?Golang SnowballWord.ReplaceSuffix使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/kljensen/snowball/snowballword.SnowballWord的用法示例。


在下文中一共展示了SnowballWord.ReplaceSuffix方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: step5

// Step 5 is the stemming of "e" and "l" sufficies
// found in R2.
//
func step5(w *snowballword.SnowballWord) bool {

	// Last rune index = `lri`
	lri := len(w.RS) - 1

	// If R1 is emtpy, R2 is also empty, and we
	// need not do anything in step 5.
	//
	if w.R1start > lri {
		return false
	}

	if w.RS[lri] == 101 {

		// The word ends with "e", which is unicode code point 101.

		// Delete "e" suffix if in R2, or in R1 and not preceded
		// by a short syllable.
		if w.R2start <= lri || !endsShortSyllable(w, lri) {
			w.ReplaceSuffix("e", "", true)
			return true
		}
		return false

	} else if w.R2start <= lri && w.RS[lri] == 108 && lri-1 >= 0 && w.RS[lri-1] == 108 {

		// The word ends in double "l", and the final "l" is
		// in R2. (Note, the unicode code point for "l" is 108.)

		// Delete the second "l".
		w.ReplaceSuffix("l", "", true)
		return true

	}
	return false
}
開發者ID:kljensen,項目名稱:snowball,代碼行數:39,代碼來源:step5.go


注:本文中的github.com/kljensen/snowball/snowballword.SnowballWord.ReplaceSuffix方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。