7 releases

0.3.4 Nov 15, 2024
0.3.3 Nov 15, 2024
0.2.0 Nov 14, 2024
0.1.0 Nov 14, 2024

#366 in Text processing

Download history 179/week @ 2024-11-08 365/week @ 2024-11-15 3/week @ 2024-11-22 2/week @ 2024-11-29 8/week @ 2024-12-06

557 downloads per month

MIT license

19KB
374 lines

uwurs

UwUify your strings with uwurs! This Rust library transforms text into the playful "UwU" style by applying various character transformations, adding stutters, leetifying text, and more.

This documentation corresponds to uwurs version 0.3.1

[dependencies]
uwurs = "0.3.1"
rand = "0.8.5"

Quick Start

  • Install by adding to Cargo.toml or via cargo add uwurs
  • Import and create an instance of UwUifier.
  • Transform your text using provided methods.
  • Customize settings and mappings as desired.
  • Enjoy UwUifying your text!

Usage

Creating an Instance

To start using uwurs, create a new instance of UwUifier:

use uwurs::UwUifier;

fn main() {
    let uwuifier = UwUifier::new();
    let input = "Hello, world!";
    let uwuified = uwuifier.uwuify(input);
    println!("{}", uwuified);
}

Uwuify Text

Transform a string into UwU style:

let input = "This is a test.";
let uwuified = uwuifier.uwuify(input);
println!("{}", uwuified);

Leetify Text

Convert text to leet speak:

let input = "Leetify this text.";
let leet = uwuifier.leetify(input);
println!("{}", leet);

Reverse Text

Reverse the characters in a string:

let input = "Reverse this.";
let reversed = uwuifier.reverse_text(input);
println!("{}", reversed);

Configuration

Setting Stutter Probability

Adjust the probability of adding stutters to words:

uwuifier.set_stutter_probability(0.2); // 20% chance

Setting Emoji Probability

Adjust the probability of adding emojis:

uwuifier.set_emoji_probability(0.3); // 30% chance

Adding Emoticons

Add custom emoticons to the UwUifier:

uwuifier.add_emoticon("(* ^ ω ^)");

Adding Interjections

Add custom interjections:

uwuifier.add_interjection("nya");

Adding Custom Mappings

Define custom word mappings:

uwuifier.add_custom_mapping("hello", "hewwo");

Adding Emoji Mappings

Associate words with emojis:

uwuifier.add_emoji_mapping("happy", "😊");

API Reference

UwUifier Struct

pub struct UwUifier {
    pub emoticons: Vec<&'static str>,
    pub interjections: Vec<&'static str>,
    pub stutter_probability: f64,
    pub emoji_probability: f64,
    pub custom_map: HashMap<String, String>,
    pub emoji_map: HashMap<String, String>,
}

Methods

Create a new UwUifier instance with default settings

new() -> Self

Transform the input string into UwU style

uwuify(&self, input: &str) -> String

Set the probability for stuttering

set_stutter_probability(&mut self, probability: f64)

Set the probability for adding emojis

set_emoji_probability(&mut self, probability: f64)

Add a new emoticon to the list

add_emoticon(&mut self, emoticon: &'static str)

Add a new interjection

add_interjection(&mut self, interjection: &'static str)

Add a custom word mapping

add_custom_mapping(&mut self, from: &str, to: &str)

Associate a word with an emoji

add_emoji_mapping(&mut self, word: &str, emoji: &str)

Convert the input string to leet speak

leetify(&self, input: &str) -> String

Reverse the input string

reverse_text(&self, input: &str) -> String

Transformation Functions

Transform specific characters to UwU style

apply_character_transformations

Add a stutter to a word based on probability

apply_stutter

Convert characters to their leet equivalents

leetify

Reverse the input string

reverse_text

Examples

Basic Uwuification

use uwurs::UwUifier;

fn main() {
    let uwuifier = UwUifier::new();
    let input = "I love programming!";
    let uwuified = uwuifier.uwuify(input);
    println!("{}", uwuified);
}

Custom Mappings and Emojis

use uwurs::UwUifier;

fn main() {
    let mut uwuifier = UwUifier::new();
    uwuifier.add_custom_mapping("friend", "fwiend");
    uwuifier.add_emoji_mapping("happy", "😊");
    
    let input = "Hello, my friend! I am happy.";
    let uwuified = uwuifier.uwuify(input);
    println!("{}", uwuified);
}

Leetify and Reverse Text

use uwurs::UwUifier;

fn main() {
    let uwuifier = UwUifier::new();
    
    let leet = uwuifier.leetify("Leetify this text.");
    println!("{}", leet);
    
    let reversed = uwuifier.reverse_text("Reverse this.");
    println!("{}", reversed);
}

Contributing

Contributions are welcome! Please submit a pull request or open an issue on the GitHub Repository.

If you'd like to contribute to uwurs, please follow these steps:

  • Fork the repository.
  • Create a new branch for your feature or bugfix.
  • Commit your changes with clear messages.
  • Submit a pull request detailing your changes.
  • Please ensure that your code follows the project's coding standards and includes appropriate tests.

License

This project is licensed under the MIT License.

Dependencies

~2.3–3.5MB
~59K SLoC