mmax2conll/mmax2raw.py
def dir_main(cls, input_dir, output_dir,
                 basedata_dir=c.WORDS_DIR,
                 allow_overwriting=c.ALLOW_OVERWRITING,
                 raw_extension=c.RAW_EXTENSION,
                 words_files_extension=c.WORDS_FILES_EXTENSION,
                 log_on_error=c.LOG_ON_ERROR,
                 **kwargs):
        """
        Batch convert all files in a directory containing a `basedata_dir`.
        """
        basedata_dir = os.path.join(input_dir, basedata_dir)
        # Remove this keyword argument, which is a remnant of using
        # CoNLLMain.super_dir_main
        kwargs.pop('markables_dir', None)

        words_files = {
            filename
            for filename in os.listdir(basedata_dir)
            if filename.endswith(words_files_extension)
        }

        for name in words_files:
            words_file = os.path.join(basedata_dir, name)
            output_file = os.path.join(
                output_dir,
                name[:-len(words_files_extension)]
            ) + raw_extension

            if os.path.exists(output_file):
                if allow_overwriting:
                    logger.warn(f"Overwriting {output_file}")
                else:
                    raise IOError(f"Will not overwrite: {output_file}")
            try:
                cls.single_main(
                    output_file,
                    words_file,
                    **kwargs
                )
            except Exception as e:
                if log_on_error:
                    logger.error(
                        f"{name} from {input_dir} is skipped: "
                        + e.args[0]
                    )
                else:
                    e.args = (
                        f"While processing {name} from {input_dir}: " +
                        e.args[0],
                    ) + e.args[1:]
                    raise e

        Batch convert all files in a directory containing a `basedata_dir`.
        
Batch convert all files in a directory containing a `basedata_dir`.
Batch convert all files in a directory containing a ` basedata_dir ` .
def dir_main(cls, input_dir, output_dir,
                 basedata_dir=c.WORDS_DIR,
                 allow_overwriting=c.ALLOW_OVERWRITING,
                 raw_extension=c.RAW_EXTENSION,
                 words_files_extension=c.WORDS_FILES_EXTENSION,
                 log_on_error=c.LOG_ON_ERROR,
                 **kwargs):
        basedata_dir = os.path.join(input_dir, basedata_dir)
        kwargs.pop('markables_dir', None)
        words_files = {
            filename
            for filename in os.listdir(basedata_dir)
            if filename.endswith(words_files_extension)
        }
        for name in words_files:
            words_file = os.path.join(basedata_dir, name)
            output_file = os.path.join(
                output_dir,
                name[:-len(words_files_extension)]
            ) + raw_extension
            if os.path.exists(output_file):
                if allow_overwriting:
                    logger.warn(f"Overwriting {output_file}")
                else:
                    raise IOError(f"Will not overwrite: {output_file}")
            try:
                cls.single_main(
                    output_file,
                    words_file,
                    **kwargs
                )
            except Exception as e:
                if log_on_error:
                    logger.error(
                        f"{name} from {input_dir} is skipped: "
                        + e.args[0]
                    )
                else:
                    e.args = (
                        f"While processing {name} from {input_dir}: " +
                        e.args[0],
                    ) + e.args[1:]
                    raise e
def dir_main ( cls , input_dir , output_dir , basedata_dir = c . WORDS_DIR , allow_overwriting = c . ALLOW_OVERWRITING , raw_extension = c . RAW_EXTENSION , words_files_extension = c . WORDS_FILES_EXTENSION , log_on_error = c . LOG_ON_ERROR , ** kwargs ) : basedata_dir = os . path . join ( input_dir , basedata_dir ) kwargs . pop ( 'markables_dir' , None ) words_files = { filename for filename in os . listdir ( basedata_dir ) if filename . endswith ( words_files_extension ) } for name in words_files : words_file = os . path . join ( basedata_dir , name ) output_file = os . path . join ( output_dir , name [ : - len ( words_files_extension ) ] ) + raw_extension if os . path . exists ( output_file ) : if allow_overwriting : logger . warn ( f"Overwriting {output_file}" ) else : raise IOError ( f"Will not overwrite: {output_file}" ) try : cls . single_main ( output_file , words_file , ** kwargs ) except Exception as e : if log_on_error : logger . error ( f"{name} from {input_dir} is skipped: " + e . args [ 0 ] ) else : e . args = ( f"While processing {name} from {input_dir}: " + e . args [ 0 ] , ) + e . args [ 1 : ] raise e
Batch convert all files in a directory containing a `basedata_dir`.
Batch convert all files in a directory containing a ` basedata_dir ` .
"""
        Batch convert all files in a directory containing a `basedata_dir`.
        """ # Remove this keyword argument, which is a remnant of using # CoNLLMain.super_dir_main
cls
input_dir
output_dir
basedata_dir
allow_overwriting
raw_extension
words_files_extension
log_on_error