# [1] pry(#)> translate_to_slang(response.downcase) # JSON::ParserError: 859: unexpected token at '' # gem install --user-install specific_install # gem specific_install --user-install https://github.com/phaul/cinch.git # gem install --user-install nlpcloud # gem install --user-install urbandict require "cinch" require "nlpcloud" require "urbandict" require "pry" $nlpcloud_token = "7f82dd1d65f6019b06511923b2fb0275e0795c2c" # https://docs.nlpcloud.com/#chatbot-and-conversational-ai client = NLPCloud::Client.new("finetuned-gpt-neox-20b", $nlpcloud_token, gpu: true, lang: "en") # -- slang = { "hello" => "yo", "goodbye" => "peace out", "cool" => "dope", "awesome" => "sick", "really" => "hella", "you" => "u" } def translate_to_slang(input) # Split the input sentence into individual words words = input.split # Loop through each word in the input sentence words.each_with_index do |word, index| # Look up the slang term for the word in the Urban Dictionary term = UrbanDictionary.define(word) # If a slang term was found, replace the original word with the slang term if term words[index] = term.word end # Replace each word with its slang equivalent, if it exists slang[word] || word end # Join the modified words back into a sentence return words.join(" ") end # -- pickup_lines = [ "Well, here I am. What are your other two wishes?", "Hey, my name's Microsoft. Can I crash at your place tonight?", "Are you French? Because Eiffel for you.", "Do you like raisins? How do you feel about a date?", "There is something wrong with my cell phone. It doesn't have your number in it.", "If I could rearrange the alphabet, I'd put 'U' and 'I' together.", "Aside from being sexy, what do you do for a living?", "I must be a snowflake, because I've fallen for you.", "Are you from Tennessee? Because you're the only 10 I see!", "If you were a Transformer, you'd be Optimus Fine.", "Are you a parking ticket? Because you've got FINE written all over you.", "I wish I were cross-eyed so I can see you twice.", "I must be in a museum, because you truly are a work of art.", "Do you believe in love at first sight, or should I walk by again?", "I'm no photographer, but I can picture us together.", "Feel my shirt. Know what it's made of? Boyfriend material.", "Are you related to Jean-Claude Van Damme? Because Jean-Claude Van Damme you're sexy!", "If you were a chicken, you'd be impeccable.", "Did your license get suspended for driving all these guys crazy?", "I'm learning about important dates in history. Wanna be one of them?", "Baby, if you were words on a page, you'd be fine print.", "Did you just come out of the oven? Because you're hot.", "It's a good thing I have my library card because I am totally checking you out.", "I was blinded by your beauty; I'm going to need your name and phone number for insurance purposes.", "I was wondering if you had an extra heart. Because mine was just stolen.", "Is your name Google? Because you have everything I've been searching for.", "Are you a bank loan? Because you got my interest.", "Are you a time traveler? Cause I see you in my future!", "Can I follow you where you're going right now? Because my parents always told me to follow my dreams.", "Is this the Hogwarts Express? Because it feels like you and I are headed somewhere magical.", "Life without you is like a broken pencil, pointless.", "Something's wrong with my eyes because I can't take them off you.", "My love for you is like diarrhea, I just can't hold it in.", "Somebody better call God, because he's missing an angel.", "We're not socks, but I think we'd make a great pair.", "You must be tired because you've been running through my mind all night.", "Do you have a map? I keep getting lost in your eyes.", "Do you have a BandAid? I just scraped my knee falling for you.", "Do you like Star Wars? Because Yoda only one for me!", "Did you invent the airplane? Because you seem Wright for me.", "Did the sun come out or did you just smile at me?", "Do you know CPR? Because you are taking my breath away!", "You're so beautiful that you made me forget my pickup line." ] # -- bot = Cinch::Bot.new do configure do |c| c.nick = "RapBot4000" c.server = "irc.libera.chat" c.channels = ["#ruby"] end # Handle incoming messages from users on :message do |m| response = client.chatbot(m.message)["response"] binding.pry m.reply translate_to_slang(response.downcase) # Maybe say something cute if [true, false].sample new_line = client.paraphrasing(pickup_lines.sample)["paraphrased_text"] m.reply translate_to_slang(new_line.downcase) end end end bot.start