Compare View
Commits (2)
Showing
3 changed files
Show diff stats
offline_tasks/deepwalk/deepwalk.py
| ... | ... | @@ -3,7 +3,7 @@ import numpy as np |
| 3 | 3 | import networkx as nx |
| 4 | 4 | from joblib import Parallel, delayed |
| 5 | 5 | import itertools |
| 6 | -from alias import create_alias_table, alias_sample | |
| 6 | +from .alias import create_alias_table, alias_sample | |
| 7 | 7 | from tqdm import tqdm |
| 8 | 8 | import argparse |
| 9 | 9 | import multiprocessing | ... | ... |
offline_tasks/scripts/load_index_to_redis.py
| ... | ... | @@ -42,11 +42,16 @@ def load_index_file(file_path, redis_client, key_prefix, expire_seconds=None): |
| 42 | 42 | continue |
| 43 | 43 | |
| 44 | 44 | parts = line.split('\t') |
| 45 | - if len(parts) != 2: | |
| 46 | - logger.warning(f"Invalid line format: {line}") | |
| 45 | + if len(parts) < 2: | |
| 46 | + logger.warning(f"Invalid line format (expected at least 2 fields): {line}") | |
| 47 | 47 | continue |
| 48 | 48 | |
| 49 | - key_suffix, value = parts | |
| 49 | + # 支持2字段和3字段格式 | |
| 50 | + # 格式1 (2字段): item_id \t similar_items | |
| 51 | + # 格式2 (3字段): item_id \t item_name \t similar_items (推荐格式) | |
| 52 | + # 取第一个字段作为key,最后一个字段作为value | |
| 53 | + key_suffix = parts[0] | |
| 54 | + value = parts[-1] | |
| 50 | 55 | redis_key = f"{key_prefix}:{key_suffix}" |
| 51 | 56 | |
| 52 | 57 | # 存储到Redis | ... | ... |