# 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 joblib
import logging
import os
import re
import shlex
import six
import subprocess
import tempfile
import threading
from wordseg import utils, folding

        thread = threading.Thread(target=writer)
        thread.start()

        # Send stdout and stderr to logger, break if EOF reached
        while True:
            line_out = process.stdout.readline().decode('utf8')
            line_err = process.stderr.readline().decode('utf8')

            if line_out == "" and line_err == "":
                break

            if line_out != "":
                log.debug(line_out.strip())

            if line_err != "":
                log.debug(line_err.strip())

        thread.join()
        process.wait()
        if process.returncode:
            raise RuntimeError(
                'failed with error code {}'.format(process.returncode))

        tmp_output.seek(0)
        return tmp_output.read().decode('utf8').split('\n')


def segment(text, nfolds=5, njobs=1,
            args='--ngram 1 --a1 0 --b1 1',

# 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/dpseg.py
import joblib
import logging
import os
import re
import shlex
import six
import subprocess
import tempfile
import threading
from wordseg import utils, folding


        thread = threading.Thread(target=writer)
        thread.start()

        # Send stdout and stderr to logger, break if EOF reached
        while True:
            line_out = process.stdout.readline().decode('utf8')
            line_err = process.stderr.readline().decode('utf8')

            if line_out == "" and line_err == "":
                break

            if line_out != "":
                log.debug(line_out.strip())

            if line_err != "":
                log.debug(line_err.strip())

        thread.join()
        process.wait()
        if process.returncode:
            raise RuntimeError(
                'failed with error code {}'.format(process.returncode))

        tmp_output.seek(0)
        return tmp_output.read().decode('utf8').split('\n')


def segment(text, nfolds=5, njobs=1,
            args='--ngram 1 --a1 0 --b1 1',

            log=utils.null_logger(),