summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormjdenkowski <michael.j.denkowski@gmail.com>2013-10-30 23:37:39 -0400
committermjdenkowski <michael.j.denkowski@gmail.com>2013-10-30 23:37:39 -0400
commit074fa88375967adababc632ea763e9dea389831e (patch)
tree0c2e7ef5e2df8496f7b153f8d119414c3b096004
parenta1d78e9ba97af7d3b442a2b8759035a0c6f6b35a (diff)
Specify heuristic for force alignment
-rw-r--r--realtime/rt/aligner.py4
-rwxr-xr-xword-aligner/force_align.py6
2 files changed, 6 insertions, 4 deletions
diff --git a/realtime/rt/aligner.py b/realtime/rt/aligner.py
index c34805eb..e1782496 100644
--- a/realtime/rt/aligner.py
+++ b/realtime/rt/aligner.py
@@ -10,7 +10,7 @@ logger = logging.getLogger('rt.aligner')
class ForceAligner:
- def __init__(self, fwd_params, fwd_err, rev_params, rev_err):
+ def __init__(self, fwd_params, fwd_err, rev_params, rev_err, heuristic='grow-diag-final-and'):
cdec_root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
fast_align = os.path.join(cdec_root, 'word-aligner', 'fast_align')
@@ -21,7 +21,7 @@ class ForceAligner:
fwd_cmd = [fast_align, '-i', '-', '-d', '-T', fwd_T, '-m', fwd_m, '-f', fwd_params]
rev_cmd = [fast_align, '-i', '-', '-d', '-T', rev_T, '-m', rev_m, '-f', rev_params, '-r']
- tools_cmd = [atools, '-i', '-', '-j', '-', '-c', 'grow-diag-final-and']
+ tools_cmd = [atools, '-i', '-', '-j', '-', '-c', heuristic]
logger.info('Executing: {}'.format(' '.join(fwd_cmd)))
self.fwd_align = util.popen_io(fwd_cmd)
diff --git a/word-aligner/force_align.py b/word-aligner/force_align.py
index 8b6ca224..b03d446e 100755
--- a/word-aligner/force_align.py
+++ b/word-aligner/force_align.py
@@ -5,13 +5,15 @@ import sys
def main():
- if len(sys.argv[1:]) != 4:
+ if len(sys.argv[1:]) < 4:
sys.stderr.write('run:\n')
sys.stderr.write(' fast_align -i corpus.f-e -d -v -o -p fwd_params >fwd_align 2>fwd_err\n')
sys.stderr.write(' fast_align -i corpus.f-e -r -d -v -o -p rev_params >rev_align 2>rev_err\n')
sys.stderr.write('\n')
sys.stderr.write('then run:\n')
- sys.stderr.write(' {} fwd_params fwd_err rev_params rev_err <in.f-e >out.f-e.gdfa\n'.format(sys.argv[0]))
+ sys.stderr.write(' {} fwd_params fwd_err rev_params rev_err [heuristic] <in.f-e >out.f-e.gdfa\n'.format(sys.argv[0]))
+ sys.stderr.write('\n')
+ sys.stderr.write('where heuristic is one of: (intersect union grow-diag grow-diag-final grow-diag-final-and) default=grow-diag-final-and\n')
sys.exit(2)
# Hook into realtime