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
6381cc97
Commit
6381cc97
authored
Sep 03, 2018
by
Myle Ott
Browse files
Add documentation
parent
0e101e9c
Changes
44
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
5 deletions
+18
-5
interactive.py
interactive.py
+3
-0
preprocess.py
preprocess.py
+4
-3
score.py
score.py
+8
-2
train.py
train.py
+3
-0
No files found.
interactive.py
View file @
6381cc97
...
...
@@ -5,6 +5,9 @@
# 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.
"""
Translate raw text with a trained model. Batches data on-the-fly.
"""
from
collections
import
namedtuple
import
numpy
as
np
...
...
preprocess.py
View file @
6381cc97
...
...
@@ -5,7 +5,9 @@
# 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.
#
"""
Data pre-processing: build vocabularies and binarize training data.
"""
import
argparse
from
itertools
import
zip_longest
...
...
@@ -17,8 +19,7 @@ from fairseq.tokenizer import Tokenizer, tokenize_line
def
get_parser
():
parser
=
argparse
.
ArgumentParser
(
description
=
'Data pre-processing: Create dictionary and store data in binary format'
)
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'-s'
,
'--source-lang'
,
default
=
None
,
metavar
=
'SRC'
,
help
=
'source language'
)
parser
.
add_argument
(
'-t'
,
'--target-lang'
,
default
=
None
,
metavar
=
'TARGET'
,
help
=
'target language'
)
parser
.
add_argument
(
'--trainpref'
,
metavar
=
'FP'
,
default
=
None
,
help
=
'train file prefix'
)
...
...
score.py
View file @
6381cc97
...
...
@@ -5,7 +5,9 @@
# 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.
#
"""
BLEU scoring of generated translations against reference translations.
"""
import
argparse
import
os
...
...
@@ -15,7 +17,7 @@ from fairseq import bleu, tokenizer
from
fairseq.data
import
dictionary
def
main
():
def
get_parser
():
parser
=
argparse
.
ArgumentParser
(
description
=
'Command-line script for BLEU scoring.'
)
parser
.
add_argument
(
'-s'
,
'--sys'
,
default
=
'-'
,
help
=
'system output'
)
parser
.
add_argument
(
'-r'
,
'--ref'
,
required
=
True
,
help
=
'references'
)
...
...
@@ -23,7 +25,11 @@ def main():
type
=
int
,
help
=
'consider ngrams up to this order'
)
parser
.
add_argument
(
'--ignore-case'
,
action
=
'store_true'
,
help
=
'case-insensitive scoring'
)
return
parser
def
main
():
parser
=
get_parser
()
args
=
parser
.
parse_args
()
print
(
args
)
...
...
train.py
View file @
6381cc97
...
...
@@ -5,6 +5,9 @@
# 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.
"""
Train a new model on one or across multiple GPUs.
"""
import
collections
import
itertools
...
...
Prev
1
2
3
Next
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