{"id":1541,"date":"2019-04-21T11:24:51","date_gmt":"2019-04-21T05:54:51","guid":{"rendered":"https:\/\/www.rangakrish.com\/?p=1541"},"modified":"2019-04-21T11:30:52","modified_gmt":"2019-04-21T06:00:52","slug":"textcontents-function-in-mathematica-12","status":"publish","type":"post","link":"https:\/\/www.rangakrish.com\/index.php\/2019\/04\/21\/textcontents-function-in-mathematica-12\/","title":{"rendered":"TextContents[ ] Function in Mathematica 12"},"content":{"rendered":"<p><em><strong>Mathematica 12<\/strong><\/em> was released a few days ago.<span class=\"Apple-converted-space\">\u00a0 <\/span>It has been over a year since version <em><strong>11.3<\/strong><\/em> came out in March 2018. The long wait appears justified since the new release boasts of numerous improvements and new features across several areas. You may want to read this <a href=\"https:\/\/blog.stephenwolfram.com\/2019\/04\/version-12-launches-today-big-jump-for-wolfram-language-and-mathematica\/\" target=\"_blank\" rel=\"noopener\"><em><strong>blog post<\/strong><\/em><\/a>\u00a0by <em><strong>Stephen Wolfram<\/strong><\/em>.<\/p>\n<p>In the area of <em><strong>Natural Language Processing<\/strong><\/em>, one function that appeals to me is <a href=\"https:\/\/reference.wolfram.com\/language\/ref\/TextContents.html\" target=\"_blank\" rel=\"noopener\"><em><strong>TextContents<\/strong><\/em><\/a>. This allows us to extract meaningful information, such as entities, numbers, locations, etc. form a given piece of text. A list of all the things that we can look for in the text is given <a href=\"https:\/\/reference.wolfram.com\/language\/guide\/TextContentTypes.html\" target=\"_blank\" rel=\"noopener\"><em><strong>here<\/strong><\/em><\/a>.<\/p>\n<p>In today\u2019s post, I will run through some examples of this function.<\/p>\n<p>Instead of using a toy 2-liner text as example, I decided to use a longer one. So, I put together some information about <em><strong>Florence Nightingale<\/strong><\/em> (sorry, I do not remember the source). Here is the <a href=\"http:\/\/www.rangakrish.com\/downloads\/florencenightingale.txt\" target=\"_blank\" rel=\"noopener\"><em><strong>text<\/strong><\/em><\/a>.<\/p>\n<p>First, we import the text from the file.<\/p>\n<figure id=\"attachment_1543\" aria-describedby=\"caption-attachment-1543\" style=\"width: 641px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/FileImport.png?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"1543\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2019\/04\/21\/textcontents-function-in-mathematica-12\/fileimport\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/FileImport.png\" data-orig-size=\"681,34\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Importing Text File\" data-image-description=\"&lt;p&gt;Importing Text File&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Importing Text File&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/FileImport.png\" class=\"wp-image-1543\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/FileImport.png?resize=641%2C32&#038;ssl=1\" alt=\"Importing Text File\" width=\"641\" height=\"32\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/FileImport.png?w=681&amp;ssl=1 681w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/FileImport.png?resize=300%2C15&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/FileImport.png?resize=680%2C34&amp;ssl=1 680w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/FileImport.png?resize=675%2C34&amp;ssl=1 675w\" sizes=\"(max-width: 641px) 100vw, 641px\" \/><\/a><figcaption id=\"caption-attachment-1543\" class=\"wp-caption-text\"><strong>Importing Text File<\/strong><\/figcaption><\/figure>\n<p>The interesting thing is we can even ask for syntactic elements appearing in the text. Below, I am asking for all <em><strong>Prepositional Phrases<\/strong><\/em>\u00a0in the example text:<\/p>\n<figure id=\"attachment_1544\" aria-describedby=\"caption-attachment-1544\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/PrepPhrase.png?ssl=1\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" data-attachment-id=\"1544\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2019\/04\/21\/textcontents-function-in-mathematica-12\/prepphrase\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/PrepPhrase.png\" data-orig-size=\"1485,806\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Prepositional Phrases\" data-image-description=\"&lt;p&gt;Prepositional Phrases&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Prepositional Phrases&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/PrepPhrase-1024x556.png\" class=\"wp-image-1544\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/PrepPhrase.png?resize=650%2C353&#038;ssl=1\" alt=\"Prepositional Phrases\" width=\"650\" height=\"353\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/PrepPhrase.png?resize=1024%2C556&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/PrepPhrase.png?resize=300%2C163&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/PrepPhrase.png?resize=768%2C417&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/PrepPhrase.png?w=1485&amp;ssl=1 1485w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><\/a><figcaption id=\"caption-attachment-1544\" class=\"wp-caption-text\"><strong>Prepositional Phrases<\/strong><\/figcaption><\/figure>\n<p>The result above shows the first 20 matches out of 28. It looks good! Since the system needs to download some resources as part of evaluating these functions, it can take several seconds when you evaluate the expression for the first time. I think there is an option to pre-download these locally so as to save time later.<\/p>\n<p>Next, let us look for any text fragments that express positive sentiment:<\/p>\n<figure id=\"attachment_1546\" aria-describedby=\"caption-attachment-1546\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/Positive-Sentiment-1.png?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"1546\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2019\/04\/21\/textcontents-function-in-mathematica-12\/positive-sentiment-2\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/Positive-Sentiment-1.png\" data-orig-size=\"1386,310\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Positive Sentiment\" data-image-description=\"&lt;p&gt;Positive Sentiment&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Positive Sentiment&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/Positive-Sentiment-1-1024x229.png\" class=\"wp-image-1546\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/Positive-Sentiment-1.png?resize=650%2C145&#038;ssl=1\" alt=\"Positive Sentiment\" width=\"650\" height=\"145\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/Positive-Sentiment-1.png?resize=1024%2C229&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/Positive-Sentiment-1.png?resize=300%2C67&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/Positive-Sentiment-1.png?resize=768%2C172&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/Positive-Sentiment-1.png?w=1386&amp;ssl=1 1386w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><\/a><figcaption id=\"caption-attachment-1546\" class=\"wp-caption-text\"><strong>Positive Sentiment<\/strong><\/figcaption><\/figure>\n<p>Looking closely at the result, it is not clear to me how the 4th element in the result <span style=\"color: #0000ff;\"><em><strong>\u201cAt night, Florence walked around the hospital\u201d<\/strong><\/em><\/span> is considered to be positive. It seems to be neutral to me (because if you work in the hospital, this is normal). This could be subjective I suppose.<\/p>\n<p>What about negative sentiment?<\/p>\n<figure id=\"attachment_1547\" aria-describedby=\"caption-attachment-1547\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/NegativeSentiment.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1547\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2019\/04\/21\/textcontents-function-in-mathematica-12\/negativesentiment\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/NegativeSentiment.png\" data-orig-size=\"1387,235\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Negative Sentiment\" data-image-description=\"&lt;p&gt;Negative Sentiment&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Negative Sentiment&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/NegativeSentiment-1024x173.png\" class=\"wp-image-1547\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/NegativeSentiment.png?resize=650%2C110&#038;ssl=1\" alt=\"Negative Sentiment\" width=\"650\" height=\"110\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/NegativeSentiment.png?resize=1024%2C173&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/NegativeSentiment.png?resize=300%2C51&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/NegativeSentiment.png?resize=768%2C130&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/NegativeSentiment.png?w=1387&amp;ssl=1 1387w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><\/a><figcaption id=\"caption-attachment-1547\" class=\"wp-caption-text\"><strong>Negative Sentiment<\/strong><\/figcaption><\/figure>\n<p>This looks OK to me.<\/p>\n<p>We can specify multiple features in the same expression. Below, I am asking for all occurrences of <em><strong>\u201cDate\u201d<\/strong><\/em>, <em><strong>\u201cLocation\u201d<\/strong> <\/em>and <em><strong>\u201cNumber\u201d<\/strong><\/em> appearing in the sample text.<\/p>\n<figure id=\"attachment_1549\" aria-describedby=\"caption-attachment-1549\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/DateLocation.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1549\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2019\/04\/21\/textcontents-function-in-mathematica-12\/datelocation\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/DateLocation.png\" data-orig-size=\"1080,785\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Multiple Features\" data-image-description=\"&lt;p&gt;Multiple Features&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Multiple Features&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/DateLocation-1024x744.png\" class=\"wp-image-1549\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/DateLocation.png?resize=650%2C472&#038;ssl=1\" alt=\"Multiple Features\" width=\"650\" height=\"472\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/DateLocation.png?resize=1024%2C744&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/DateLocation.png?resize=300%2C218&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/DateLocation.png?resize=768%2C558&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/DateLocation.png?w=1080&amp;ssl=1 1080w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><\/a><figcaption id=\"caption-attachment-1549\" class=\"wp-caption-text\"><strong>Multiple Features<\/strong><\/figcaption><\/figure>\n<p>If you observe carefully, you will see that the system has wrongly mapped the person <em><strong>\u201cFlorence\u201d<\/strong><\/em> to the city <em><strong>\u201cFlorence\u201d<\/strong><\/em> in some places. Looks like more training needs to be done!<\/p>\n<p>We can use the <em><strong>\u201cContaining[]\u201d<\/strong><\/em> function to extract sentences that contain certain features, for example, <em><strong>Pronouns<\/strong><\/em>.<\/p>\n<figure id=\"attachment_1550\" aria-describedby=\"caption-attachment-1550\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/Pronouns.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1550\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2019\/04\/21\/textcontents-function-in-mathematica-12\/pronouns\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/Pronouns.png\" data-orig-size=\"1387,678\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Sentences with Pronouns\" data-image-description=\"&lt;p&gt;Sentences with Pronouns&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Sentences with Pronouns&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/Pronouns-1024x501.png\" class=\"wp-image-1550\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/Pronouns.png?resize=650%2C318&#038;ssl=1\" alt=\"Sentences with Pronouns\" width=\"650\" height=\"318\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/Pronouns.png?resize=1024%2C501&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/Pronouns.png?resize=300%2C147&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/Pronouns.png?resize=768%2C375&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/Pronouns.png?w=1387&amp;ssl=1 1387w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><\/a><figcaption id=\"caption-attachment-1550\" class=\"wp-caption-text\"><strong>Sentences with Pronouns<\/strong><\/figcaption><\/figure>\n<p>We can also use the <em><strong>\u201cEntity[]\u201d<\/strong><\/em> function to look for specific entities as given <a href=\"https:\/\/reference.wolfram.com\/language\/guide\/TextContentTypes.html\" target=\"_blank\" rel=\"noopener\"><em><strong>here<\/strong><\/em><\/a>:<\/p>\n<p><figure id=\"attachment_1551\" aria-describedby=\"caption-attachment-1551\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/Country.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1551\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2019\/04\/21\/textcontents-function-in-mathematica-12\/country\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/Country.png\" data-orig-size=\"1222,154\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Using Entities[] Function\" data-image-description=\"&lt;p&gt;Using Entities[] Function&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Using Entities[] Function&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/Country-1024x129.png\" class=\"wp-image-1551\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/Country.png?resize=650%2C82&#038;ssl=1\" alt=\"Using Entities[] Function\" width=\"650\" height=\"82\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/Country.png?resize=1024%2C129&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/Country.png?resize=300%2C38&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/Country.png?resize=768%2C97&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/04\/Country.png?w=1222&amp;ssl=1 1222w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><\/a><figcaption id=\"caption-attachment-1551\" class=\"wp-caption-text\"><strong>Using Entity[] Function<\/strong><\/figcaption><\/figure>Quite interesting! Definitely a useful function in the area of NLP. One of the remarkable things about Mathematica is that it exposes functionality at the right level of abstraction, making it much easier for the user.<\/p>\n<p>One feature I was quite eagerly anticipating in this release is support for <em><strong>Text Summarization. <\/strong><\/em>I am a bit disappointed it is not there, but I am sure it would be included in a future release because summarization is a hot topic today.<\/p>\n<p>You can download the sample <a href=\"http:\/\/www.rangakrish.com\/downloads\/florencenightingale.txt\" target=\"_blank\" rel=\"noopener\"><em><strong>text file<\/strong><\/em><\/a>\u00a0as well as the Mathematica <a href=\"http:\/\/www.rangakrish.com\/downloads\/TextContents-Example.nb\" target=\"_blank\" rel=\"noopener\"><em><strong>Notebook<\/strong><\/em><\/a>.<\/p>\n<p>Have a great weekend!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Mathematica 12 was released a few days ago.\u00a0 It has been over a year since version 11.3 came out in March 2018. The long wait appears justified since the new release boasts of numerous improvements and new features across several areas. You may want to read this blog post\u00a0by Stephen Wolfram. In the area of [&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_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":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[72,107,17],"tags":[206,207],"class_list":["post-1541","post","type-post","status-publish","format-standard","hentry","category-mathematica","category-natural-language-processing","category-programming","tag-mathematica-12","tag-textcontents"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9OLnF-oR","jetpack-related-posts":[{"id":328,"url":"https:\/\/www.rangakrish.com\/index.php\/2016\/09\/11\/natural-language-processing-in-mathematica\/","url_meta":{"origin":1541,"position":0},"title":"Natural Language Processing in Mathematica","author":"admin","date":"September 11, 2016","format":false,"excerpt":"Welcome back. Today I am going to share with you some of the nice capabilities of Mathematica in the area of Natural Language Processing (NLP). Let us start with words. What if we wish to know\u00a0the various definitions of the word image?\u00a0Here is the answer. Mathematica gives the various senses\u2026","rel":"","context":"In &quot;Mathematica&quot;","block_context":{"text":"Mathematica","link":"https:\/\/www.rangakrish.com\/index.php\/category\/mathematica\/"},"img":{"alt_text":"Word Definition","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2016\/09\/word-data1-1024x238.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2016\/09\/word-data1-1024x238.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2016\/09\/word-data1-1024x238.png?resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2016\/09\/word-data1-1024x238.png?resize=700%2C400 2x"},"classes":[]},{"id":870,"url":"https:\/\/www.rangakrish.com\/index.php\/2018\/03\/25\/question-answering-in-mathematica\/","url_meta":{"origin":1541,"position":1},"title":"Question Answering in Mathematica","author":"admin","date":"March 25, 2018","format":false,"excerpt":"About 10 days ago, I received an update for Mathematica. The latest version is 11.3.0. As usual, I looked through the list of new features\u00a0in this release. There are several new features, but one of them attracted my attention immediately: There is a new function FindTextualAnswer\u00a0that, given a piece of\u2026","rel":"","context":"In &quot;Mathematica&quot;","block_context":{"text":"Mathematica","link":"https:\/\/www.rangakrish.com\/index.php\/category\/mathematica\/"},"img":{"alt_text":"Example 1","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/03\/Example1.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/03\/Example1.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/03\/Example1.png?resize=525%2C300 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":1541,"position":2},"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":[]},{"id":3545,"url":"https:\/\/www.rangakrish.com\/index.php\/2024\/11\/09\/semantic-search-in-wolfram-mathematica\/","url_meta":{"origin":1541,"position":3},"title":"Semantic Search in Wolfram Mathematica","author":"admin","date":"November 9, 2024","format":false,"excerpt":"In an earlier article, I explained how to use OpenAI from Wolfram Mathematica ver 14.1. This latest release of Wolfram supports Semantic Search as well. In today\u2019s article, let me discuss this feature. As in the case of using LLMs, using Semantic Search requires an account with one of the\u2026","rel":"","context":"In &quot;Mathematica&quot;","block_context":{"text":"Mathematica","link":"https:\/\/www.rangakrish.com\/index.php\/category\/mathematica\/"},"img":{"alt_text":"Remedy Description","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/11\/image1-300x225.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/11\/image1-300x225.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/11\/image1-300x225.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":348,"url":"https:\/\/www.rangakrish.com\/index.php\/2016\/09\/26\/computer-vision-with-mathematica\/","url_meta":{"origin":1541,"position":4},"title":"Computer Vision with Mathematica","author":"admin","date":"September 26, 2016","format":false,"excerpt":"Over the past several weeks, I have been discussing many interesting features of Mathematica. As a continuation, today, I would like to show some cool functionality in the domain of computer vision and machine learning. The function ImageIdentify[] tries to identify the object in the given image. According to the\u2026","rel":"","context":"In &quot;Machine Learning&quot;","block_context":{"text":"Machine Learning","link":"https:\/\/www.rangakrish.com\/index.php\/category\/machine-learning\/"},"img":{"alt_text":"A Truck","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2016\/09\/truck-fig.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":2084,"url":"https:\/\/www.rangakrish.com\/index.php\/2020\/08\/16\/pattern-matching-comparing-elixir-and-mathematica\/","url_meta":{"origin":1541,"position":5},"title":"Pattern Matching: Comparing Elixir and Mathematica","author":"admin","date":"August 16, 2020","format":false,"excerpt":"One of the things I like about Elixir\u00a0is its support for patterns at the core language level, not through library functions as in most other languages. This contributes to writing cleaner code, in my opinion. \u00a0 Another environment that I am familiar with, namely Mathematica, boasts of (arguably) the most\u2026","rel":"","context":"In &quot;Elixir&quot;","block_context":{"text":"Elixir","link":"https:\/\/www.rangakrish.com\/index.php\/category\/elixir\/"},"img":{"alt_text":"Symbolic Expressions","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/08\/pattern-mm.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/08\/pattern-mm.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/08\/pattern-mm.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/1541","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=1541"}],"version-history":[{"count":0,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/1541\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/media?parent=1541"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/categories?post=1541"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/tags?post=1541"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}