From 40207b7623d6271492520c8aecb445a48a67e6d6 Mon Sep 17 00:00:00 2001 From: chris Date: Mon, 9 Feb 2026 12:33:33 -0500 Subject: [PATCH] Accept multiple values --- tlm/cli.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tlm/cli.py b/tlm/cli.py index 3fb5c18..c929050 100644 --- a/tlm/cli.py +++ b/tlm/cli.py @@ -12,8 +12,8 @@ def cli(): @cli.command() @click.option("--length", default=50, help="Number of words to generate.") @click.option("--n", default=2, help="Number of words in the context window.") -@click.option("--text", type=click.Path(exists=True), help="Text file to use as training corpus.") -@click.option("--gutenberg", help="NLTK Gutenberg corpus key (use --list-gutenberg to see available keys).") +@click.option("--text", type=click.Path(exists=True), multiple=True, help="Text file(s) to use as training corpus. Can be specified multiple times.") +@click.option("--gutenberg", multiple=True, help="NLTK Gutenberg corpus key(s). Can be specified multiple times.") @click.option("--list-gutenberg", is_flag=True, help="List available Gutenberg corpus keys.") @click.option("--mbox", type=click.Path(exists=True), help="Mbox file to use for training.") @click.option("--prompt", help="Prompt to start generation.") @@ -35,12 +35,16 @@ def generate(length, n, text, gutenberg, list_gutenberg, mbox, prompt, interact) corpus = None if text: - with open(text, "r") as f: - corpus = f.read().split() + corpus = [] + for filepath in text: + with open(filepath, "r") as f: + corpus.extend(f.read().split()) elif gutenberg: nltk.download("gutenberg", quiet=True) from nltk.corpus import gutenberg as gutenberg_corpus - corpus = gutenberg_corpus.words(gutenberg) + corpus = [] + for key in gutenberg: + corpus.extend(gutenberg_corpus.words(key)) elif mbox: mail_text = read_mail_text(mbox) corpus = mail_text.split()