SmallEmoji V1.2 - Insert Emoji to Sentence Algorithm [Open Source] Update: Sigmoid

It’s funny you mention that, that what I’m using it for. Just open sourcing novel pieces of my chatbots architecture. It’s considered complete. I like using it. The version that’s not open sourced may be slightly better but this version is pretty good.
I like your creativity, I have an emotional classification dataset that I use for interpreting emotions
(https://www.roblox.com/library/17345586792)
It works based off this algorithm.

function cm.score_string(str)
   -- Convert the string to lower case and split it into words
   

   -- Initialize a table of scores for each emotion
   local scores = {}
   for _, emotion in ipairs({"Epic", "Happy", "Polite", "Mystery", "Question", "Sad", "Scary", "Angry"}) do
   	scores[emotion] = 0
   end
   str = str:lower()
   local words = cm.splitString(str,nil,true)
   --local weight=#words
   -- Loop through each word and increment the score for the matching emotion
   --for _, word in ipairs(words) do
   if EmotionalClassification==nil and not isLocal then
       EmotionalClassification=require(game.ReplicatedStorage.GlobalSpells.ChatbotAlgorithm.EmotionalClassification)
      emotiondata={Epic=EmotionalClassification[1],
       Happy=EmotionalClassification[2],
       Mystery=EmotionalClassification[3],
       Question=EmotionalClassification[4],
       Sad=EmotionalClassification[5],
       Scary=EmotionalClassification[6],
       Angry=EmotionalClassification[7],
       Polite=EmotionalClassification[8]}
       EmotionalClassification=1
   end
   if not isLocal then
   -- Initialize a table of scores for each emotion
   local scores = {}
   for _, emotion in ipairs({"Epic", "Happy", "Polite", "Mystery", "Question", "Sad", "Scary", "Angry"}) do
       scores[emotion] = 0
   end

   -- Loop through each word and increment the score for the matching emotion
   for emotion, guide_words in  emotiondata do
    -- print(emotion)
     --  local guide_words =  checkemot(emotion) -- Get the global table of guide words for the emotion
      -- print(guide_words)
       
       for _, t in words do					         
          local synoms=cm.Getsynonyms(t,true)
           for i,word in synoms do
           if guide_words[word] then
               scores[emotion] = scores[emotion] + 1
             --  break    
               end
            end   
       end

   end
   --end
   local emotion,score=cm.get_emotion(scores)
   -- Return the table of scores
   	return score,emotion--,weight
   else return 0,nil	
   end
end

function cm.getemotion(str)
   local emotionscores,emotion=cm.score_string(str)
   return emotion,emotionscores
end	
--Example Code
function cm.splitString(str,filter,lower)
local words = {}
 --  str=cm.Duplicates(str)
  -- str= Removepunc(str) 
  -- print(str)
   if str~=nil then	
   --   if filter==true then str=cm.ReduceWords(str) end  
       if str:gmatch("%w+") then
           for word in str:gmatch("%w+") do
            if lower==nil then  word=word:lower() end
              table.insert(words, word)                      			                              
           end                
       end
   end    
   if #words==0 then 
       return {str} 
   end			
   return words		
end

I use this play ambient music based on the theme of the text classification.
I have a similar algorithm as the emoji one for a library of different 140 emotes

local AnimationEngine = {}
local AnimationLibrary=script.AnimationsLibrary:GetChildren()
local SearchArray={}


local function splitString(str)
	local words = {}
	--  str=cm.Duplicates(str)
	-- print(str)
	if str~=nil then	
		if str:gmatch("%w+") then
			for word in str:gmatch("%w+") do
				word=word:lower() 
				table.insert(words, word)                      			                              
			end                
		end
	end    
	if #words==0 then 
		return {str} 
	end			
	return words		
end	

for i,v in AnimationLibrary do
	SearchArray[v]={splitString(v.Value.Value),math.random(75,125)/100}--assign random weight to each animation 
end

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
function AnimationEngine.Emotes(str,temperature)
	--local synoms
	local words=proccessor:Invoke("splitString",{str,true})
	--if proccessor  then
	local synoms=proccessor:Invoke("GetSynomArray",{words,true,false})
--	end	
	local count=0
	local match=nil
	local maximum=#words
	local threshold=1/temperature
	local noise=.1*temperature
	local address=nil
	if threshold>0 then
		for y,words in synoms do --words of the npc
			local rew=1	
			if string.find(y:lower(),"antonym") then
				rew=-.5
			end
		for r,f in words do --words of the npc
			for i,v in SearchArray do 
				local c=0
				for t,o in v[1] do
					if string.find(f,o) then
							c+=rew+(noise*(math.random(75,100)/100*v[2]))
							break -- only one match per synom group
					end		
				end
				if c>count and c>threshold then
					count=c
					match=i
					address=i
				end
		end
			end
		end
	end
	if address~=nil then
		SearchArray[address][2]=SearchArray[address][2]/1.2--adjust the weights to reduce chance of repetition 
	--guess it can learn the least used animation	
	end	
	return address -- return the animation object
end
--local iemotes=require(game.ServerScriptService.DeterminantAI.IntelligentEmotes)
return AnimationEngine

I open source what I can.

Chatbot & LLM Artificial Intelligence Model API Code Documentation FREE (Open Source) and Other Useful APIs

1 Like