diff --git a/build/cache/geocache.json b/build/cache/geocache.json index 4de1b42..ce7c10a 100644 --- a/build/cache/geocache.json +++ b/build/cache/geocache.json @@ -951,6 +951,10 @@ "Latitude": 35.4646358, "Longitude": 139.619518 }, + "1-12-4 Minamisaiwai Nishi-ku Yokohama Kanagawa 神奈川県\n \n \n \n \n 横浜市西区\n \n \n 南幸\n \n 1-12-4\n \n \n TK横浜西口ビル 4F": { + "Latitude": 35.4646494, + "Longitude": 139.6194301 + }, "1-12-5 Mizonokuchi Takatsu-ku Kawasaki Kanagawa": { "Latitude": 35.6005732, "Longitude": 139.6121676 @@ -1211,6 +1215,10 @@ "Latitude": 35.5207258, "Longitude": 139.6321589 }, + "1-17-1 Okurayama Kohoku-ku Yokohama Kanagawa 神奈川県\n \n \n \n \n 横浜市港北区\n \n \n 大倉山\n \n 1-17-1\n \n \n 2F": { + "Latitude": 35.5213991, + "Longitude": 139.6302162 + }, "1-17-10 Chuo Ebina Kanagawa": { "Latitude": 35.4540087, "Longitude": 139.3954582 @@ -3359,6 +3367,10 @@ "Latitude": 35.4425774, "Longitude": 139.6458973 }, + "138 Yamashitacho Naka-ku Yokohama Kanagawa 神奈川県\n \n \n \n \n 横浜市中区\n \n \n 山下町\n \n 138": { + "Latitude": 35.4439672, + "Longitude": 139.650749 + }, "138 Yamashitacho, Naka-ku Yokohama, Kanagawa Prefecture": { "Latitude": 35.4425774, "Longitude": 139.6458973 @@ -4115,6 +4127,10 @@ "Latitude": 35.4625139, "Longitude": 139.6224983 }, + "2-10-28 Takashima Nishi-ku Yokohama Kanagawa 神奈川県\n \n \n \n \n 横浜市西区\n \n \n 高島\n \n 2-10-28\n \n \n 双洋ビル 1F": { + "Latitude": 35.4624287, + "Longitude": 139.6224378 + }, "2-10-4 Minamirinkan Yamato 242-0006, Kanagawa Prefecture": { "Latitude": 35.4961298, "Longitude": 139.4466723 @@ -5911,6 +5927,10 @@ "Latitude": 35.44085159999999, "Longitude": 139.3636416 }, + "2-6-24 Nakacho Atsugi Kanagawa 神奈川県\n \n \n \n \n 厚木市\n \n \n 中町\n \n 2-6-24\n \n \n ほてい屋第二ビル B1": { + "Latitude": 35.4408432, + "Longitude": 139.3636689 + }, "2-6-26 Kitasaiwai Nishi-Ku H1 Yokohama Bldg. B1 Yokohama 220-0004, Kanagawa Prefecture": { "Latitude": 35.4660612, "Longitude": 139.6158849 @@ -7311,6 +7331,10 @@ "Latitude": 35.44652970000001, "Longitude": 139.6374977 }, + "3-29 Sumiyoshicho Naka-ku Yokohama Kanagawa 神奈川県\n \n \n \n \n 横浜市中区\n \n \n 住吉町\n \n 3-29\n \n \n 関内住吉ビル 1F": { + "Latitude": 35.4464973, + "Longitude": 139.6374982 + }, "3-29-1 Tsuruyacho Kanagawa-ku Yokohama Kanagawa": { "Latitude": 35.469302, "Longitude": 139.6195873 @@ -9911,6 +9935,10 @@ "Latitude": 35.3273668, "Longitude": 139.3534541 }, + "Daikancho Hiratsuka Kanagawa 神奈川県\n \n \n \n \n 平塚市\n \n \n 代官町\n \n 10-22": { + "Latitude": 35.3267335, + "Longitude": 139.3519793 + }, "Daikancho Hiratsuka, Kanagawa Prefecture": { "Latitude": 35.3273668, "Longitude": 139.3534541 diff --git a/build/converter.go b/build/converter.go index de70ac2..942d40f 100644 --- a/build/converter.go +++ b/build/converter.go @@ -230,7 +230,7 @@ func (c converter) review(doc *goquery.Document) (name, address string, features value /= p.Scale } - features[n] = value + features[n] = value*2.0 - 1.0 } return diff --git a/build/data/converters/tabelog.toml b/build/data/converters/tabelog.toml new file mode 100644 index 0000000..a8f3250 --- /dev/null +++ b/build/data/converters/tabelog.toml @@ -0,0 +1,65 @@ +name = "tabelog" +domains = ["tabelog.com"] + +[index.items] + path = "div.list-rst__header > p > a" + attr = "href" + +[index.next] + path = "a.c-pagination__target--next" + attr = "href" + +[item.name] + path = "a.rd-header__rst-name-main" + +[item.address] + path = "p.rd-detail-info__rst-address:nth-of-type(1)" + +[item.count] + path = "a.rd-header__rst-reviews-target > b" + +[item.props] + [item.props.service] + accomodating = 1.0 + affordable = 0.0 + atmospheric = 0.0 + delicious = 0.0 + scale = 5.0 + + path = "dl#js-rating-detail > dd:nth-child(4)" + + [item.props.dishes] + accomodating = 0.0 + affordable = 0.0 + atmospheric = 0.0 + delicious = 0.8 + scale = 5.0 + + path = "dl#js-rating-detail > dd:nth-child(2)" + + [item.props.drinks] + accomodating = 0.0 + affordable = 0.0 + atmospheric = 0.0 + delicious = 0.2 + scale = 5.0 + + path = "dl#js-rating-detail > dd:nth-child(10)" + + [item.props.cost] + accomodating = 0.0 + affordable = 1.0 + atmospheric = 0.0 + delicious = 0.0 + scale = 5.0 + + path = "dl#js-rating-detail > dd:nth-child(8)" + + [item.props.atmosphere] + accomodating = 0.0 + affordable = 0.0 + atmospheric = 1.0 + delicious = 0.0 + scale = 5.0 + + path = "dl#js-rating-detail > dd:nth-child(6)" diff --git a/build/tabelog.go b/build/tabelog.go deleted file mode 100644 index 5ee6455..0000000 --- a/build/tabelog.go +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2015 Alex Yatskov - * Author: Alex Yatskov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package main - -import ( - "errors" - "fmt" - "strconv" - "strings" - - "github.com/PuerkitoBio/goquery" -) - -type tabelog struct { -} - -func (tabelog) define(keyword string) semantics { - return map[string]semantics{ - "dishes": {Accomodating: 0.0, Affordable: 0.0, Atmospheric: 0.0, Delicious: 0.8}, - "drinks": {Accomodating: 0.0, Affordable: 0.0, Atmospheric: 0.0, Delicious: 0.2}, - "service": {Accomodating: 1.0, Affordable: 0.0, Atmospheric: 0.0, Delicious: 0.0}, - "cost": {Accomodating: 0.0, Affordable: 1.0, Atmospheric: 0.0, Delicious: 0.0}, - "atmosphere": {Accomodating: 0.0, Affordable: 0.0, Atmospheric: 1.0, Delicious: 0.0}, - }[keyword] -} - -func (tabelog) index(doc *goquery.Document) (string, []string) { - var reviewUrls []string - doc.Find("div.list-rst__header > p > a").Each(func(index int, sel *goquery.Selection) { - if href, ok := sel.Attr("href"); ok { - reviewUrls = append(reviewUrls, href) - } - }) - - var nextIndexUrl string - if href, ok := doc.Find("a.c-pagination__target--next").Attr("href"); ok { - nextIndexUrl = href - } - - return nextIndexUrl, reviewUrls -} - -func (tabelog) review(doc *goquery.Document) (name, address string, features map[string]float64, weight float64, err error) { - if name = doc.Find("a.rd-header__rst-name-main").Text(); len(name) == 0 { - err = errors.New("invalid name") - return - } - - if addresses := doc.Find("p.rd-detail-info__rst-address"); addresses.Length() == 2 { - address = strings.TrimSpace(addresses.First().Text()) - } else { - err = errors.New("invalid address") - return - } - - features = make(map[string]float64) - for index, category := range []string{"dishes", "service", "atmosphere", "cost", "drinks"} { - valueText := doc.Find(fmt.Sprintf("dl#js-rating-detail > dd:nth-child(%d)", (index+1)*2)).Text() - - var value float64 - if value, err = strconv.ParseFloat(valueText, 8); err != nil { - err = fmt.Errorf("invalid rating for %s", category) - return - } - - features[category] = value/2.5 - 1.0 - } - - weight, err = strconv.ParseFloat(doc.Find("a.rd-header__rst-reviews-target > b").Text(), 8) - if err != nil { - err = fmt.Errorf("invalid review count") - return - } - - return -}