# Path: delphin/sembase.py
# def role_priority(role: str) -> Tuple[bool, bool, str]:
# def property_priority(prop: str) -> Tuple[int, str]:
#     def __init__(self,
#                  id: Identifier,
#                  predicate: str,
#                  type: Union[str, None],
#                  lnk: Optional[Lnk],
#                  surface,
#                  base):
#     def __repr__(self):
#     def __init__(self,
#                  top: Optional[Identifier],
#                  predications: Predications,
#                  lnk: Optional[Lnk],
#                  surface,
#                  identifier):
#     def __repr__(self):
#     def __eq__(self, other):
#     def __contains__(self, id):
#     def __getitem__(self, id):
#     def arguments(self, types=None, expressed=None) -> ArgumentStructure:
#     def properties(self, id: Identifier) -> PropertyMap:
#     def is_quantifier(self, id: Identifier) -> bool:
#     def quantification_pairs(self) -> List[PredicationPair]:
# _COMMON_PROPERTIES = (
#     'PERS',      # [x] person (ERG, Jacy)
#     'NUM',       # [x] number (ERG, Jacy)
#     'GEND',      # [x] gender (ERG, Jacy)
#     'IND',       # [x] individuated (ERG)
#     'PT',        # [x] pronoun-type (ERG)
#     'PRONTYPE',  # [x] pronoun-type (Jacy)
#     'SF',        # [e] sentential-force (ERG)
#     'TENSE',     # [e] tense (ERG, Jacy)
#     'MOOD',      # [e] mood (ERG, Jacy)
#     'PROG',      # [e] progressive (ERG, Jacy)
#     'PERF',      # [e] perfective (ERG, Jacy)
#     'ASPECT',    # [e] other aspect (Jacy)
#     'PASS',      # [e] passive (Jacy)
# )
# _COMMON_PROPERTY_INDEX = dict((p, i) for i, p in enumerate(_COMMON_PROPERTIES))
# class Predication(LnkMixin):
# class SemanticStructure(LnkMixin):
# 
# Path: delphin/exceptions.py
# class PyDelphinException(Exception):
#     """The base class for PyDelphin exceptions."""
#     def __init__(self, *args, **kwargs):
#         super(PyDelphinException, self).__init__(*args, **kwargs)
# 
# Path: delphin/__about__.py



from typing import (Optional, Mapping, Iterable, List, Tuple, Dict)
from delphin.lnk import Lnk
from delphin.sembase import (
    Identifier,
    Role,
    Predication,
    Predications,
    SemanticStructure
)
from delphin.exceptions import PyDelphinException
from delphin.util import _connected_components
from delphin.__about__ import __version__  # noqa: F401
                args = ns_args[predication.id]
                # check if args are in the immediate scope
                if args.intersection(others):
                    continue
                # check if args are in scope descendants
                if any(args.intersection(descs[id]) for id in others):
                    continue
                # tests passed; predication is a candidate representative
                reps[label].append(predication)

    if priority is None:
        priority = _make_representative_priority(x)
    for label in reps:
        reps[label].sort(key=priority)

    return reps


_UNTENSED_VALUES = {
    '',
    'untensed',
}


def _make_representative_priority(x: ScopingSemanticStructure):
    """
    Create a function to sort scope representatives in *x*.
    """
    index = {p.id: i for i, p in enumerate(x.predications, 1)}


# Path: delphin/sembase.py
# def role_priority(role: str) -> Tuple[bool, bool, str]:
# def property_priority(prop: str) -> Tuple[int, str]:
#     def __init__(self,
#                  id: Identifier,
#                  predicate: str,
#                  type: Union[str, None],
#                  lnk: Optional[Lnk],
#                  surface,
#                  base):
#     def __repr__(self):
#     def __init__(self,
#                  top: Optional[Identifier],
#                  predications: Predications,
#                  lnk: Optional[Lnk],
#                  surface,
#                  identifier):
#     def __repr__(self):
#     def __eq__(self, other):
#     def __contains__(self, id):
#     def __getitem__(self, id):
#     def arguments(self, types=None, expressed=None) -> ArgumentStructure:
#     def properties(self, id: Identifier) -> PropertyMap:
#     def is_quantifier(self, id: Identifier) -> bool:
#     def quantification_pairs(self) -> List[PredicationPair]:
# _COMMON_PROPERTIES = (
#     'PERS',      # [x] person (ERG, Jacy)
#     'NUM',       # [x] number (ERG, Jacy)
#     'GEND',      # [x] gender (ERG, Jacy)
#     'IND',       # [x] individuated (ERG)
#     'PT',        # [x] pronoun-type (ERG)
#     'PRONTYPE',  # [x] pronoun-type (Jacy)
#     'SF',        # [e] sentential-force (ERG)
#     'TENSE',     # [e] tense (ERG, Jacy)
#     'MOOD',      # [e] mood (ERG, Jacy)
#     'PROG',      # [e] progressive (ERG, Jacy)
#     'PERF',      # [e] perfective (ERG, Jacy)
#     'ASPECT',    # [e] other aspect (Jacy)
#     'PASS',      # [e] passive (Jacy)
# )
# _COMMON_PROPERTY_INDEX = dict((p, i) for i, p in enumerate(_COMMON_PROPERTIES))
# class Predication(LnkMixin):
# class SemanticStructure(LnkMixin):
# 
# Path: delphin/exceptions.py
# class PyDelphinException(Exception):
#     """The base class for PyDelphin exceptions."""
#     def __init__(self, *args, **kwargs):
#         super(PyDelphinException, self).__init__(*args, **kwargs)
# 
# Path: delphin/__about__.py



# Path: delphin/scope.py
from typing import (Optional, Mapping, Iterable, List, Tuple, Dict)
from delphin.lnk import Lnk
from delphin.sembase import (
    Identifier,
    Role,
    Predication,
    Predications,
    SemanticStructure
)
from delphin.exceptions import PyDelphinException
from delphin.util import _connected_components
from delphin.__about__ import __version__  # noqa: F401

                args = ns_args[predication.id]
                # check if args are in the immediate scope
                if args.intersection(others):
                    continue
                # check if args are in scope descendants
                if any(args.intersection(descs[id]) for id in others):
                    continue
                # tests passed; predication is a candidate representative
                reps[label].append(predication)

    if priority is None:
        priority = _make_representative_priority(x)
    for label in reps:
        reps[label].sort(key=priority)

    return reps


_UNTENSED_VALUES = {
    '',
    'untensed',
}


def _make_representative_priority(x: ScopingSemanticStructure):
    """
    Create a function to sort scope representatives in *x*.
    """
    index = {p.id: i for i, p in enumerate(x.predications, 1)}


    def representative_priority(p: Predication):