def json(self, align_threshold: float = 0.0) -> Dict:
        """
        Returns a dictionary suitable for json.dumps() representing all
        the information in the class. It is initialized with any keys
        present in the corresponding `TranslatorInput` object's pass_through_dict.
        Keys from here that are not overwritten by Sockeye will thus be passed
        through to the output.

        :param align_threshold: If alignments are defined, only print ones over this threshold.
        :return: A dictionary.
        """
        _d = self.pass_through_dict  # type: Dict[str, Any]
        _d['sentence_id'] = self.sentence_id
        _d['translation'] = self.translation
        _d['score'] = self.score

        if self.nbest_translations is not None and len(self.nbest_translations) > 1:
            _d['translations'] = self.nbest_translations
            _d['scores'] = self.nbest_scores
            if self.nbest_attention_matrices:
                extracted_alignments = []
                for alignment_matrix in self.nbest_attention_matrices:
                    extracted_alignments.append(list(utils.get_alignments(alignment_matrix, threshold=align_threshold)))
                _d['alignments'] = extracted_alignments

        return _d
def json ( self , align_threshold : float = 0.0 ) -> Dict : _d = self . pass_through_dict _d [ 'sentence_id' ] = self . sentence_id _d [ 'translation' ] = self . translation _d [ 'score' ] = self . score if self . nbest_translations is not None and len ( self . nbest_translations ) > 1 : _d [ 'translations' ] = self . nbest_translations _d [ 'scores' ] = self . nbest_scores if self . nbest_attention_matrices : extracted_alignments = [ ] for alignment_matrix in self . nbest_attention_matrices : extracted_alignments . append ( list ( utils . get_alignments ( alignment_matrix , threshold = align_threshold ) ) ) _d [ 'alignments' ] = extracted_alignments return _d
Returns a dictionary suitable for json.dumps() representing all
        the information in the class. It is initialized with any keys
        present in the corresponding `TranslatorInput` object's pass_through_dict.
        Keys from here that are not overwritten by Sockeye will thus be passed
        through to the output.

        :param align_threshold: If alignments are defined, only print ones over this threshold.
        :return: A dictionary.