from typing import Dict
from typing import Optional
from typing import Any


def __group_member_contribution(res_act: Dict[str, Dict[str, int]], act_res: Dict[str, Dict[str, int]],
                                groups: Dict[str, Dict[str, int]], parameters: Optional[Dict[Any, str]] = None) -> Dict[
    str, Dict[str, Dict[str, int]]]:
    """
    Calculates the member contribution metric

    GROUP MEMBER CONTRIBUTION of a member of a resource group with respect to the given type of work specifies how
    much of this type of work by the group was performed by the member. It can be used to measure how the workload
    of the entire group devoted to a certain type of work is distributed over the group members.

    The approach implemented is the one described in:
    Yang, Jing, et al. "OrgMining 2.0: A Novel Framework for Organizational Model Mining from Event Logs."
    arXiv preprint arXiv:2011.12445 (2020).

    Parameters
    ----------------
    res_act
        Dictionary resources-activities-occurrences
    act_res
        Dictionary activities-resources-occurrences
    groups
        Dictionary groups-resources-occurrences
    parameters
        Parameters of the algorithm

    Returns
    -----------------
    metric
        Metric value
    """
    ret = {}
    for g in groups:
        ret[g] = {}
        for r in groups[g]:
            ret[g][r] = res_act[r]
    return ret