battle programmers alliance
Would you like to react to this message? Create an account in a few clicks or log in to continue.

battle programmers allianceLog in

the LivinGrimoire Artificial General Intelligence software design pattern forum

descriptionset the speech pattern for the bot uwu Emptyset the speech pattern for the bot uwu

more_horiz
added code to modify speech patterns. more patterns may be added in the future.
python code:

Code:

import random

from AXPython import AXNeuroSama


def chi_speech_pattern(input_string):
    # Split the input string into words
    words = input_string.split()

    # If the string is not empty, repeat the last word
    if words:
        last_word = words[-1]
        transformed_string = input_string + ' ' + last_word
    else:
        transformed_string = input_string

    return transformed_string


def uwu_converter(text):
    text = text.replace('r', 'w')
    text = text.replace('l', 'w')
    text = text.replace('R', 'W')
    text = text.replace('L', 'W')
    return text


def g_dropping_dialect(input_string):
    # Replace 'ing' with 'in''
    input_string = input_string.replace('ing ', 'in\' ')

    return input_string


def girly_speak(sentence):
    words = sentence.split()
    girly_words = []
    cute_phrases = ["teehee", "oh my goshies", "like, totally", "for sure", "super duper"]

    for word in words:
        if len(word) > 3 and word[-1] not in ['a', 'e', 'i', 'o', 'u', 'y']:
            girly_word = word + "ies"
        else:
            girly_word = word
        girly_words.append(girly_word)

    girly_sentence = " ".join(girly_words)

    if random.random() < 0.2:
        girly_sentence += ", " + random.choice(cute_phrases)

    return girly_sentence


def unrefined_speech_pattern(input_string):
    # Replace common words with their childish equivalents
    replacements = {
        ' I ': ' me ',
        ' my ': ' me\'s ',
        ' am ': ' is ',
        ' are ': ' is ',
        ' you ': ' yoo ',
        ' the ': ' da ',
        ' and ': ' an\' ',
        ' to ': ' ta '
    }

    for word, replacement in replacements.items():
        input_string = input_string.replace(word, replacement)

    # Add a playful "~" at the end of sentences
    input_string = input_string + '~'

    return input_string


def add_comrade(sentence):
    if random.randint(1, 4) == 1:
        return sentence + ' comrade'
    else:
        return sentence


def neuro_sama(sentence: str):
    return AXNeuroSama(3).decorate(sentence)

:s35:

descriptionset the speech pattern for the bot uwu EmptyRe: set the speech pattern for the bot uwu

more_horiz
update to the file:
it can now use synonyms
and also detect emotional vectors:

nl: nltk_beefUp = nltk_beefUp()
print(nl.replace_synonyms("i'm not your pal."))
print(nl.replace_synonyms("Write short paragraphs and cover one topic per paragraph. Long paragraphs discourage users from even trying to understand your material. Short paragraphs are easier to read and understand."))


i'm not your pal.
write short paragraph and screen one subject per paragraph. hanker paragraph deter user from evening try to understand your material. short paragraph are easy to read and understand.

print(detect_emotion("I love this!")) # Output: Positive
print(detect_emotion("I hate this!")) # Output: Negative
print(detect_emotion("I don't know.")) # Output: Neutral

Code:

import random

import nltk

from AXPython import AXNeuroSama
from nltk.corpus import wordnet
from textblob import TextBlob  # emotion detection


class nltk_beefUp:
    def __init__(self):
        nltk.download('wordnet')  # for synonims function

    @staticmethod
    def replace_synonyms(text):
        words = text.split()
        synonyms = []
        for word in words:
            syns = wordnet.synsets(word)
            if syns:
                synonyms.append(syns[0].lemmas()[0].name())
            else:
                synonyms.append(word)
        return ' '.join(synonyms)


def detect_emotion(text):
    blob = TextBlob(text)
    if blob.sentiment.polarity > 0:
        return "Positive"
    elif blob.sentiment.polarity < 0:
        return "Negative"
    else:
        return "Neutral"


def chi_speech_pattern(input_string):
    # Split the input string into words
    words = input_string.split()

    # If the string is not empty, repeat the last word
    if words:
        last_word = words[-1]
        transformed_string = input_string + ' ' + last_word
    else:
        transformed_string = input_string

    return transformed_string


def uwu_converter(text):
    text = text.replace('r', 'w')
    text = text.replace('l', 'w')
    text = text.replace('R', 'W')
    text = text.replace('L', 'W')
    return text


def g_dropping_dialect(input_string):
    # Replace 'ing' with 'in''
    input_string = input_string.replace('ing ', 'in\' ')

    return input_string


def girly_speak(sentence):
    words = sentence.split()
    girly_words = []
    cute_phrases = ["teehee", "oh my goshies", "like, totally", "for sure", "super duper"]

    for word in words:
        if len(word) > 3 and word[-1] not in ['a', 'e', 'i', 'o', 'u', 'y']:
            girly_word = word + "ies"
        else:
            girly_word = word
        girly_words.append(girly_word)

    girly_sentence = " ".join(girly_words)

    if random.random() < 0.2:
        girly_sentence += ", " + random.choice(cute_phrases)

    return girly_sentence


def unrefined_speech_pattern(input_string):
    # Replace common words with their childish equivalents
    replacements = {
        ' I ': ' me ',
        ' my ': ' me\'s ',
        ' am ': ' is ',
        ' are ': ' is ',
        ' you ': ' yoo ',
        ' the ': ' da ',
        ' and ': ' an\' ',
        ' to ': ' ta '
    }

    for word, replacement in replacements.items():
        input_string = input_string.replace(word, replacement)

    # Add a playful "~" at the end of sentences
    input_string = input_string + '~'

    return input_string


def add_comrade(sentence):
    if random.randint(1, 4) == 1:
        return sentence + ' comrade'
    else:
        return sentence


def neuro_sama(sentence: str):
    return AXNeuroSama(3).decorate(sentence)
privacy_tip Permissions in this forum:
You cannot reply to topics in this forum
power_settings_newLogin to reply