MCPcopy Create free account
hub / github.com/AkaliKong/MiniOneRec / build_review_data_amazon23

Function build_review_data_amazon23

data/amazon23_data_process.py:457–487  ·  view source on GitHub ↗

Build review_data: key = (uid, iid, timestamp) value = {review, title}

(reviews, user2index, item2index)

Source from the content-addressed store, hash-verified

455
456
457def build_review_data_amazon23(reviews, user2index, item2index):
458 """
459 Build review_data:
460 key = (uid, iid, timestamp)
461 value = {review, title}
462 """
463
464 review_data = {}
465
466 for r in tqdm(reviews, desc="Building review_data"):
467 user = r["user_id"]
468 asin = r["asin"]
469
470 if user not in user2index or asin not in item2index:
471 continue
472
473 uid = user2index[user]
474 iid = item2index[asin]
475 ts = r["timestamp"]
476
477 key = str((uid, iid, ts))
478
479 review_data[key] = {
480 "review": clean_text(r.get("review_text", "")),
481 "summary": clean_text(r.get("review_title", "")),
482 "helpful_votes": r.get("helpful_votes", 0),
483 "verified": r.get("verified", False),
484 }
485
486 print(f"[ReviewData] Stored {len(review_data)} review entries")
487 return review_data
488
489
490def parse_args():

Callers 1

mainFunction · 0.85

Calls 1

clean_textFunction · 0.70

Tested by

no test coverage detected