def compute_rouge_perl(cand, ref, is_input_files=False, verbose=False):
    """
    Computes ROUGE scores using the python wrapper
    (https://github.com/bheinzerling/pyrouge) of perl ROUGE package.

    Args:
        cand (list or str): If `is_input_files` is `False`, `cand` is a list of strings
            containing predicted summaries. if `is_input_files` is `True`, `cand` is the path
            to the file containing the predicted summaries.
        ref (list or str): If `is_input_files` is `False`, `cand` is a list of strings
            containing reference summaries. if `is_input_files` is `True`, `cand` is the path
            to the file containing the reference summaries.
        is_input_files (bool, optional): If True, inputs are file names. Otherwise, inputs are lists
            of predicted and reference summaries. Defaults to False.
        verbose (bool, optional): If True, print out all rouge scores. Defaults to False.

    Returns:
        dict: Dictionary of ROUGE scores.

    """

    temp_dir = tempfile.mkdtemp()

    if is_input_files:
        candidates = [line.strip() for line in open(cand, encoding="utf-8")]
        references = [line.strip() for line in open(ref, encoding="utf-8")]
    else:
        candidates = cand
        references = ref

    print("Number of candidates: {}".format(len(candidates)))
    print("Number of references: {}".format(len(references)))
    assert len(candidates) == len(references)

    cnt = len(candidates)
    current_time = time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime())
    tmp_dir = os.path.join(temp_dir, "rouge-tmp-{}".format(current_time))

    tmp_dir_candidate = tmp_dir + "/candidate/"
    tmp_dir_reference = tmp_dir + "/reference/"

    os.makedirs(tmp_dir_candidate, exist_ok=True)
    os.makedirs(tmp_dir_reference, exist_ok=True)

    try:
        for i in range(cnt):
            if len(references[i]) < 1:
                continue
            with open(tmp_dir_candidate + "/cand.{}.txt".format(i), "w", encoding="utf-8") as f:
                f.write(candidates[i])
            with open(tmp_dir_reference + "/ref.{}.txt".format(i), "w", encoding="utf-8") as f:
                f.write(references[i])
        r = Rouge155()
        r.model_dir = tmp_dir_reference
        r.system_dir = tmp_dir_candidate
        r.model_filename_pattern = "ref.#ID#.txt"
        r.system_filename_pattern = r"cand.(\d+).txt"
        rouge_results = r.convert_and_evaluate()
        if verbose:
            print(rouge_results)
        results_dict = r.output_to_dict(rouge_results)
    finally:
        if os.path.isdir(tmp_dir):
            shutil.rmtree(tmp_dir)
    return results_dict

    Computes ROUGE scores using the python wrapper
    (https://github.com/bheinzerling/pyrouge) of perl ROUGE package.

    Args:
        cand (list or str): If `is_input_files` is `False`, `cand` is a list of strings
            containing predicted summaries. if `is_input_files` is `True`, `cand` is the path
            to the file containing the predicted summaries.
        ref (list or str): If `is_input_files` is `False`, `cand` is a list of strings
            containing reference summaries. if `is_input_files` is `True`, `cand` is the path
            to the file containing the reference summaries.
        is_input_files (bool, optional): If True, inputs are file names. Otherwise, inputs are lists
            of predicted and reference summaries. Defaults to False.
        verbose (bool, optional): If True, print out all rouge scores. Defaults to False.

    Returns:
        dict: Dictionary of ROUGE scores.

    
utils_nlp/eval/rouge/compute_rouge.py