32 lines
769 B
Go
32 lines
769 B
Go
package config
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/hireme/hireme/internal/filter"
|
|
"gopkg.in/yaml.v3"
|
|
)
|
|
|
|
type FilterConfig struct {
|
|
HardKeywords []string `yaml:"hard_keywords"`
|
|
AnalysisThreshold float64 `yaml:"analysis_threshold"`
|
|
ScoringWeights []filter.KeywordWeight `yaml:"scoring_weights"`
|
|
}
|
|
|
|
func LoadFilterConfig(path string) (*FilterConfig, error) {
|
|
data, err := os.ReadFile(path)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to read filter config file %s: %w", path, err)
|
|
}
|
|
|
|
var cfg FilterConfig
|
|
// Default threshold if not specified
|
|
cfg.AnalysisThreshold = 25.0
|
|
if err := yaml.Unmarshal(data, &cfg); err != nil {
|
|
return nil, fmt.Errorf("failed to unmarshal filter config: %w", err)
|
|
}
|
|
|
|
return &cfg, nil
|
|
}
|