Package com.tagtraum.audiokern.mood
Class Mood
- java.lang.Object
-
- com.tagtraum.audiokern.mood.Mood
-
- All Implemented Interfaces:
Externalizable
,Serializable
,org.json.simple.JSONAware
public class Mood extends Object implements Externalizable, org.json.simple.JSONAware
Valence/arousal based mood. Internally used mood constants/angles are derived from J. A. Russell, "A circumspect model of affect", Journal of Personality and Social Psychology, vol. 39, no. 6, p. 1161, 1980.
-
-
Field Summary
Fields Modifier and Type Field Description static Mood
AFRAID
static Mood
ALARMED
static Mood
ANGRY
static Mood
ANNOYED
static Mood
AROUSED
static Mood
ASTONISHED
static Mood
BORED
static Mood
CALM
static Mood[]
CATEGORIES
static Mood[]
CATEGORIES_NO_NEUTRAL
static Mood
CATEGORY_AROUSED
static Mood
CATEGORY_CONTENT
static Mood
CATEGORY_DEPRESSED
static Mood
CATEGORY_DISTRESSED
static Mood
CATEGORY_EXCITED
static Mood
CATEGORY_MISERABLE
static Mood
CATEGORY_NEUTRAL
static Mood
CATEGORY_PLEASED
static Mood
CATEGORY_SLEEPY
static Mood
DELIGHTED
static Mood
DEPRESSED
static Mood
DISTRESSED
static Mood
DROOPY
static Mood
EXCITED
static Mood
FRUSTRATED
static Mood
GLAD
static Mood
GLOOMY
static Mood
HAPPY
static Mood[]
LABELED_MOODS
static byte
MAX_AROUSAL
static float
MAX_STRENGTH
static byte
MAX_VALENCE
static Mood
MISERABLE
static Mood
NEUTRAL
static Mood
PLEASED
static Mood
RELAXED
static Mood
SAD
static Mood
SERENE
static Mood
SLEEPY
static Mood
TENSE
static Mood
TIRED
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description float
cosineSimilarity(float otherAngle)
float
cosineSimilarity(int valence, int arousal)
float
cosineSimilarity(Mood mood)
Compares the angles of two moods and returns a number between -1 and 1.boolean
equals(Object o)
float
getAngle()
Angle of this emotion in a circumspect model.int
getArousal()
Arousal of this song.Mood
getCategory()
One of nine categories this mood can be grouped into.int
getCategoryOrdinal()
One of nine categories this mood can be grouped into.Mood
getClosestLabeledMood()
One of a number of labeled moods this mood is most similar to.float[]
getComponents()
Mood components valence and arousal scaled to the range-1
to1
.String
getLabel()
Color
getRedGreenSaturation()
Maps valence to values from red (negative) to green (positive) and indicates the associated arousal through saturation.static Color
getRedGreenSaturation(int valence, int arousal)
Maps valence to values from red (negative) to green (positive) and indicates the associated arousal through saturation.float
getStrength()
Indicates the strength of an emotion, assuming a no-strength center in the middle of the valence/arousal scale.MoodStrength
getStrengthClass()
Classifies this mood into a strength class.int
getValence()
Valence of this song.static Mood
guessMood(String... words)
Attempt to derive a mood from the given word list.int
hashCode()
void
readExternal(ObjectInput in)
void
setArousal(int arousal)
Sets the arousal - a value ranging from -100 to +100.void
setLabel(String label)
void
setValence(int valence)
Sets the valence - a value ranging from -100 to +100.String
toJSONString()
String
toString()
void
writeExternal(ObjectOutput out)
-
-
-
Field Detail
-
MAX_AROUSAL
public static byte MAX_AROUSAL
-
MAX_VALENCE
public static byte MAX_VALENCE
-
MAX_STRENGTH
public static float MAX_STRENGTH
-
HAPPY
public static final Mood HAPPY
-
DELIGHTED
public static final Mood DELIGHTED
-
EXCITED
public static final Mood EXCITED
-
ASTONISHED
public static final Mood ASTONISHED
-
AROUSED
public static final Mood AROUSED
-
TENSE
public static final Mood TENSE
-
ALARMED
public static final Mood ALARMED
-
ANGRY
public static final Mood ANGRY
-
AFRAID
public static final Mood AFRAID
-
ANNOYED
public static final Mood ANNOYED
-
DISTRESSED
public static final Mood DISTRESSED
-
FRUSTRATED
public static final Mood FRUSTRATED
-
MISERABLE
public static final Mood MISERABLE
-
SAD
public static final Mood SAD
-
GLOOMY
public static final Mood GLOOMY
-
DEPRESSED
public static final Mood DEPRESSED
-
BORED
public static final Mood BORED
-
DROOPY
public static final Mood DROOPY
-
TIRED
public static final Mood TIRED
-
SLEEPY
public static final Mood SLEEPY
-
CALM
public static final Mood CALM
-
RELAXED
public static final Mood RELAXED
-
SERENE
public static final Mood SERENE
-
GLAD
public static final Mood GLAD
-
PLEASED
public static final Mood PLEASED
-
NEUTRAL
public static final Mood NEUTRAL
-
CATEGORY_PLEASED
public static final Mood CATEGORY_PLEASED
-
CATEGORY_EXCITED
public static final Mood CATEGORY_EXCITED
-
CATEGORY_AROUSED
public static final Mood CATEGORY_AROUSED
-
CATEGORY_DISTRESSED
public static final Mood CATEGORY_DISTRESSED
-
CATEGORY_MISERABLE
public static final Mood CATEGORY_MISERABLE
-
CATEGORY_DEPRESSED
public static final Mood CATEGORY_DEPRESSED
-
CATEGORY_SLEEPY
public static final Mood CATEGORY_SLEEPY
-
CATEGORY_CONTENT
public static final Mood CATEGORY_CONTENT
-
CATEGORY_NEUTRAL
public static final Mood CATEGORY_NEUTRAL
-
CATEGORIES_NO_NEUTRAL
public static final Mood[] CATEGORIES_NO_NEUTRAL
-
CATEGORIES
public static final Mood[] CATEGORIES
-
LABELED_MOODS
public static final Mood[] LABELED_MOODS
-
-
Constructor Detail
-
Mood
public Mood(int valence, int arousal) throws IllegalArgumentException
Mood.- Parameters:
valence
- -100 <= valence <= +100arousal
- -100 <= arousal <= +100- Throws:
IllegalArgumentException
- if the parameters aren't in the valid range
-
Mood
public Mood(int valence, int arousal, String label) throws IllegalArgumentException
Mood.- Parameters:
valence
- -100 <= valence <= +100arousal
- -100 <= arousal <= +100label
- description- Throws:
IllegalArgumentException
- if the parameters aren't in the valid range
-
Mood
public Mood()
Mood.
-
Mood
public Mood(String jsonString)
Instantiate from JSON string.- Parameters:
jsonString
- json string- See Also:
toJSONString()
-
Mood
public Mood(float angleInRadians, String label, float strength) throws IllegalArgumentException
Mood.- Parameters:
angleInRadians
- angleInRadianslabel
- labelstrength
- value between 0 and 100.- Throws:
IllegalArgumentException
- if strength is greater than 100
-
-
Method Detail
-
cosineSimilarity
public float cosineSimilarity(Mood mood)
Compares the angles of two moods and returns a number between -1 and 1. -1 being most dissimilar, 0 being orthogonal and 1 being the same.- Parameters:
mood
- another mood,null
will always lead to a similarity of 0- Returns:
- similarity
-
cosineSimilarity
public float cosineSimilarity(int valence, int arousal)
-
cosineSimilarity
public float cosineSimilarity(float otherAngle)
-
getComponents
public float[] getComponents()
Mood components valence and arousal scaled to the range-1
to1
.- Returns:
- [valance, arousal]
-
getAngle
public float getAngle()
Angle of this emotion in a circumspect model. In polar coordinates this would be the angle,getStrength()
would be the length.- Returns:
- angle (in radians) of this mood
-
getStrength
public float getStrength()
Indicates the strength of an emotion, assuming a no-strength center in the middle of the valence/arousal scale. In essence this is the length of the vector from the center of the scale to the actual emotion.- Returns:
- strength
- See Also:
getAngle()
-
getStrengthClass
public MoodStrength getStrengthClass()
Classifies this mood into a strength class.- Returns:
- strength class
-
getValence
public int getValence()
Valence of this song. This is a value ranging from -100 to +100.- Returns:
- valence
-
setValence
public void setValence(int valence)
Sets the valence - a value ranging from -100 to +100.- Parameters:
valence
- -100 <= valence <= +100- Throws:
IllegalArgumentException
- if the parameter isn't in the valid range
-
getArousal
public int getArousal()
Arousal of this song. This is a value ranging from -100 to +100.- Returns:
- arousal
-
setArousal
public void setArousal(int arousal) throws IllegalArgumentException
Sets the arousal - a value ranging from -100 to +100.- Parameters:
arousal
- -100 <= arousal <= +100- Throws:
IllegalArgumentException
- if the parameter isn't in the valid range
-
getLabel
public String getLabel()
-
setLabel
public void setLabel(String label)
-
getCategory
public Mood getCategory()
One of nine categories this mood can be grouped into.CATEGORY_NEUTRAL
is chosen when the length of this mood is less then 20.- Returns:
- category
-
getCategoryOrdinal
public int getCategoryOrdinal()
One of nine categories this mood can be grouped into.CATEGORY_NEUTRAL
is chosen when the length of this mood is less then 20.- Returns:
- a number denoting a category
-
getClosestLabeledMood
public Mood getClosestLabeledMood()
One of a number of labeled moods this mood is most similar to.NEUTRAL
is chosen when the length of this mood is less then 20.- Returns:
- category
-
getRedGreenSaturation
public Color getRedGreenSaturation()
Maps valence to values from red (negative) to green (positive) and indicates the associated arousal through saturation.- Returns:
- color red green mapping of this mood
-
getRedGreenSaturation
public static Color getRedGreenSaturation(int valence, int arousal)
Maps valence to values from red (negative) to green (positive) and indicates the associated arousal through saturation.- Parameters:
valence
- valencearousal
- arousal- Returns:
- color red green mapping of this mood
-
toJSONString
public String toJSONString()
- Specified by:
toJSONString
in interfaceorg.json.simple.JSONAware
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-
guessMood
public static Mood guessMood(String... words)
Attempt to derive a mood from the given word list.- Parameters:
words
- word list- Returns:
- derived mood or
null
, if we were unable to derive one
-
-