# Path: wordseg/utils.py
# def str2type(t):
# def type2str(t):
# def strip(string):
# def null_logger():
# def get_logger(name=None, level=logging.WARNING):
#     def __init__(self, elements):
#     def __iter__(self):
#     def __next__(self):
#     def __init__(self, function):
#     def __call__(self):
#     def exit(msg):
# def get_binary(binary):
# def get_config_files(algorithm, extension=None):
#     def __init__(self, short_name=None, name=None, type=None,
#                  default=None, help=''):
#     def add_to_parser(self, parser):
#     def parsed_name(self):
# def get_parser(description=None, separator=Separator(), train_file=False):
# def prepare_main(name=None,
#                  description=None,
#                  separator=Separator(phone=None, syllable=None, word=None),
#                  add_arguments=None,
#                  train_file=False):
# class CountingIterator:
# class CatchExceptions:
# class Argument:
# 
# Path: wordseg/folding.py
# def _permute(l):
# def _flatten(l):
# def _cumsum(l):
# def boundaries(text, nfolds):
# def fold(text, nfolds, fold_boundaries=None):
# def unfold(folds, index):


import codecs
import collections
import os
import joblib
from wordseg import utils, folding
        The logger instance where to send messages.

    Returns
    -------
    generator
        The utterances from `text` with estimated words boundaries.

    See also
    --------
    wordseg.folding.fold

    """
    # force the text to be a list of utterances
    text = list(text)

    if not train_text:
        log.info('not train data provided, will train model on test data')

        log.debug('building %s folds', nfolds)
        folded_texts, fold_index = folding.fold(text, nfolds)

        # segment the folds in parallel
        segmented_texts = joblib.Parallel(n_jobs=njobs, verbose=0)(
            joblib.delayed(_do_puddle)(
                fold, window, by_frequency,
                log.getEffectiveLevel(),
                f'wordseg-puddle - fold {n+1}')
            for n, fold in enumerate(folded_texts))

        log.debug('unfolding the %s folds', nfolds)

# Path: wordseg/utils.py
# def str2type(t):
# def type2str(t):
# def strip(string):
# def null_logger():
# def get_logger(name=None, level=logging.WARNING):
#     def __init__(self, elements):
#     def __iter__(self):
#     def __next__(self):
#     def __init__(self, function):
#     def __call__(self):
#     def exit(msg):
# def get_binary(binary):
# def get_config_files(algorithm, extension=None):
#     def __init__(self, short_name=None, name=None, type=None,
#                  default=None, help=''):
#     def add_to_parser(self, parser):
#     def parsed_name(self):
# def get_parser(description=None, separator=Separator(), train_file=False):
# def prepare_main(name=None,
#                  description=None,
#                  separator=Separator(phone=None, syllable=None, word=None),
#                  add_arguments=None,
#                  train_file=False):
# class CountingIterator:
# class CatchExceptions:
# class Argument:
# 
# Path: wordseg/folding.py
# def _permute(l):
# def _flatten(l):
# def _cumsum(l):
# def boundaries(text, nfolds):
# def fold(text, nfolds, fold_boundaries=None):
# def unfold(folds, index):


# Path: wordseg/algos/puddle.py
import codecs
import collections
import os
import joblib
from wordseg import utils, folding

        The logger instance where to send messages.

    Returns
    -------
    generator
        The utterances from `text` with estimated words boundaries.

    See also
    --------
    wordseg.folding.fold

    """
    # force the text to be a list of utterances
    text = list(text)

    if not train_text:
        log.info('not train data provided, will train model on test data')

        log.debug('building %s folds', nfolds)
        folded_texts, fold_index = folding.fold(text, nfolds)

        # segment the folds in parallel
        segmented_texts = joblib.Parallel(n_jobs=njobs, verbose=0)(
            joblib.delayed(_do_puddle)(
                fold, window, by_frequency,
                log.getEffectiveLevel(),
                f'wordseg-puddle - fold {n+1}')
            for n, fold in enumerate(folded_texts))

        log.debug('unfolding the %s folds', nfolds)

        output_text = folding.unfold(segmented_texts, fold_index)