Commit 6f03163c authored by 赵威's avatar 赵威

get tractate data from redis

parent c713565e
......@@ -35,7 +35,30 @@ def get_tractate_from_redis():
"""
return: {tractate_id: {first_demands: [], is_pure_author: 1}}
"""
pass
db_key = "cvr:db:content:tractate"
column_key = db_key + ":column"
columns = str(redis_db_client.get(column_key), "utf-8").split("|")
d = redis_db_client.hgetall(db_key)
res = {}
for i in d.values():
row_list = str(i, "utf-8").split("|")
tmp = {}
for (index, elem) in enumerate(row_list):
col_name = columns[index]
if col_name in [
"first_demands", "second_demands", "first_solutions", "second_solutions", "first_positions",
"second_positions", "projects"
]:
tmp[col_name] = elem.split(",")
elif col_name in ["is_pure_author", "is_have_pure_reply", "is_have_reply"]:
if elem == "true":
tmp[col_name] = 1
else:
tmp[col_name] = 0
else:
tmp[col_name] = elem
res[int(tmp["card_id"])] = tmp
return res
def tractate_feature_engineering(tractate_df):
......
......@@ -65,7 +65,7 @@ def main():
predict_fn = tf.contrib.predictor.from_saved_model(save_path)
device_dict = device_fe.get_device_dict_from_redis()
diary_dict = tractate_fe.get_diary_dict_from_redis()
diary_dict = tractate_fe.get_tractate_dict_from_redis()
device_ids = list(device_dict.keys())[:20]
diary_ids = list(diary_dict.keys())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment