# 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.

## 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 on other sites
You can build a search tree.

Consider the case where the emoticons that are recognized are

 :-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 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 on other sites
awesome, thanks for the ideas guys.

1. 1
2. 2
Rutin
19
3. 3
JoeJ
16
4. 4
5. 5

• 35
• 23
• 13
• 13
• 17
• ### Forum Statistics

• Total Topics
631702
• Total Posts
3001812
×