# Path: abkhazia/decode/_score.py
# def options():
# def format(score_opts, mkgraph_opts):
# def skip_scoring(score_opts):


import os
import abkhazia.utils as utils
import abkhazia.kaldi as kaldi
from abkhazia.decode import _score
    score_opts = ' '.join(
        '--{} {}'.format(n, str(o))
        for n, o in decoder.score_opts.items())

    # add the reverse flag if enabled in the mkgraph options
    if decoder.mkgraph_opts['reverse'].value:
        score_opts += ' --reverse true'

    target = os.path.join(decoder.recipe_dir, 'decode')
    if not os.path.isdir(target):
        os.makedirs(target)

    # link requested files to decoder.recipe_dir. final.mat is optional (here
    # only if features type is LDA)
    for linked in ('final.mdl', 'final.alimdl', 'tree', 'final.mat'):
        src = os.path.join(decoder.am_dir, linked)
        if os.path.exists(src):
            os.symlink(src, os.path.join(decoder.recipe_dir, linked))
        elif linked == 'final.mat':
            pass
        else:
            raise IOError('acoustic model file not found: {}'.format(src))

    decoder._run_command((
        'steps/decode_fmllr.sh --nj {njobs} --cmd "{cmd}" '
        '{decode_opts} {skip_scoring} --scoring-opts "{score_opts}" '
        '{graph} {data} {decode}'.format(
            njobs=decoder.njobs,
            cmd=utils.config.get('kaldi', 'decode-cmd'),
            decode_opts=decode_opts,

# Path: abkhazia/decode/_score.py
# def options():
# def format(score_opts, mkgraph_opts):
# def skip_scoring(score_opts):


# Path: abkhazia/decode/_decoder_fmllr.py
import os
import abkhazia.utils as utils
import abkhazia.kaldi as kaldi
from abkhazia.decode import _score

    score_opts = ' '.join(
        '--{} {}'.format(n, str(o))
        for n, o in decoder.score_opts.items())

    # add the reverse flag if enabled in the mkgraph options
    if decoder.mkgraph_opts['reverse'].value:
        score_opts += ' --reverse true'

    target = os.path.join(decoder.recipe_dir, 'decode')
    if not os.path.isdir(target):
        os.makedirs(target)

    # link requested files to decoder.recipe_dir. final.mat is optional (here
    # only if features type is LDA)
    for linked in ('final.mdl', 'final.alimdl', 'tree', 'final.mat'):
        src = os.path.join(decoder.am_dir, linked)
        if os.path.exists(src):
            os.symlink(src, os.path.join(decoder.recipe_dir, linked))
        elif linked == 'final.mat':
            pass
        else:
            raise IOError('acoustic model file not found: {}'.format(src))

    decoder._run_command((
        'steps/decode_fmllr.sh --nj {njobs} --cmd "{cmd}" '
        '{decode_opts} {skip_scoring} --scoring-opts "{score_opts}" '
        '{graph} {data} {decode}'.format(
            njobs=decoder.njobs,
            cmd=utils.config.get('kaldi', 'decode-cmd'),
            decode_opts=decode_opts,

            skip_scoring=_score.skip_scoring(decoder.score_opts),