Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix unicode compatibility #30

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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 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