Generate text.

    Parameters
    ----------
    args : `argparse.Namespace`
        Command arguments.
341009
def cmd_generate(args):
    

    if args.start:
        if args.end or args.reply:
            raise ValueError('multiple input arguments')
        args.reply_to = args.start
        args.reply_mode = ReplyMode.END
    elif args.end:
        if args.reply:
            raise ValueError('multiple input arguments')
        args.reply_to = args.end
        args.reply_mode = ReplyMode.START
    elif args.reply:
        args.reply_to = args.reply
        args.reply_mode = ReplyMode.REPLY
    else:
        args.reply_to = None
        args.reply_mode = ReplyMode.END

    markov = load(MarkovText, args.state, args)

    ss = range(args.count)
    if args.progress:
        title = truncate(args.output.name, BAR_DESC_SIZE - 1, False)
        ss = tqdm(ss, desc=title,
                  bar_format=BAR_FORMAT, dynamic_ncols=True)

    if not args.format:
        markov.formatter = lambda x: x

    for _ in ss:
        data = markov(
            args.words,
            state_size=args.state_size,
            reply_to=args.reply_to,
            reply_mode=args.reply_mode
        )
        if data:
            print(data)
34604
def generate_corpus(self, text):
        
        if isinstance(text, str):
            sentences = self.sentence_split(text)
        else:
            sentences = []
            for line in text:
                sentences += self.sentence_split(line)
        passing = filter(self.test_sentence_input, sentences)
        runs = map(self.word_split, passing)
        return runs
826400
def call_command(self, cmd, *argv):
        
        parser = self.get_parser()
        args = [cmd] + list(argv)
        namespace = parser.parse_args(args)
        self.run_command(namespace)
1096013
def _append_message(self, text, char_format):
        
        self._cursor = self._text_edit.textCursor()
        operations = self._parser.parse_text(FormattedText(text, char_format))
        for i, operation in enumerate(operations):
            try:
                func = getattr(self, '_%s' % operation.command)
            except AttributeError:
                print('command not implemented: %r - %r' % (
                    operation.command, operation.data))
            else:
                try:
                    func(operation.data)
                except Exception:
                    _logger().exception('exception while running %r', operation)
                    # uncomment next line for debugging commands
                    self._text_edit.repaint()
165644
def generate(self, **kwargs: Any) -> bytes:
        """"""
        namespace = {
            "escape": escape.xhtml_escape,
            "xhtml_escape": escape.xhtml_escape,
            "url_escape": escape.url_escape,
            "json_encode": escape.json_encode,
            "squeeze": escape.squeeze,
            "linkify": escape.linkify,
            "datetime": datetime,
            "_tt_utf8": escape.utf8,  # for internal use
            "_tt_string_types": (unicode_type, bytes),
            # __name__ and __loader__ allow the traceback mechanism to find
            # the generated source code.
            "__name__": self.name.replace(".", "_"),
            "__loader__": ObjectDict(get_source=lambda name: self.code),
        }
        namespace.update(self.namespace)
        namespace.update(kwargs)
        exec_in(self.compiled, namespace)
        execute = typing.cast(Callable[[], bytes], namespace["_tt_execute"])
        # Clear the traceback module's cache of source data now that
        # we've generated a new template (mainly for this module's
        # unittests, where different tests reuse the same name).
        linecache.clearcache()
        return execute()
1061625
def generate(inputfilename, outputfilename='', dump=0, **flags):
    """"""

    if not outputfilename:
        if inputfilename[-2:] == '.g':
            outputfilename = inputfilename[:-2] + '.py'
        else:
            raise Exception("Missing output filename")

    print 'Input Grammar:', inputfilename
    print 'Output File:', outputfilename

    DIVIDER = '\n%%\n'  # This pattern separates the pre/post parsers
    preparser, postparser = None, None  # Code before and after the parser desc

    # Read the entire file
    s = open(inputfilename, 'r').read()

    # See if there's a separation between the pre-parser and parser
    f = find(s, DIVIDER)
    if f >= 0:
        preparser, s = s[:f] + '\n\n', s[f + len(DIVIDER):]

    # See if there's a separation between the parser and post-parser
    f = find(s, DIVIDER)
    if f >= 0:
        s, postparser = s[:f], '\n\n' + s[f + len(DIVIDER):]

    # Create the parser and scanner
    p = ParserDescription(ParserDescriptionScanner(s))
    if not p:
        return

    # Now parse the file
    t = wrap_error_reporter(p, 'Parser')
    if not t:
        return  # Error
    if preparser is not None:
        t.preparser = preparser
    if postparser is not None:
        t.postparser = postparser

    # Check the options
    for f in t.options.keys():
        for opt, _, _ in yapps_options:
            if f == opt:
                break
        else:
            print 'Warning: unrecognized option', f
    # Add command line options to the set
    for f in flags.keys():
        t.options[f] = flags[f]

    # Generate the output
    if dump:
        t.dump_information()
    else:
        t.output = open(outputfilename, 'w')
        t.generate_output()
1337937
def load_args(self, args, clargs):
        
        # Parse All Arguments
        args = self.parser.parse_args(args=clargs, namespace=args)

        # Print the help information if no subcommand is given
        # subcommand is required for operation
        if args.subcommand is None:
            self.parser.print_help()
            args = None

        return args
696504
def generate_parser():
    """"""
    parser = argparse.ArgumentParser(
        description=constants.TACL_DESCRIPTION,
        formatter_class=ParagraphFormatter)
    subparsers = parser.add_subparsers(title='subcommands')
    generate_align_subparser(subparsers)
    generate_catalogue_subparser(subparsers)
    generate_counts_subparser(subparsers)
    generate_diff_subparser(subparsers)
    generate_excise_subparser(subparsers)
    generate_highlight_subparser(subparsers)
    generate_intersect_subparser(subparsers)
    generate_lifetime_subparser(subparsers)
    generate_ngrams_subparser(subparsers)
    generate_prepare_subparser(subparsers)
    generate_results_subparser(subparsers)
    generate_supplied_diff_subparser(subparsers)
    generate_search_subparser(subparsers)
    generate_supplied_intersect_subparser(subparsers)
    generate_statistics_subparser(subparsers)
    generate_strip_subparser(subparsers)
    return parser
242314
def write_text(_command, txt_file):
    """"""
    command = _command.strip()
    with open(txt_file, 'w') as txt:
        txt.writelines(command)
1329803
def gen_text(env: TextIOBase, package: str, tmpl: str):
    """"""
    if env:
        env_args = json_datetime.load(env)
    else:
        env_args = {}
    jinja_env = template.setup(package)
    echo(jinja_env.get_template(tmpl).render(**env_args))
1219548
def do_tag(self, args: argparse.Namespace):
        """"""
        # The Namespace always includes the Statement object created when parsing the command line
        statement = args.__statement__

        self.poutput("The command line you ran was: {}".format(statement.command_and_args))
        self.poutput("It generated this tag:")
        self.poutput('<{0}>{1}</{0}>'.format(args.tag, ' '.join(args.content)))
412183
def text(*)
      if options[:help]
        invoke :help, ['text']
      elsif options.empty?
        invoke :help
      else
        require_relative 'commands/text'
        RubyEdit::Commands::Text.new(options).execute
      end
    end
960253
def _make_fn_text(self):
        """"""
        if not self._f:
            text = "(not loaded)"
        elif self._f.filename:
            text = os.path.relpath(self._f.filename, ".")
        else:
            text = "(filename not set)"
        return text
298129
def genargs() -> ArgumentParser:
    
    parser = ArgumentParser()
    parser.add_argument("spec", help="JSG specification - can be file name, URI or string")
    parser.add_argument("-o", "--outfile", help="Output python file - if omitted, python is not saved")
    parser.add_argument("-p", "--print", help="Print python file to stdout")
    parser.add_argument("-id", "--inputdir", help="Input directory with JSON files")
    parser.add_argument("-i", "--json", help="URL, file name or json text", nargs='*')
    return parser
404692
def tokenize_argument(text):
    
    for delim in ARG_TOKENS:
        if text.startswith(delim):
            return text.forward(len(delim))
1124464
def append_to_run_from_text(cls, r, text):
        
        appender = cls(r)
        appender.add_text(text)
859361
def generate_cli_main_parser():
    """"""
    parser = argparse.ArgumentParser(
        description='Create, Update, Delete, List DNS entries')

    parser.add_argument('--version', help='show the current version of lexicon',
                        action='version', version='%(prog)s {0}'
                        .format(discovery.lexicon_version()))
    parser.add_argument('--delegated', help='specify the delegated domain')
    parser.add_argument('--config-dir', default=os.getcwd(),
                        help='specify the directory where to search lexicon.yml and '
                             'lexicon_[provider].yml configuration files '
                             '(default: current directory).')
    subparsers = parser.add_subparsers(
        dest='provider_name', help='specify the DNS provider to use')
    subparsers.required = True

    for provider, available in discovery.find_providers().items():
        provider_module = importlib.import_module(
            'lexicon.providers.' + provider)
        provider_parser = getattr(provider_module, 'provider_parser')

        subparser = subparsers.add_parser(provider, help='{0} provider'.format(provider),
                                          parents=[generate_base_provider_parser()])
        provider_parser(subparser)

        if not available:
            subparser.epilog = ('WARNING: some required dependencies for this provider are not '
                                'installed. Please install lexicon[{0}] first before using it.'
                                .format(provider))

    return parser