Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
Fairseq
Commits
cd6590b6
Commit
cd6590b6
authored
Aug 14, 2018
by
Alexei Baevski
Committed by
Myle Ott
Sep 03, 2018
Browse files
script to read binarized data
parent
5b533aa6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
+35
-0
read_binarized.py
read_binarized.py
+35
-0
No files found.
read_binarized.py
0 → 100644
View file @
cd6590b6
#!/usr/bin/env python3
# Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the LICENSE file in
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.
#
import
argparse
from
fairseq.data
import
dictionary
from
fairseq.data
import
IndexedDataset
def
get_parser
():
parser
=
argparse
.
ArgumentParser
(
description
=
'writes text from binarized file to stdout'
)
parser
.
add_argument
(
'--dict'
,
metavar
=
'FP'
,
required
=
True
,
help
=
'dictionary containing known words'
)
parser
.
add_argument
(
'--input'
,
metavar
=
'FP'
,
required
=
True
,
help
=
'binarized file to read'
)
return
parser
def
main
(
args
):
dict
=
dictionary
.
Dictionary
.
load
(
args
.
dict
)
ds
=
IndexedDataset
(
args
.
input
,
fix_lua_indexing
=
True
)
for
tensor_line
in
ds
:
print
(
dict
.
string
(
tensor_line
))
if
__name__
==
'__main__'
:
parser
=
get_parser
()
args
=
parser
.
parse_args
()
main
(
args
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment