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

Do not fail if no tokenization step #122

Open
wants to merge 1 commit into
base: main
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
10 changes: 8 additions & 2 deletions source/embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,15 +364,21 @@ def EmbedMmap(fname, dim=1024, dtype=np.float32, verbose=False):

with tempfile.TemporaryDirectory() as tmpdir:
ifname = '' # stdin will be used
tok_fname = os.path.join(tmpdir, 'tok')

if args.token_lang != '--':
tok_fname = os.path.join(tmpdir, 'tok')

Token(ifname,
tok_fname,
lang=args.token_lang,
romanize=True if args.token_lang == 'el' else False,
lower_case=True, gzip=False,
verbose=args.verbose, over_write=False)
ifname = tok_fname
else:
with open(tok_fname, "w") as ofname:
for line in sys.stdin:
ofname.write(line)
ifname = tok_fname

if args.bpe_codes:
bpe_fname = os.path.join(tmpdir, 'bpe')
Expand Down