Class Mood

    • 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 <= +100
        arousal - -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 <= +100
        arousal - -100 <= arousal <= +100
        label - 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 - angleInRadians
        label - label
        strength - 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 to 1.
        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 - valence
        arousal - arousal
        Returns:
        color red green mapping of this mood
      • toJSONString

        public String toJSONString()
        Specified by:
        toJSONString in interface org.json.simple.JSONAware
      • 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
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object