Sentiments and Emotions in iLexicon

Written by on February 25, 2018 in LISP, Natural Language Processing, Programming with 0 Comments

Detecting sentiments and emotions in a piece of text are frequently performed activities in Text analysis. There are some API services available for this. For example,  has an API for detecting sentiments in the text submitted to it. Another API service provider is . Emotion detection for text is supported by

Because iLexicon is an intelligent dictionary, my goal is to include in it as much useful information as possible. In addition to the features we saw in the earlier posts, words have been annotated with respect to sentiment and emotion. Sentiment tagging is based on Sentiwordnet, and for emotions, I am using my own tagging.

OK, let us look at some examples of sentiment tagging.

cg-user(1): (get-matching-words :sentiment+ 0.25)

(“abbot” “abdicable” “aberrant” “abient” “abjectly” “ablaut” “ablative” “abruptness” “absconder” “absently” …)

The above is an example of enumerating all words that have a positive sentiment with a value of 0.25 and above. Sentiment values are in the range of 0 to 1.

It is possible to specify a value range, and in this case, only those words that have sentiment value in the range will be returned.

cg-user(2): (get-matching-words :sentiment+ ‘(0.2 0.3))

(“absolver” “absorb” “abstemiously” “abstinence” “achromatic” “acaulescent” “accept” “acceptance” “accomplishable” “accuser” …)

The above words have a positive sentiment value between 0.2 and 0.3.

Just as we can search for words with positive sentiment, we can also look for words that have negative sentiment.

cg-user(3): (get-matching-words  :sentiment- ‘(0.5 0.7) :sentiment+ ‘(0.3 0.5))

(“acquitted” “adulation” “aggressiveness” “angry” “antidotal” “appeasing” “archaistic” “ascensional” “attrition” “authentic” …)

Here we are looking for words with a negative sentiment in the range 0.5 to 0.7 and positive sentiment in the range 0.3 to 0.5. The result is non-empty because a word can have both positive and negtive sentiment connotation.

In the following, we are identifying all words that have only positive sentiment and no negtive sentiment:

cg-user(4): (get-matching-words :sentiment+ 1.0)

(“admirability” “bliss” “estimable” “excellent” “first-rater” “good” “happiness” “praise” “sensational” “unsurpassable” …)

Since 1 is the upper bound on the sentiment value, clearly these words cannot have a negative sentiment.

As we have seen with other examples earlier, it is easy to combine filters while retrieving words from the lexicon.

cg-user(5): (get-matching-words :sentiment+ 0.4 :num-syllables 5 :word-pat “^c”)

(“centenarian” “certifiable” “characteristic” “coloratura” “comfortableness” “comicality” “complicatedness” “complimentary” “comprehensiveness” “comprehensible” …)

The above returns words with a positive sentiment of 0.4 and above, having 5 syllables, and starting with the letter c.

Here is another example. It locates isograms with positive sentiment with number of letters between 8 and 15.

cg-user(6): (get-matching-words :sentiment+ 0.7 :isogram 1 :num-letters ‘(8 15))

(“altruism” “adoringly” “amusingly” “charming” “consider” “courtesy” “curative” “downright” “drinkable” …)

instead of looking for matching words, if you want to see the sentiment information associated with a specific words, that is also possible:

cg-user(7): (get-word-sentiment “lovely”)

(0.625 0.0)

The first element is the positive sentiment value and the second corresponds to negative sentiment. In this example, lovely has only positive sentiment.

I hope this gives an idea of the support for sentiments in iLexicon. Let us look at emotions next.

At present iLexicon contains word annotations for these emotions: Action, Anger, Fear, Happiness, Humor, Romance, Sadness, and Shock (I expect this list to grow). A word can be associated with zero or more of these emotions.

cg-user(8): (get-matching-words :emotion ‘anger :num-syllables 4 :pos “[V]”)

(“antagonize” “infuriate”)

This fetches 4-syllable verbs that denote the emotion anger.

You can pass a list of emotions if you want words that represent any of those emotions:

cg-user(9): (get-matching-words :emotion ‘(humor happiness))

(“amusement” “amuse” “banter” “beam” “bliss” “blissful” “blithe” “bloom” “buffoon” “buffoonery” …)

Here is another example:

cg-user(10): (get-matching-words :emotion ‘romance :rhyming-with “air”)


You can get the emotions attached to any specific word thus:

cg-user(11): (get-word-emotions “laugh”)

(humor happiness)

Tagging words with emotions and sentiments can prove quite useful if someone wants to generate poetry, for example.

This concludes today’s discussion of iLexicon. More in the coming weeks…

Have a nice weekend!

Tags: , ,


If you enjoyed this article, subscribe now to receive more just like it.

Subscribe via RSS Feed

Leave a Reply

Your email address will not be published. Required fields are marked *