With the help of this library you can parse and create EmotionML with C#. Both, EmotionML documents and fragments, are supported. Furthermore you can work with the represented emotions a little bit.
You can download this library in a compiled format.
You can parse a whole EmotionML document or only parts of it with the build in EmotionML parser.
Load by XmlDocument:
XmlDocument emotionmlDoc = new XmlDocument(); emotionmlDoc.Load("your.emotionml"); Parser emotionmlParser = new Parser(emotionmlDoc);
Load by string:
Parser emotionmlParser = new Parser(emotionmlString);
After that you can access the parts of EmotionML document you need.
Whole EmotionML document:
EmotionMLDocument emotionmlDoc = emotionmlParser.getEmotionMLDocument();
List of emotions:
List<Emotion> emotionList = emotionmlParser.getEmotions();
Single emotion:
Emotion emotion = emotionmlParser.getSingleEmotion();
List of vocabularies:
List<Vocabulary> vocabularyList = emotionmlParser.getVocabularies();
Single vocabulary:
Vocabulary vocabulary = emotionmlParser.getSingleVocabulary();
You can create XmlDocument instances with the method ToDom() and XML with the method ToXml().
Add some emotions to an EmotionML document and output it as XML:
EmotionMLDocument emodoc = new EmotionMLDocument(); emodoc.addEmotion(emotion1); emodoc.addEmotion(emotion2); Console.Write(emodoc.ToXml());
Output single emotion as XmlDocument:
emotion1.ToDom();
In general every XML tag has it's own class. Furthermore there is a directory resources with some XSLT for validation and a file with the default vocabularies of EmotionML. This files are accessible via Helper::loadInternalResource(). However, here is a simplified class diagram:
- integration of automated tests
- references between emotions and vocabularies
- improvements in comparisons
License: FreeBSD