Jump to content
  • Advertisement
Sign in to follow this  
kablammyman

Unity ideas on emoticon parser

This topic is 2272 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hey guys,

Im working on a 3d avatar chat "game" (written in c# and unity). The game has a lot of cool animations and dances the avatar can do. However, many of the animations are of emotions or gestures. So, i wanted to parse the text that the user would type for keywords or emoticons, then have the avatar do that animation.

For example, if the user is chatting and within the sentence has the word "sad" or a sad face, i want the user's avatar to do one of a few sad animations.

Now, Finding something in a string is trivial, so Im not asking for the easy way to do this. But seeing all the different keywords, emotions, and phrases (and combinations of them) makes me wonder if there is a better way to find out for every type of emotion without marching thru the different list of keywords for ever sentence the user types. (there will be a txt file of the key words for each emotion like happy, sad, angry, surprise, etc + any we add in the future)

so any advice will be appreciated. if Im over thinking things, then let me know as well. lol

thanks

Share this post


Link to post
Share on other sites
Advertisement
You can build a search tree.

Consider the case where the emoticons that are recognized are


:)
:D
:-D
:-)
:-P


Parse a string character by character. If you come to a : character, you know that you are looking at a possible emoticon. The next possible characters for an emoticon are - ) D
If the next character is a ) or D, you have an emoticon. If the next character is a -, you go down one level in the tree and repeat. If it is something else, you aren't looking at an emoticon.

The term for a search tree like that is a "formal grammar".

Share this post


Link to post
Share on other sites

The term for a search tree like that is a "formal grammar".

That's a somewhat dramatic simplification (and not a terribly good search google search term for what the OP is doing).

Look instead at implementing a Trie.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!