vocalpy / crowsetta

A tool to work with any format for annotating animal sounds
https://crowsetta.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
51 stars 3 forks source link

refactor Transcriber class #144

Closed NickleDave closed 2 years ago

NickleDave commented 2 years ago

Transcriber class is due for a re-factor; should be done in next version

class Transcriber:
    def __init__(from_file, to_annot):
         self.from_file = from_file
         self.to_annot = to_annot

    @classmethod
    def from_format(format):
        ...

    @classmethod
    def from_config(config):
        ...
NickleDave commented 2 years ago
  • the "right" way to do this would be to pass in the functions themselves as arguments, and have a classmethod Transcriber.from_format('simple-seq') (I don't love the method name from_format)

ended up doing basically this.
Transcriber.from_format('simple-seq'), for example, returns an instance of a SimpleSeq, already instantiated, using its from_file method. Methods like to_annot can then be called on this returned instance, instead of Transcriber having to handle them or even know they exist