From a6b94e9ff249f878de8d5c8d4b96082f153bb93a Mon Sep 17 00:00:00 2001 From: horus Date: Sat, 10 Feb 2018 04:44:35 +0100 Subject: Improves detecting of spirit_type. (crawler) --- crawler/utility.go | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'crawler/utility.go') diff --git a/crawler/utility.go b/crawler/utility.go index 9de7845..17ed47b 100644 --- a/crawler/utility.go +++ b/crawler/utility.go @@ -10,26 +10,36 @@ import ( ) func detect_spirit_type(name string) string { - if strings.Contains(name, "Gin") { + matched, err := regexp.MatchString(`(^|\s)Gin(\s|$)`, name) + if err != nil { + log.Fatal(err) + } + if matched { return "Gin" } - if strings.Contains(name, "Rum") { + matched, err = regexp.MatchString(`(^|\s)Rum(\s|$)`, name) + if err != nil { + log.Fatal(err) + } + if matched { return "Rum" } - if strings.Contains(name, "Vodka") { - return "Wodka" + matched, err = regexp.MatchString(`(^|\s)[VW]odka(\s|$)`, name) + if err != nil { + log.Fatal(err) } - if strings.Contains(name, "Wodka") { + if matched { return "Wodka" } - if strings.Contains(name, "Whisky") { - return "Whisky" + matched, err = regexp.MatchString(`(^|\s)Whiske?y(\s|$)`, name) + if err != nil { + log.Fatal(err) } - if strings.Contains(name, "Whiskey") { + if matched { return "Whisky" } - return "Anderes" + return "Verschiedenes" } func extract_volume(volume string) (float32, error) { -- cgit v1.2.3