from pathlib import Path
import json


def read_features(corpus_folder):
    """Read the dictionary of each poem in "corpus_folder" and
    return the list of python dictionaries

    :param corpus_folder: Local folder where the corpus is located
    :return: List of python dictionaries with the poems features
    """
    features_path = Path.cwd() / Path(corpus_folder) / "averell" / "parser"
    features = []
    for json_file in features_path.rglob("*.json"):
        features.append(json.loads(json_file.read_text()))

    features = sorted(features, key=lambda i: i['poem_title'])
    return features