feat: add content filter and code processing module (v0.3.0)
- Add content filter module (internal/content/) - Implement basic character filtering (control chars, line breaks, symbols) - Implement code block and inline code detection - Implement comment detection for 30+ languages (JS/Python/Go/HTML/etc) - Add go-enry dependency for intelligent language detection - Add SkipKeywords config option (default: TODO/FIXME/HACK/XXX/etc) - Integrate content processing into Translator - Update config.yaml with skip_keywords
This commit is contained in:
@@ -23,6 +23,9 @@ type Config struct {
|
||||
|
||||
// Prompt配置
|
||||
Prompts map[string]string `yaml:"prompts"`
|
||||
|
||||
// 内容过滤配置
|
||||
SkipKeywords []string `yaml:"skip_keywords"` // 不翻译的关键词
|
||||
}
|
||||
|
||||
// ProviderConfig 厂商配置
|
||||
@@ -121,6 +124,16 @@ func (c *Config) setDefaults() {
|
||||
if c.Prompts == nil {
|
||||
c.Prompts = make(map[string]string)
|
||||
}
|
||||
|
||||
// 设置默认关键词
|
||||
if c.SkipKeywords == nil {
|
||||
c.SkipKeywords = []string{
|
||||
"TODO", "FIXME", "HACK", "XXX", "NOTE",
|
||||
"BUG", "WARN", "IMPORTANT", "TODO:",
|
||||
"FIXME:", "HACK:", "XXX:", "NOTE:",
|
||||
"BUG:", "WARN:", "IMPORTANT:",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// GetProviderConfig 获取指定厂商的配置
|
||||
|
||||
Reference in New Issue
Block a user