build_tools.nltk_syllable_extractor.cli

Command-line interface for the NLTK syllable extractor.

This module provides the CLI entry point and argument parser for the NLTK-based syllable extractor. The actual processing logic is in:

  • interactive.py - Interactive mode for single-file extraction

  • batch.py - Batch mode for processing multiple files

Note: This extractor only supports English (CMUDict limitation).

Usage:

# Interactive mode (no arguments)
python -m build_tools.nltk_syllable_extractor

# Batch mode (with arguments)
python -m build_tools.nltk_syllable_extractor --file input.txt
python -m build_tools.nltk_syllable_extractor --source ~/corpus/ --recursive

Attributes

main_batch

main_interactive

process_single_file_batch

Functions

create_argument_parser()

Create and configure the argument parser for batch mode.

main([args])

Main entry point for the NLTK syllable extractor CLI.

Module Contents

build_tools.nltk_syllable_extractor.cli.main_batch
build_tools.nltk_syllable_extractor.cli.main_interactive
build_tools.nltk_syllable_extractor.cli.process_single_file_batch
build_tools.nltk_syllable_extractor.cli.create_argument_parser()[source]

Create and configure the argument parser for batch mode.

This function sets up the argparse parser with all command-line options for batch processing mode.

Returns:

Configured ArgumentParser instance ready to parse sys.argv.

Return type:

argparse.ArgumentParser

Example

>>> parser = create_argument_parser()
>>> args = parser.parse_args(["--file", "input.txt"])
>>> print(args.file)
PosixPath('input.txt')
build_tools.nltk_syllable_extractor.cli.main(args=None)[source]

Main entry point for the NLTK syllable extractor CLI.

This function determines whether to run in interactive or batch mode based on the presence of command-line arguments.

Parameters:

args (list[str] | None) – Command-line arguments. If None, uses sys.argv.

Returns:

Exit code (0 for success, non-zero for error).

Return type:

int

Modes:
  • Interactive Mode: No arguments provided. Prompts user for all settings.

  • Batch Mode: Arguments provided. Processes files based on CLI flags.

Examples

Interactive mode (no arguments):

$ python -m build_tools.nltk_syllable_extractor

Batch mode (with arguments):

$ python -m build_tools.nltk_syllable_extractor --file input.txt
$ python -m build_tools.nltk_syllable_extractor --files *.txt
$ python -m build_tools.nltk_syllable_extractor --source ~/docs/ --recursive