Port PR14140 and PR16881 to GO (#17102)

### Summary

Port
https://github.com/infiniflow/ragflow/pull/14140/
https://github.com/infiniflow/ragflow/pull/16881
This commit is contained in:
qinling0210
2026-07-21 17:46:23 +08:00
committed by GitHub
parent 20b760f266
commit 0189ca3700
19 changed files with 570 additions and 152 deletions

View File

@@ -96,6 +96,17 @@ func (a *Analyzer) SetEnablePosition(enablePosition bool) {
C.RAGAnalyzer_SetEnablePosition(a.handle, C.bool(enablePosition))
}
// SetLanguage configures the Snowball stemmer for the given language (e.g. "English", "Dutch").
// Falls back to the English Porter stemmer for unmapped languages.
func (a *Analyzer) SetLanguage(language string) {
if a.handle == nil {
return
}
cLang := C.CString(language)
defer C.free(unsafe.Pointer(cLang))
C.RAGAnalyzer_SetLanguage(a.handle, cLang)
}
// Analyze analyzes the input text and returns all tokens
func (a *Analyzer) Analyze(text string) ([]Token, error) {
if a.handle == nil {