An open API service indexing awesome lists of open source software.

https://github.com/lostjared/code2text

Code2Text: A Random Text Generator for AI-Driven Image Creation
https://github.com/lostjared/code2text

Last synced: 3 months ago
JSON representation

Code2Text: A Random Text Generator for AI-Driven Image Creation

Awesome Lists containing this project

README

          

# code2text

![ScreenShot1](https://github.com/lostjared/code2text/blob/main/images/ss.png?raw=true "screenshot1")

## Overview
`code2text` is a versatile tool designed to generate random words from text files or source code. It provides a wide range of options to customize the output based on your specific needs, including filtering by word length, selecting words with underscores, and output customization.

## Motivation
To be able to use large amounts of text and generate random words from that text quickly and easily from the terminal. It can be used kind of like an advanced mad libs.

## Installation
Clone the repository and build the project using Rust's package manager, Cargo.

```bash
git clone https://example.com/code2text.git
cd code2text
cargo build --release
```

The executable will be located in `./target/release/`.

## Usage

### Advanced Options
`code2text` supports several command-line options to fine-tune its behavior:

- `-i filename.txt`: Specify the input filename. If omitted, `code2text` reads from STDIN.
- `-u`: Only include words that contain underscores.
- `-n`: Set the number of words to find.
- `-l`: Specify the minimum length of words to include.
- `-m`: Set the maximum length of words to include.
- `-o`: Output the result to a specified filename. By default, the output is printed to STDOUT.
- `-s`: Sort the output list of words.
- `-g`: Specify a filename for the output log.
- `-w`: List all collected words before generating the output.
- `-r`: Replace text in the input file with collected words (advanced usage; see below for examples).

### Examples
Generate 10 random words of at least 5 characters from `words.txt` and sort them:

```bash
./code2text -i words.txt -n 10 -l 5 -s
```

## Advanced Text Replacement
The `-r` option allows you to replace placeholders in your text with the words generated by `code2text`. Placeholders should be formatted as `%1`, `%2`, etc., in your text file.

For example:

```bash
./code2text -i input.txt -r template.txt -n 5 -o replaced.txt
```

This command will replace placeholders in `template.txt` with 5 random words from `input.txt` and save the result to `replaced.txt`.

## Contributing
Contributions are welcome! Please fork the repository and submit a pull request with your proposed changes.

## License
`code2text` is open-source software licensed under the GNU GPLv3.