-
Notifications
You must be signed in to change notification settings - Fork 55
/
run_preprocess.py
executable file
·37 lines (28 loc) · 1.24 KB
/
run_preprocess.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from jTransUP.data.preprocessRatings import preprocess as preprocessRating
from jTransUP.data.preprocessTriples import preprocess as preprocessKG
import os
import logging
data_path = "/Users/caoyixin/Github/joint-kg-recommender/datasets/"
dataset = 'dbbook2014'
dataset_path = os.path.join(data_path, dataset)
kg_path = os.path.join(dataset_path, 'kg')
rating_file = os.path.join(dataset_path, 'ratings.csv')
triple_file = os.path.join(kg_path, "kg_hop0.dat")
relation_file = os.path.join(kg_path, "relation_filter.dat")
i2kg_file = os.path.join(dataset_path, "i2kg_map.tsv")
log_path = dataset_path
logger = logging.getLogger()
logger.setLevel(level=logging.DEBUG)
log_file = os.path.join(dataset_path, "data_preprocess.log")
# Formatter
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
# FileHandler
file_handler = logging.FileHandler(log_file)
file_handler.setFormatter(formatter)
logger.addHandler(file_handler)
# StreamHandler
stream_handler = logging.StreamHandler()
stream_handler.setFormatter(formatter)
logger.addHandler(stream_handler)
preprocessRating(rating_file, dataset_path, low_frequence=5, logger=logger)
preprocessKG([triple_file], kg_path, entity_file=i2kg_file, relation_file=relation_file, logger=logger)