コード例 #1
0
 def map_by_presence_of_coupons(self, _, line):
     data = line
     COUPONS = tools.read_coupons_file()
     if any(word in data['text'].lower() for word in COUPONS):
         yield "review_c", data["stars"]
     else:
         yield "review", data["stars"]
コード例 #2
0
 def separate_map_by_stars_and_categories(self, _, line):
     data = line
     if data.get("review_id"):
         # business_id, ["review", user_id, stars]
         COUPONS = tools.read_coupons_file()
         if any(word in data['text'].lower() for word in COUPONS):
             yield data["business_id"], ["review", data["review_id"], data["stars"] ]
     elif data.get("business_id"):
         # business_id, ["business", categories]
         yield data["business_id"], ["categories", data["categories"]]
コード例 #3
0
 def separate_map_by_stars_and_categories(self, _, line):
     data = line
     if data.get("review_id"):
         # business_id, ["review", user_id, stars]
         has_coupon = False
         COUPONS = tools.read_coupons_file()
         for coupon in COUPONS:
             if coupon in data["text"].lower():
                 has_coupon = True
                 yield data["business_id"], ["review_c", data["review_id"], data["stars"], coupon]
         if has_coupon == False:
             yield data["business_id"], ["review", data["review_id"], data["stars"]]
     elif data.get("business_id"):
         # business_id, ["business_info", name, categories]
         yield data["business_id"], ["business_info", data["name"], data["categories"]]
コード例 #4
0
 def mapper_input(self, _, line):
     COUPONS = tools.read_coupons_file()
     if any(word in line['text'].lower() for word in COUPONS):
         yield 'COUNTER', 1