{"id":856,"date":"2018-02-25T05:32:23","date_gmt":"2018-02-25T05:32:23","guid":{"rendered":"http:\/\/www.rangakrish.com\/?p=856"},"modified":"2018-02-25T05:37:42","modified_gmt":"2018-02-25T05:37:42","slug":"sentiments-and-emotions-in-ilexicon","status":"publish","type":"post","link":"https:\/\/www.rangakrish.com\/index.php\/2018\/02\/25\/sentiments-and-emotions-in-ilexicon\/","title":{"rendered":"Sentiments and Emotions in iLexicon"},"content":{"rendered":"<p>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<b><i>, <a href=\"https:\/\/www.meaningcloud.com\/products\/sentiment-analysis\" target=\"_blank\" rel=\"noopener\">meaningcloud.com <\/a><\/i><\/b>\u00a0has an API for detecting sentiments in the text submitted to it. Another API service provider is <a href=\"http:\/\/docs.aylien.com\/docs\/sentiment\" target=\"_blank\" rel=\"noopener\"><b><i>aylien.com <\/i><\/b><\/a>. Emotion detection for text is supported by <a href=\"http:\/\/api.qemotion.com\/api\/documentation#top\" target=\"_blank\" rel=\"noopener\"><b><i>qemotion.com<\/i><\/b><\/a>.<\/p>\n<p>Because <em><strong>iLexicon<\/strong><\/em> 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 <a href=\"http:\/\/sentiwordnet.isti.cnr.it\/\" target=\"_blank\" rel=\"noopener\"><b><i>Sentiwordnet,<\/i><\/b><\/a>\u00a0and for emotions, I am using my own tagging.<\/p>\n<p>OK, let us look at some examples of sentiment tagging.<\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #008000;\"><b>cg-user(1): (get-matching-words :sentiment+ 0.25)<\/b><\/span><\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #008000;\"><b>(&#8220;abbot&#8221; &#8220;abdicable&#8221; &#8220;aberrant&#8221; &#8220;abient&#8221; &#8220;abjectly&#8221; &#8220;ablaut&#8221; &#8220;ablative&#8221; &#8220;abruptness&#8221; &#8220;absconder&#8221; &#8220;absently&#8221; &#8230;)<\/b><\/span><\/p>\n<p>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.<\/p>\n<p>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.<\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #008000;\"><b>cg-user(2): (get-matching-words :sentiment+ &#8216;(0.2 0.3))<\/b><\/span><\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #008000;\"><b>(&#8220;absolver&#8221; &#8220;absorb&#8221; &#8220;abstemiously&#8221; &#8220;abstinence&#8221; &#8220;achromatic&#8221; &#8220;acaulescent&#8221; &#8220;accept&#8221; &#8220;acceptance&#8221; &#8220;accomplishable&#8221; &#8220;accuser&#8221; &#8230;)<\/b><\/span><\/p>\n<p>The above words have a positive sentiment value between 0.2 and 0.3.<\/p>\n<p>Just as we can search for words with positive sentiment, we can also look for words that have negative sentiment.<\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #008000;\"><b>cg-user(3): (get-matching-words\u00a0 :sentiment- &#8216;(0.5 0.7) :sentiment+ &#8216;(0.3 0.5))<\/b><\/span><\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #008000;\"><b>(&#8220;acquitted&#8221; &#8220;adulation&#8221; &#8220;aggressiveness&#8221; &#8220;angry&#8221; &#8220;antidotal&#8221; &#8220;appeasing&#8221; &#8220;archaistic&#8221; &#8220;ascensional&#8221; &#8220;attrition&#8221; &#8220;authentic&#8221; &#8230;)<\/b><\/span><\/p>\n<p>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.<\/p>\n<p>In the following, we are identifying all words that have only positive sentiment and no negtive sentiment:<\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #008000;\"><b>cg-user(4): (get-matching-words :sentiment+ 1.0)<\/b><\/span><\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #008000;\"><b>(&#8220;admirability&#8221; &#8220;bliss&#8221; &#8220;estimable&#8221; &#8220;excellent&#8221; &#8220;first-rater&#8221; &#8220;good&#8221; &#8220;happiness&#8221; &#8220;praise&#8221; &#8220;sensational&#8221; &#8220;unsurpassable&#8221; &#8230;)<\/b><\/span><\/p>\n<p>Since 1 is the upper bound on the sentiment value, clearly these words cannot have a negative sentiment.<\/p>\n<p>As we have seen with other examples earlier, it is easy to combine filters while retrieving words from the lexicon.<\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #008000;\"><b>cg-user(5): (get-matching-words :sentiment+ 0.4 :num-syllables 5 :word-pat &#8220;^c&#8221;)<\/b><\/span><\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #008000;\"><b>(&#8220;centenarian&#8221; &#8220;certifiable&#8221; &#8220;characteristic&#8221; &#8220;coloratura&#8221; &#8220;comfortableness&#8221; &#8220;comicality&#8221; &#8220;complicatedness&#8221; &#8220;complimentary&#8221; &#8220;comprehensiveness&#8221; &#8220;comprehensible&#8221; &#8230;)<\/b><\/span><\/p>\n<p>The above returns words with a positive sentiment of 0.4 and above, having 5 syllables, and starting with the letter <em><strong>c<\/strong><\/em>.<\/p>\n<p>Here is another example. It locates <em><strong>isograms<\/strong><\/em> with positive sentiment with number of letters between 8 and 15.<\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #008000;\"><b>cg-user(6): (get-matching-words :sentiment+ 0.7 :isogram 1 :num-letters &#8216;(8 15))<\/b><\/span><\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #008000;\"><b>(&#8220;altruism&#8221; &#8220;adoringly&#8221; &#8220;amusingly&#8221; &#8220;charming&#8221; &#8220;consider&#8221; &#8220;courtesy&#8221; &#8220;curative&#8221; &#8220;downright&#8221; &#8220;drinkable&#8221; &#8230;)<\/b><\/span><\/p>\n<p>instead of looking for matching words, if you want to see the sentiment information associated with a specific words, that is also possible:<\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #008000;\"><b>cg-user(7): (get-word-sentiment &#8220;lovely&#8221;)<\/b><\/span><\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #008000;\"><b>(0.625 0.0)<\/b><\/span><\/p>\n<p>The first element is the positive sentiment value and the second corresponds to negative sentiment. In this example, <b><i>lovely <\/i><\/b>has only positive sentiment.<\/p>\n<p>I hope this gives an idea of the support for sentiments in <b><i>iLexicon<\/i><\/b>. Let us look at emotions next.<\/p>\n<p>At present <em><strong>iLexicon<\/strong><\/em> contains word annotations for these emotions: <b><i>Action, Anger, Fear, Happiness, Humor, Romance, Sadness, <\/i><\/b>and <b><i>Shock<\/i><\/b> (I expect this list to grow). A word can be associated with zero or more of these emotions.<\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #008000;\"><b>cg-user(8): (get-matching-words :emotion &#8216;anger :num-syllables 4 :pos &#8220;[V]&#8221;)<\/b><\/span><\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #008000;\"><b>(&#8220;antagonize&#8221; &#8220;infuriate&#8221;)<\/b><\/span><\/p>\n<p>This fetches 4-syllable <b><i>verbs <\/i><\/b>that denote the emotion <b><i>anger<\/i><\/b>.<\/p>\n<p>You can pass a list of emotions if you want words that represent any of those emotions:<\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #008000;\"><b>cg-user(9): (get-matching-words :emotion &#8216;(humor happiness))<\/b><\/span><\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #008000;\"><b>(&#8220;amusement&#8221; &#8220;amuse&#8221; &#8220;banter&#8221; &#8220;beam&#8221; &#8220;bliss&#8221; &#8220;blissful&#8221; &#8220;blithe&#8221; &#8220;bloom&#8221; &#8220;buffoon&#8221; &#8220;buffoonery&#8221; &#8230;)<\/b><\/span><\/p>\n<p>Here is another example:<\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #008000;\"><b>cg-user(10): (get-matching-words :emotion &#8216;romance :rhyming-with &#8220;air&#8221;)<\/b><\/span><\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #008000;\"><b>(&#8220;affair&#8221;)<\/b><\/span><\/p>\n<p>You can get the emotions attached to any specific word thus:<\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #008000;\"><b>cg-user(11): (get-word-emotions &#8220;laugh&#8221;)<\/b><\/span><\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #008000;\"><b>(humor happiness)<\/b><\/span><\/p>\n<p>Tagging words with emotions and sentiments can prove quite useful if someone wants to generate poetry, for example.<\/p>\n<p>This concludes today&#8217;s discussion of <em><strong>iLexicon<\/strong><\/em>. More in the coming weeks&#8230;<\/p>\n<p>Have a nice weekend!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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, meaningcloud.com \u00a0has an API for detecting sentiments in the text submitted to it. Another API service provider is aylien.com . Emotion detection for text is supported by qemotion.com. Because [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[18,107,17],"tags":[136,130,135],"class_list":["post-856","post","type-post","status-publish","format-standard","hentry","category-lisp","category-natural-language-processing","category-programming","tag-emotions","tag-ilexicon","tag-sentiments"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9OLnF-dO","jetpack-related-posts":[{"id":1460,"url":"https:\/\/www.rangakrish.com\/index.php\/2019\/02\/17\/identifying-emotions-from-text\/","url_meta":{"origin":856,"position":0},"title":"Identifying Emotions from Text","author":"admin","date":"February 17, 2019","format":false,"excerpt":"Identifying the predominant sentiment in unstructured text is used widely these days. There are several REST API services that allow you to submit a piece of text and get back the corresponding sentiment analysis. Meaningcloud, Aylien, Google's Cloud Natural Language API, and\u00a0 IBM Natural Language Understanding\u00a0Service are just a few.\u2026","rel":"","context":"In &quot;Natural Language Processing&quot;","block_context":{"text":"Natural Language Processing","link":"https:\/\/www.rangakrish.com\/index.php\/category\/natural-language-processing\/"},"img":{"alt_text":"Program to Dump Emotions","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Code.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Code.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Code.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":1475,"url":"https:\/\/www.rangakrish.com\/index.php\/2019\/02\/24\/emotion-detection-using-paralleldots-api\/","url_meta":{"origin":856,"position":1},"title":"Emotion Detection using ParallelDots API","author":"admin","date":"February 24, 2019","format":false,"excerpt":"Last week, I showed how we can use IBM Natural Language Understanding API to identify emotions from given text. Today, I would like to run through the same examples, but using ParallelDots API service. There are wrappers\u00a0in Java, Python, Ruby, C#, and PHP for accessing the REST service. However, I\u2026","rel":"","context":"In &quot;LISP&quot;","block_context":{"text":"LISP","link":"https:\/\/www.rangakrish.com\/index.php\/category\/lisp\/"},"img":{"alt_text":"The Code","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Code-1.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Code-1.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/02\/Code-1.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":1349,"url":"https:\/\/www.rangakrish.com\/index.php\/2018\/12\/30\/natural-language-interaction-with-ilexicon-using-luis\/","url_meta":{"origin":856,"position":2},"title":"Natural Language Interaction with iLexicon Using LUIS","author":"admin","date":"December 30, 2018","format":false,"excerpt":"Some time ago, I had written a series of articles on my iLexicon project. It is a Lisp package that supports many interesting queries on English words. When I was discussing this project with a client recently, she asked me if it was possible to query the system in natural\u2026","rel":"","context":"In &quot;LISP&quot;","block_context":{"text":"LISP","link":"https:\/\/www.rangakrish.com\/index.php\/category\/lisp\/"},"img":{"alt_text":"Talking to iLexicon","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/12\/Code2.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/12\/Code2.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/12\/Code2.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":2315,"url":"https:\/\/www.rangakrish.com\/index.php\/2021\/02\/14\/litedb-a-nosql-database-for-net\/","url_meta":{"origin":856,"position":3},"title":"LiteDB: A NoSQL Database for .NET","author":"admin","date":"February 14, 2021","format":false,"excerpt":"I have been looking around for a compact embedded NoSQL database library for .NET, to use as the back-end of my \"iLexicon\" system. \"iLexicon\" is written in Lisp and Prolog (I have written a few articles\u00a0on it before). At present, the entire dictionary component (containing over 300,000 word entries) is\u2026","rel":"","context":"In &quot;Programming&quot;","block_context":{"text":"Programming","link":"https:\/\/www.rangakrish.com\/index.php\/category\/programming\/"},"img":{"alt_text":"Using Package Manager to Install LiteDB","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/02\/Package-Manager-300x98.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/02\/Package-Manager-300x98.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/02\/Package-Manager-300x98.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":1285,"url":"https:\/\/www.rangakrish.com\/index.php\/2018\/12\/09\/parsing-text-with-meaningclouds-text-analytics-api\/","url_meta":{"origin":856,"position":4},"title":"Parsing Text with MeaningCloud&#8217;s Text Analytics API","author":"admin","date":"December 9, 2018","format":false,"excerpt":"There is wide-spread interest in Natural Language Processing (NLP) today, and there are several API services available to cater to this demand. See this article for a fairly detailed list of services. All of them support multiple languages, including English. Today, I am going to share my experience in working\u2026","rel":"","context":"In &quot;LISP&quot;","block_context":{"text":"LISP","link":"https:\/\/www.rangakrish.com\/index.php\/category\/lisp\/"},"img":{"alt_text":"Get Words Function","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/12\/Get-words.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/12\/Get-words.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/12\/Get-words.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":2131,"url":"https:\/\/www.rangakrish.com\/index.php\/2020\/09\/13\/mathematica-using-textcases-to-extract-information-from-natural-language-text\/","url_meta":{"origin":856,"position":5},"title":"Mathematica: Using TextCases to Extract Information from Natural Language Text\u00a0","author":"admin","date":"September 13, 2020","format":false,"excerpt":"Extracting meaningful information from unstructured, human readable text is a hot topic of research today and has important applications in many domains. I have written a few blogs related to this topic, for example, see this\u00a0and this. In today\u2019s article, I would like to show how Mathematica can be a\u2026","rel":"","context":"In &quot;Mathematica&quot;","block_context":{"text":"Mathematica","link":"https:\/\/www.rangakrish.com\/index.php\/category\/mathematica\/"},"img":{"alt_text":"Extracting Sentences","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/09\/ex1-2-300x106.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/856","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/comments?post=856"}],"version-history":[{"count":0,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/856\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/media?parent=856"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/categories?post=856"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/tags?post=856"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}