116 lines
2.9 KiB
C++
116 lines
2.9 KiB
C++
#include <iostream>
|
|
#include <regex>
|
|
#include <string>
|
|
#include <random>
|
|
#include <argparse.hpp>
|
|
using namespace std;
|
|
|
|
string replacements[6][2] = {
|
|
{"(?:r|l)", "w"},
|
|
{"(?:R|L)", "W"},
|
|
{"n([aeiou])", "ny$1"},
|
|
{"N([aeiou])", "Ny$1"},
|
|
{"N([AEIOU])", "Ny$1"},
|
|
{"ove", "uv"}
|
|
};
|
|
|
|
string random_ending_replacents[11] = {
|
|
"uwu",
|
|
"owo",
|
|
"OwO",
|
|
"UwU",
|
|
"uwu",
|
|
"OwO",
|
|
">w<",
|
|
"Owo",
|
|
"X3",
|
|
":3",
|
|
">:3",
|
|
};
|
|
|
|
string full_word_replacents[20][2] = {
|
|
{"hello", "h-hello there"},
|
|
{"goodbye", "bai"},
|
|
{"bye", "bai"},
|
|
{"please", "p-pwease"},
|
|
{"thanks", "t-thank u"},
|
|
{"thank you", "t-thank u"},
|
|
{"you", "u"},
|
|
{"your", "ur"},
|
|
{"you're", "ur"},
|
|
{"you are", "ur"},
|
|
{"are", "r"},
|
|
{"the", "da"},
|
|
{"this", "dis"},
|
|
{"that", "dat"},
|
|
{"there", "dere"},
|
|
{"they", "dey"},
|
|
{"their", "dere"},
|
|
{"them", "dem"},
|
|
{"those", "dose"},
|
|
{"these", "deez"},
|
|
};
|
|
|
|
string random_ending(string input) {
|
|
string output = input;
|
|
for (int i = 0; i < output.length(); i++) {
|
|
if (output[i] == '.' || output[i] == '!' || output[i] == '?') {
|
|
output.insert(i, " " + random_ending_replacents[rand() % 11]);
|
|
i += random_ending_replacents[rand() % 11].length() + 1;
|
|
}
|
|
}
|
|
if (output[output.length()-1] != '.' && output[output.length()-1] != '!' && output[output.length()-1] != '?') {
|
|
output += " " + random_ending_replacents[rand() % 11];
|
|
}
|
|
return output;
|
|
}
|
|
|
|
string full_word(string input) {
|
|
string output = input;
|
|
for (int i = 0; i < 20; i++) {
|
|
output = regex_replace(output, regex(full_word_replacents[i][0]), full_word_replacents[i][1]);
|
|
}
|
|
return output;
|
|
}
|
|
|
|
string owo(string input, bool no_full_word = false, bool no_random_ending = false) {
|
|
string output = input;
|
|
if (!no_full_word){
|
|
output = full_word(output);
|
|
}
|
|
for (int i = 0; i < 6; i++) {
|
|
output = regex_replace(output, regex(replacements[i][0]), replacements[i][1]);
|
|
}
|
|
if (!no_random_ending) {
|
|
output = random_ending(output);
|
|
}
|
|
return output;
|
|
}
|
|
|
|
struct Args : public argparse::Args {
|
|
bool &no_full_word = flag("nfw", "Don't replace full words");
|
|
bool &no_random_ending = flag("nre", "Don't add random ending");
|
|
bool &_stdin = flag("p", "Read from stdin");
|
|
string &input = arg("input", "Input string").set_default("");
|
|
};
|
|
|
|
int main(int argc, char *argv[]) {
|
|
auto args = argparse::parse<Args>(argc, argv);
|
|
srand(time(nullptr));
|
|
|
|
if (argc == 1) {
|
|
args.help();
|
|
return 0;
|
|
}
|
|
|
|
if (args._stdin) {
|
|
string line;
|
|
while (getline(cin, line)) {
|
|
cout << owo(line, args.no_full_word, args.no_random_ending) << endl;
|
|
}
|
|
} else {
|
|
cout << owo(args.input, args.no_full_word, args.no_random_ending) << endl;
|
|
}
|
|
|
|
return 0;
|
|
} |