Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions 9 codes/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ def read_triple(file_path, entity2id, relation2id):
triples = []
with open(file_path) as fin:
for line in fin:
h, r, t = line.strip().split('\t')
# The entity/relation dict have the element names at the end, when loading them
# the entire line is stripped, removing any trailing spaces. As such, we need
# to strip each element individually here as well.
h, r, t = map(str.strip, line.split('\t'))
triples.append((entity2id[h], relation2id[r], entity2id[t]))
return triples

Expand Down Expand Up @@ -160,12 +163,12 @@ def log_metrics(mode, step, metrics):

def main(args):
if (not args.do_train) and (not args.do_valid) and (not args.do_test):
raise ValueError('one of train/val/test mode must be choosed.')
raise ValueError('one of train/val/test mode must be chosen.')

if args.init_checkpoint:
override_config(args)
elif args.data_path is None:
raise ValueError('one of init_checkpoint/data_path must be choosed.')
raise ValueError('one of init_checkpoint/data_path must be chosen.')

if args.do_train and args.save_path is None:
raise ValueError('Where do you want to save your trained model?')
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.