Skip to content

Commit

Permalink
add list of emotions and exception
Browse files Browse the repository at this point in the history
  • Loading branch information
gfobe committed Aug 2, 2012
1 parent 146b7aa commit f4bca09
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 1 deletion.
17 changes: 17 additions & 0 deletions EmotionException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EmotionML
{
[Serializable()]
public class EmotionException : System.Exception
{
public EmotionException() : base() { }
public EmotionException(string message) : base(message) { }
public EmotionException(string message, System.Exception inner) : base(message, inner) { }

protected EmotionException(System.Runtime.Serialization.StreamingContext context) { }
}
}
76 changes: 76 additions & 0 deletions EmotionList.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace EmotionML
{
class EmotionList : List<Emotion>
{
/// <summary>
/// emotions categories in current emotion annotation
/// </summary>
public EmotionSet<EmotionCategory> category = null;
/// <summary>
/// emotions dimensions in current emotion annotation
/// </summary>
public EmotionSet<EmotionDimension> dimension = null;
/// <summary>
/// emotions appraisals in current emotion annotation
/// </summary>
public EmotionSet<EmotionAppraisal> appraisal = null;
/// <summary>
/// emotions action tendencies in current emotion annotation
/// </summary>
EmotionSet<EmotionActionTendency> actionTendency = null;

/// <summary>
/// creates a DOM-list of emotions in list
/// </summary>
/// <returns>DOM of emotionml notation</returns>
public XmlDocument ToDom()
{
//init root node with attributes
XmlDocument emotionmlXml = new XmlDocument();
XmlElement emotionml = emotionmlXml.CreateElement("emotionml");

if (this.category != null)
{
emotionml.SetAttribute("category-set", this.category.getEmotionsetUri().AbsoluteUri);
}
if (this.dimension != null)
{
emotionml.SetAttribute("dimension-set", this.dimension.getEmotionsetUri().AbsoluteUri);
}
if (this.appraisal != null)
{
emotionml.SetAttribute("appraisal-set", this.appraisal.getEmotionsetUri().AbsoluteUri);
}
if (this.actionTendency != null)
{
emotionml.SetAttribute("action-tendency-set", this.actionTendency.getEmotionsetUri().AbsoluteUri);
}

//add emotions to list
for (int i = 0; i < this.Count; i++)
{
XmlDocument emotion = this.ElementAt(i).ToDom();
emotionml.AppendChild(emotion);
}

emotionmlXml.AppendChild(emotionml);

return emotionmlXml;
}

/// <summary>
/// creates EmotionML-XML for emotion list
/// </summary>
/// <returns>XML of emotions</returns>
public string ToXml()
{
return this.ToDom().ToString();
}
}
}
3 changes: 2 additions & 1 deletion EmotionML.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@
<Compile Include="EmotionActionTendency.cs" />
<Compile Include="EmotionAppraisal.cs" />
<Compile Include="EmotionCategory.cs" />
<Compile Include="EmotionCategorySet.cs" />
<Compile Include="EmotionDimension.cs" />
<Compile Include="EmotionException.cs" />
<Compile Include="EmotionInfo.cs" />
<Compile Include="EmotionList.cs" />
<Compile Include="EmotionML.cs" />
<Compile Include="EmotionmlDocument.cs" />
<Compile Include="EmotionPart.cs" />
Expand Down

0 comments on commit f4bca09

Please sign in to comment.