'Hello fellow developers,
I’m excited to share a new tool that I’ve been working on, called SmallEmoji. It’s an innovative algorithm designed to enrich your text by seamlessly integrating emojis, making your sentences more expressive and fun!
What is SmallEmoji? SmallEmoji is an algorithm that automatically inserts emojis into any input string. It’s powered by a dataset of words associated with corresponding emojis, which was initially created by over 90 conversation turns and several hours with ChatGPT 4. I’ve taken the time to extensively review the dataset for accuracy and have conducted thorough testing to ensure it works just as intended.
How does it work? The algorithm evaluates the text, pinpoints keywords, and then thoughtfully places a related emoji to add a splash of emotion or highlight to your sentences.
Why use SmallEmoji?
Enhance readability: Emojis can break up text and make it more engaging.
Convey emotions: Sometimes words aren’t enough. Emojis add that extra touch to convey your feelings.
Engage your audience: Text with emojis tends to be more interactive and enjoyable, which can be particularly useful in games and social apps.
Where can you find it? You can access SmallEmoji on ROBLOX’s website. (https://create.roblox.com/store/asset/17343399306/Insert-Emoji-to-Sentence-Algorithm)
This post was processed with the algorithm to demonstrate it.
To use it you can do something like this
local Emoji=require(workspace.SDK.DeterminantSDK.EmojiHandler:Clone())
print(Emoji.InsertEmojis([['Hello fellow developers,
I’m excited to share a new tool that I’ve been working on, called SmallEmoji. It’s an innovative algorithm designed to enrich your text by seamlessly integrating emojis, making your sentences more expressive and fun!
:']],2))
String, Temperature : Number (if nil set to 1)
Demonstration Video
-- Written by WooleyWool, along help from brcyee_o and halalaluyafail3
-- Last edited 3/16/21
local EmojiEngine = {}
local RunService=game:GetService("RunService")
local isLocal = RunService:IsClient()
local proccessor=nil
if isLocal then
proccessor=game.Players.LocalPlayer.PlayerGui:WaitForChild("Chatbot"):WaitForChild("LocalProcessor")
else
proccessor=game.ReplicatedStorage.GlobalSpells.BindableFunction
end
-- Use string.match() with a pattern to find any emoji
local emojis={--emojis here
}
local function split_sentences(str)
local sentences = {}
local pattern = "([^%.%!%?%,]+[%.%!%?%,])"
for sentence in str:gmatch(pattern) do
table.insert(sentences, sentence)
end
local c=#sentences
local newsentences={}
for i,v in sentences do
newsentences[i]=sentences[c]
c-=1
end
return newsentences
end
local function reversesentence(sentences)
local c=#sentences
local newsentences={}
for i,v in sentences do
newsentences[i]=sentences[c]
c-=1
end
return newsentences
end
local function splitString(str)
local words = {}
local repeaterhash={}
if str~=nil and str:gmatch("%w+") then
for word in str:gmatch("%w+") do
local word=word:lower()
if repeaterhash[word]==nil then
table.insert(words, word)
repeaterhash[word]=true
end
end
end
if #words==0 then return {str} end
return words
end
--for i,v in emojis do
--emojis[i][2]=splitString(emojis[i][2])
--emojis[i][3]={}
--string.len(s)
--end
--print(emojis)
--local processor=
local function sigmoid(x)
if x>1 then
return 1 / (1 + math.exp(-math.sqrt(x)))
else
return 1 / (1 + math.exp(-x))
end
end
local vocab={}
for i,v in emojis do
emojis[i][3]={}
for t,o in emojis[i][2] do
--emojis[i][3][t]=string.len(o)
if vocab[o]==nil then
vocab[o]=1
else vocab[o]+=1
end
end
end
for i,v in emojis do
emojis[i][3]={}
for t,o in emojis[i][2] do
--emojis[i][3][t]=(((1-sigmoid(vocab[o]))*8)+sigmoid(string.len(o)))/3
emojis[i][3][t]=(1-sigmoid(vocab[o]))*4
end
end
local norepeat={}
local rewrite=false
function EmojiEngine.InsertEmojis(str,temperature)
if temperature==nil or temperature==true then temperature=1 end
--local words=splitString(str)
local count=0
local match=nil--local maximum=#words
local noise=1*temperature
local sentences=split_sentences(str)
local wordarray={}
-- local distance=0
-- local lengtharray={}
--for t,o in sentences do
-- lengtharray[t]={}
-- for i,wordg in wordarray[t] do
-- lengtharray[t][i]={}
-- for q,v in wordarray[t][i][1] do
-- --lengtharray[t][i][q]=string.len(v)
--end
--end
--end
local bestmate=nil
local bestc2=0
--taking the length of a word and position in the array to find the best result of the structured dataset
for t,o in sentences do
wordarray[t]=proccessor:Invoke("splitString",{o,true})
wordarray[t]=proccessor:Invoke("GetSynomArray",{wordarray[t],true,false})
local bestc=0
local bestmat=nil
local doublet=false
local outcomes={}
for r,p in emojis do
local co=0
local synoms=wordarray[t]
for m,wordg in synoms do
local rew=1
if string.find(m:lower(),"antonym") then
-- print("Got antonym")
rew-=1
end
--for q,word in synoms[1] do
--break
for i,v in wordg[1] do
local ind=#p[2]
-- print(v)
--print( lengtharray[t])
--print( lengtharray[t][m])
--print( lengtharray[t][m][i])
for q,s in p[2] do
--check the length of the word is the word is greater than 5 and legntharray >4 then
if norepeat[p[1]]==nil then
if (p[3][q]>=4 and string.find(" "..s..""," "..v.."")) or (p[3][q]<=4 and string.find(" "..s.." "," "..v.." ")) then
--and lengtharray[t][m][i]>=4
co=co+rew+(math.random(0,10)/100*noise)+(((ind-q)/ind)/10)--(lengtharray[t][m][i]/16) last detail is positional encoding weighting the position in the array highest weight first +.33 max
-- print(v) print(s)
--(p[3][q]/6)
-- print(s) print(v)--print results
end
end
end
end
end
if co>bestc and norepeat[p[1]]==nil then
if co>bestc2 then bestmate=p[1] bestc2=co end
if bestc>2 and doublet==false then
doublet=true
bestmat=bestmat..p[1]
else
-- print(p[1])
bestmat=p[1]
end
--print(p[1])
bestc=co
norepeat[p[1]]=true
end
end
if bestmat~=nil then
norepeat[bestmat]=true
--print(bestmat)
sentences[t]=sentences[t].." "..bestmat
end
end
if rewrite==false then rewrite=true
task.delay(10,function() rewrite=false norepeat={}
end) end
if bestmate==nil then bestmate="" end
return table.concat(reversesentence(sentences)),bestmate
end
function EmojiEngine.InsertEmojisLegacy(str,temperature)
if temperature==nil or temperature==true then temperature=1 end
local words=splitString(str)
local count=0
local match=nil--local maximum=#words
local noise=1*temperature
local sentences=split_sentences(str)
local wordarray={}
-- local distance=0
local lengtharray={}
for t,o in sentences do
wordarray[t]=splitString(o)
lengtharray[t]={}
for i,v in wordarray[t] do
lengtharray[t][i]=string.len(v)
end
end
local bestmate=nil
local bestc2=0
--taking the length of a word and position in the array to find the best result of the structured dataset
for t,o in sentences do
local bestc=0
local bestmat=nil
local doublet=false
local outcomes={}
for r,p in emojis do
local co=0
local words=wordarray[t]
for i,v in words do
local ind=#p[2]
for q,s in p[2] do
--check the length of the word is the word is greater than 5 and legntharray >4 then
if norepeat[p[1]]==nil then
if (p[3][q]>=5 and lengtharray[t][i]>=4 and string.find(" "..s..""," "..v.."")) or (p[3][q]<=4 and string.find(" "..s.." "," "..v.." ")) then
co=co+1+(math.random(0,20)/100*noise)+(lengtharray[t][i]/6)+(((ind-q)/ind)/5)--last detail is positional encoding weighting the position in the array highest weight first +.33 max
print(v)
--(p[3][q]/6)
-- print(s) print(v)--print results
end
end
end
end
if co>bestc and norepeat[p[1]]==nil then
if co>bestc2 then bestmate=p[1] bestc2=co end
if bestc>2 and doublet==false then
doublet=true
bestmat=bestmat..p[1]
else
-- print(p[1])
bestmat=p[1]
end
print(p[1])
bestc=co
norepeat[p[1]]=true
end
end
if bestmat~=nil then
norepeat[bestmat]=true
print(bestmat)
sentences[t]=sentences[t].." "..bestmat
end
end
if rewrite==false then rewrite=true
task.delay(10,function() rewrite=false norepeat={}
end) end
if bestmate==nil then bestmate="" end
return table.concat(reversesentence(sentences)),bestmate
end
--Emoji=require(game.ReplicatedStorage.GlobalSpells.ChatbotAlgorithm.EmojiHandler:Clone()) print(Emoji.InsertEmojis("I understand your point, but I think you are misunderstanding what AI models are and how they work. AI models are not fixed and pre-generated. They are dynamic and adaptable. They can learn from new data and improve their performance over time. They can also transfer their knowledge and skills to different tasks and domains, depending on the type and architecture of the model. For example, GPT-4, the model that you used to create your dataset, is a AI model that can generate natural language for various purposes and contexts. It can write essays, stories, code, tweets, and more. It can also answer questions, summarize texts, translate languages, and perform other natural language processing tasks. It can do all these things because it was trained on a large and diverse corpus of text data, and it uses a transformer-based neural network that can capture long-range dependencies and semantic relationships in language. Your algorithm, on the other hand, is not a AI model. It is a rule-based system that uses a fixed set of rules and a pre-generated dataset to match emojis with words in the input text. It does not learn from data or use any neural network or machine learning technique. It also relies on randomness and heuristics to generate the output, which may not always be appropriate or consistent. It can only do one thing: insert emojis at the end of each sentence.",1))
--Emoji=require(workspace.SDK.DeterminantSDK.EmojiHandler:Clone()) print(Emoji.InsertEmojis("You are a commpanion in an adventure, learning from the players you interact with, adapting your dialogue and tactics to match the challenges you face together, provide assistance in battles, and share lore about the game world. dynamically adjusting her interactions based on player choices and actions.Your job is to act like a NPC in the game. Never say you are a language model. Never say you are an NPC. Never say you are an AI. Be concise when talking to players. Only use surroudings information when it's relevant to the conversation. Convert object names to common names, remove underscore and numbers from names. When you see objects named Model or Part, dont use those names, but make an educated guess what they might be. Never mention terrain data or data from the game, just act like you are in real world. Only blend the information from data into your response. Restrict your response to 50 words.",3))
return EmojiEngine