refactored & audited, real analizer added
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package moonblood
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"strings"
|
||||
|
||||
"git.kplus.net.ua/yevhen/resource-scraper/internal/releaseparser"
|
||||
)
|
||||
|
||||
// Словники токенів лежать у dicts/*.txt — один токен на рядок.
|
||||
// Їх можна редагувати без перекомпіляції логіки (embed тягне їх у бінарник на збірці).
|
||||
|
||||
//go:embed dicts/*.txt
|
||||
var dictFS embed.FS
|
||||
|
||||
func loadDict(name string) map[string]bool {
|
||||
data, err := dictFS.ReadFile("dicts/" + name + ".txt")
|
||||
if err != nil {
|
||||
panic("moonblood: cannot load dictionary " + name + ": " + err.Error())
|
||||
}
|
||||
out := make(map[string]bool)
|
||||
for _, line := range strings.Split(string(data), "\n") {
|
||||
line = strings.ToUpper(strings.TrimSpace(line))
|
||||
if line == "" || strings.HasPrefix(line, "#") {
|
||||
continue
|
||||
}
|
||||
out[line] = true
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
var Profile = releaseparser.GroupProfile{
|
||||
Name: "MOONBLOOD",
|
||||
ExpectedTailOrder: []string{"bit_depth", "resolution", "source", "format", "year", "group"},
|
||||
FormatTokens: loadDict("format"),
|
||||
SourceTokens: loadDict("source"),
|
||||
BitDepthTokens: loadDict("bitdepth"),
|
||||
ResolutionTokens: loadDict("resolution"),
|
||||
LanguageMarkers: loadDict("language"),
|
||||
EditionTokens: loadDict("edition"),
|
||||
}
|
||||
Reference in New Issue
Block a user