def correct_batch(
            self,
            sentences: List[str],
            max_length: int = 128,
            batch_size: int = 32,
            threshold: float = 0.7,
            silent: bool = True
    ):
        """
        Correct sentences with macbert4csc model
        :param sentences: list[str], sentence list
        :param max_length: int, max length of each sentence
        :param batch_size: int, batch size
        :param threshold: float, threshold of error word
        :param silent: bool, silent or not
        :return: list of dict, {'source': 'src', 'target': 'trg', 'errors': [(error_word, correct_word, position), ...]}
        """
        input_sents = []
        sent_map = []
        for idx, sentence in enumerate(sentences):
            if len(sentence) > max_length:
                # split long sentence into short ones
                short_sentences = [i[0] for i in split_text_into_sentences_by_length(sentence, max_length)]
                input_sents.extend(short_sentences)
                sent_map.extend([idx] * len(short_sentences))
            else:
                input_sents.append(sentence)
                sent_map.append(idx)

        # predict all sentences
        sents = self._predict(
            input_sents,
            threshold=threshold,
            batch_size=batch_size,
            silent=silent,
        )

        # concatenate the results of short sentences
        corrected_sentences = [''] * len(sentences)
        for idx, corrected_sent in zip(sent_map, sents):
            corrected_sentences[idx] += corrected_sent

        new_corrected_sentences = []
        corrected_details = []
        for idx, corrected_sent in enumerate(corrected_sentences):
            new_corrected_sent, sub_details = get_errors(corrected_sent, sentences[idx])
            new_corrected_sentences.append(new_corrected_sent)
            corrected_details.append(sub_details)
        return [{'source': s, 'target': c, 'errors': e} for s, c, e in
                zip(sentences, new_corrected_sentences, corrected_details)]

        Correct sentences with macbert4csc model
        :param sentences: list[str], sentence list
        :param max_length: int, max length of each sentence
        :param batch_size: int, batch size
        :param threshold: float, threshold of error word
        :param silent: bool, silent or not
        :return: list of dict, {'source': 'src', 'target': 'trg', 'errors': [(error_word, correct_word, position), ...]}
        
pycorrector/macbert/macbert_corrector.py