o
    8wÖiQ  ã                   @   s0   d dl mZmZ ddlmZ G dd„ deƒZdS )é    )ÚIteratorÚDicté   )ÚProtocolc                   @   s4   e Zd ZdZdee fdd„Zdee fdd„ZdS )ÚCollectionProtocola#  A collection of files with no train/dev/test split

    A collection can be defined programmatically by creating a class that
    inherits from CollectionProtocol and implements the `files_iter` method:

        >>> class MyCollection(CollectionProtocol):
        ...     def files_iter(self) -> Iterator[Dict]:
        ...         yield {"uri": "filename1", "any_other_key": "..."}
        ...         yield {"uri": "filename2", "any_other_key": "..."}
        ...         yield {"uri": "filename3", "any_other_key": "..."}

    `files_iter` should return an iterator of dictionnaries with
        - a mandatory "uri" key that provides a unique file identifier (usually
          the filename),
        - any other key that the collection may provide.

    It can then be used in Python like this:

        >>> collection = MyCollection()
        >>> for file in collection.files():
        ...    print(file["uri"])
        filename1
        filename2
        filename3

    A collection can also be defined using `pyannote.database` configuration
    file, whose (configurable) path defaults to "~/database.yml".

    ~~~ Content of ~/database.yml ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Protocols:
      MyDatabase:
        Collection:
          MyCollection:
            uri: /path/to/collection.lst
            any_other_key: ... # see custom loader documentation
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    where "/path/to/collection.lst" contains the list of identifiers of the
    files in the collection:

    ~~~ Content of "/path/to/collection.lst ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    filename1
    filename2
    filename3
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    It can the be used in Python like this:

        >>> from pyannote.database import registry
        >>> collection = registry.get_protocol('MyDatabase.Collection.MyCollection')
        >>> for file in collection.files():
        ...    print(file["uri"])
        filename1
        filename2
        filename3
    Úreturnc                 C   s   t ƒ ‚©N)ÚNotImplementedError©Úself© r   úb/home/ubuntu/sommelier/.venv/lib/python3.10/site-packages/pyannote/database/protocol/collection.pyÚ
files_iter]   s   zCollectionProtocol.files_iterc                 C   s   |   ¡ S r   )r   r
   r   r   r   Ú
train_itera   s   zCollectionProtocol.train_iterN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   r   "   s    :r   N)Útypingr   r   Úprotocolr   r   r   r   r   r   Ú<module>   s   