{"id":1613,"date":"2019-06-24T16:55:01","date_gmt":"2019-06-24T11:25:01","guid":{"rendered":"https:\/\/www.rangakrish.com\/?p=1613"},"modified":"2019-06-26T05:09:23","modified_gmt":"2019-06-25T23:39:23","slug":"text-analysis-using-meaningclouds-deep-categorization-api","status":"publish","type":"post","link":"https:\/\/www.rangakrish.com\/index.php\/2019\/06\/24\/text-analysis-using-meaningclouds-deep-categorization-api\/","title":{"rendered":"Text Analysis Using MeaningCloud\u2019s Deep Categorization API"},"content":{"rendered":"<p><a href=\"https:\/\/www.meaningcloud.com\" target=\"_blank\" rel=\"noopener\"><em><strong>MeaningCloud<\/strong><\/em><\/a>\u00a0announced their premium offering <em><strong>\u201cDeep Categorization\u201d<\/strong><\/em> service quite recently. You can read about it in this nice <a href=\"https:\/\/www.meaningcloud.com\/blog\/tutorial-deep-categorization-customization\" target=\"_blank\" rel=\"noopener\"><em><strong>blog<\/strong><\/em><\/a>\u00a0by Blanca Galego.<\/p>\n<p>Compared to the canonical classification models that rely on machine learning using large data sets, <em><strong>MeaningCloud\u2019s<\/strong><\/em> deep categorization models use hand-crafted rules that take advantage of <em><strong>\u201cmorphosyntactic, semantic and contextual information\u201d<\/strong><\/em> to classify a piece of text.<\/p>\n<p>The company has several pre-defined deep categorization models, such as <em><strong>Intention Analysis<\/strong><\/em>, <em><strong>Voice-of-Customer Banking<\/strong><\/em>, <em><strong>Voice-of-Employee Exit Interview<\/strong><\/em>, and so on. Take a look at <a href=\"https:\/\/www.meaningcloud.com\/developer\/documentation\/supported-deep-categorization-models\" target=\"_blank\" rel=\"noopener\"><em><strong>this<\/strong><\/em><\/a>\u00a0to learn more.<\/p>\n<p>This feature, as well as how to build custom models, is explained in detail in the <a href=\"https:\/\/www.meaningcloud.com\/developer\/resources\/doc\/deep-categorization-models\" target=\"_blank\" rel=\"noopener\"><em><strong>documentation<\/strong><\/em><\/a>\u00a0section.<\/p>\n<p>After reading the extensive documentation, I was keen to get my hands dirty by trying it on some example. I am working on a homeopathy project that involves text analysis, so I decided to apply it in that context.<\/p>\n<p>Here is the problem: Given a homeopathy case record (corresponding to a patient), can we automatically identify the nature of ailment? Prescribing the correct remedy for an ailment is a very complex process in homeopathy, so if some kind of automation can facilitate this process, I would consider it to be a significant achievement.<\/p>\n<p>For this toy experiment, of course, I have taken a simple example with just two categories:<\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">acute-disease&gt;common-cold<\/span><\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">acute-disease&gt;diarrhoea<\/span><\/p>\n<p>Given a piece of text, we want the system to label it as one or both of the above categories.<span class=\"Apple-converted-space\">\u00a0<\/span><\/p>\n<p>First, consider the labels I have chosen for the categories. In homeopathy, <em><strong>common cold<\/strong><\/em> and <em><strong>diarrhoea<\/strong><\/em> are examples of <a href=\"https:\/\/www.homeopathycenter.org\/homeopathy-today\/dynamic-medicine-acute-and-chronic-prescribing-whats-difference\" target=\"_blank\" rel=\"noopener\"><em><strong>acute<\/strong><\/em><\/a> diseases. <em><strong>Diabetes<\/strong><\/em> is an example of <a href=\"https:\/\/www.homeopathycenter.org\/homeopathy-today\/dynamic-medicine-acute-and-chronic-prescribing-whats-difference\" target=\"_blank\" rel=\"noopener\"><em><strong>chronic<\/strong><\/em><\/a> disease. When developing deep categorization models, it is useful to take advantage of hierarchies like this, wherever appropriate.<span class=\"Apple-converted-space\">\u00a0<\/span><\/p>\n<p>Now, take the case of <em><strong>common cold<\/strong><\/em>. A case record that documents this acute ailment of a patient will most likely have expressions like <em><strong>\u201ccold\u201d<\/strong><\/em>, <em><strong>\u201crunny nose\u201d<\/strong><\/em>, <em><strong>\u201csneezing\u201d<\/strong><\/em>, <em><strong>\u201cheadache\u201d<\/strong><\/em>, <em><strong>\u201cfever\u201d<\/strong><\/em>, etc. We can capture this knowledge in terms of\u00a0<em><strong>\u201crules\u201d<\/strong><\/em>\u00a0involving pattern expressions for categorizing given text into <em><strong>\u201cacute-disease&gt;common-cold\u201d<\/strong><\/em> category. Here are my two rules:<\/p>\n<figure id=\"attachment_1616\" aria-describedby=\"caption-attachment-1616\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/common-cold-category.png?ssl=1\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" data-attachment-id=\"1616\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2019\/06\/24\/text-analysis-using-meaningclouds-deep-categorization-api\/common-cold-category\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/common-cold-category-e1561375799457.png\" data-orig-size=\"650,461\" 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=\"Rules for Common Cold\" data-image-description=\"&lt;p&gt;Rules for Common Cold&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Rules for Common Cold&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/common-cold-category-e1561375799457.png\" class=\"wp-image-1616 size-full\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/common-cold-category-e1561375799457.png?resize=650%2C461&#038;ssl=1\" alt=\"Rules for Common Cold\" width=\"650\" height=\"461\" \/><\/a><figcaption id=\"caption-attachment-1616\" class=\"wp-caption-text\"><strong>Rules for Common Cold<\/strong><\/figcaption><\/figure>\n<p>The first rule <em><strong>\u201csymptom1\u201d<\/strong><\/em> uses a <em><strong>\u201cmacro\u201d<\/strong><\/em> called <em><strong>\u201ccold-symptoms\u201d<\/strong><\/em>. Macros are a nice way to capture patterns that are likely to be used across multiple rules. Instead of repeating the same pattern expression again and again, defining it as a macro makes it concise, more readable and maintainable.<\/p>\n<p>Here is the macro definition:<\/p>\n<figure id=\"attachment_1627\" aria-describedby=\"caption-attachment-1627\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/macro-1.png?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"1627\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2019\/06\/24\/text-analysis-using-meaningclouds-deep-categorization-api\/macro-2\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/macro-1-e1561375824760.png\" data-orig-size=\"650,241\" 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=\"Macro: cold symptoms\" data-image-description=\"&lt;p&gt;Macro: cold symptoms&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Macro: cold symptoms&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/macro-1-e1561375824760.png\" class=\"wp-image-1627 size-full\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/macro-1-e1561375824760.png?resize=650%2C241&#038;ssl=1\" alt=\"Macro: cold symptoms\" width=\"650\" height=\"241\" \/><\/a><figcaption id=\"caption-attachment-1627\" class=\"wp-caption-text\"><strong>Macro: cold-symptoms<\/strong><\/figcaption><\/figure>\n<p>The two rules <em><strong>\u201csymptom1\u201d and\u00a0\u201csymptom2\u201d\u00a0<\/strong><\/em>together define the category <em><strong>\u201cacute-disease&gt;common-cold\u201d<\/strong><\/em>.<\/p>\n<p>Let us now look at the other category <em><strong>\u201cacute-disease&gt;diarrhoea\u201d<\/strong><\/em>. See this figure:<\/p>\n<figure id=\"attachment_1628\" aria-describedby=\"caption-attachment-1628\" style=\"width: 649px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Diarrhoea-rule-1.png?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"1628\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2019\/06\/24\/text-analysis-using-meaningclouds-deep-categorization-api\/diarrhoea-rule-2\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Diarrhoea-rule-1-e1561375855331.png\" data-orig-size=\"649,412\" 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=\"Rule for Diarrhoea\" data-image-description=\"&lt;p&gt;Rule for Diarrhoea&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Rule for Diarrhoea&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Diarrhoea-rule-1-e1561375855331.png\" class=\"wp-image-1628 size-full\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Diarrhoea-rule-1-e1561375855331.png?resize=649%2C412&#038;ssl=1\" alt=\"Rule for Diarrhoea\" width=\"649\" height=\"412\" \/><\/a><figcaption id=\"caption-attachment-1628\" class=\"wp-caption-text\"><strong>Rule for Diarrhoea<\/strong><\/figcaption><\/figure>\n<p>This pattern expression is slightly more complex than the ones used for <em><strong>common cold<\/strong><\/em>. To whet your curiosity, the last part of the pattern <b>[putrid|watery|undigested stools]~4<\/b> matches the following cases:<\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">\u201cputrid stools\u201d<\/span><\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">\u201cwatery stools\u201d<\/span><\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">\u201cstools containing undigested food\u201d<\/span><\/p>\n<p>That is, the two sets of words may appear in any order within a span of 4 words. For a detailed description of the pattern syntax, see the <a href=\"https:\/\/www.meaningcloud.com\/developer\/resources\/doc\/deep-categorization-models\/rules\/syntax\" target=\"_blank\" rel=\"noopener\"><em><strong>documentation<\/strong><\/em><\/a>.<span class=\"Apple-converted-space\">\u00a0<\/span><\/p>\n<p>The following image shows our two categories:<\/p>\n<figure id=\"attachment_1619\" aria-describedby=\"caption-attachment-1619\" style=\"width: 653px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/All-categories.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1619\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2019\/06\/24\/text-analysis-using-meaningclouds-deep-categorization-api\/all-categories\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/All-categories-e1561375880945.png\" data-orig-size=\"650,267\" 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=\"The Two Categories in Our Model\" data-image-description=\"&lt;p&gt;The Two Categories in Our Model&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;The Two Categories in Our Model&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/All-categories-1024x420.png\" class=\"wp-image-1619 \" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/All-categories.png?resize=653%2C268&#038;ssl=1\" alt=\"The Two Categories in Our Model\" width=\"653\" height=\"268\" \/><\/a><figcaption id=\"caption-attachment-1619\" class=\"wp-caption-text\"><strong>The Two Categories in Our Model<\/strong><\/figcaption><\/figure>\n<p>Once the model has been defined, we need to <em><strong>\u201cBuild\u201d<\/strong><\/em> the model by clicking the <em><strong>\u201cBuild\u201d<\/strong><\/em> button under <em><strong>\u201cActions\u201d<\/strong><\/em> group on the left side (see above). If there are no errors, the model is compiled and we get a confirmation message:<\/p>\n<figure id=\"attachment_1620\" aria-describedby=\"caption-attachment-1620\" style=\"width: 410px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Build.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1620\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2019\/06\/24\/text-analysis-using-meaningclouds-deep-categorization-api\/build\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Build.png\" data-orig-size=\"410,273\" 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=\"Successful Build\" data-image-description=\"&lt;p&gt;Successful Build&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Successful Build&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Build.png\" class=\"size-full wp-image-1620\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Build.png?resize=410%2C273&#038;ssl=1\" alt=\"Successful Build\" width=\"410\" height=\"273\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Build.png?w=410&amp;ssl=1 410w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Build.png?resize=300%2C200&amp;ssl=1 300w\" sizes=\"(max-width: 410px) 100vw, 410px\" \/><\/a><figcaption id=\"caption-attachment-1620\" class=\"wp-caption-text\"><strong>Successful Build<\/strong><\/figcaption><\/figure>\n<p>Once the model is ready, we can test it with our sample data.The nice thing is that we can do this<span class=\"Apple-converted-space\">\u00a0<\/span>through the <em><strong>Test Console<\/strong><\/em>; there is no need to write any program to make <em><strong>API<\/strong><\/em> calls for this purpose. Clicking on the <em><strong>\u201cTest\u201d<\/strong><\/em> button under <em><strong>\u201cActions\u201d<\/strong><\/em> brings up the <em><strong>Test Console<\/strong><\/em> with our model already selected!<\/p>\n<figure id=\"attachment_1621\" aria-describedby=\"caption-attachment-1621\" style=\"width: 626px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/common-cold-case.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1621\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2019\/06\/24\/text-analysis-using-meaningclouds-deep-categorization-api\/common-cold-case\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/common-cold-case.png\" data-orig-size=\"848,875\" 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=\"Common Cold Sample Text\" data-image-description=\"&lt;p&gt;Common Cold Sample Text&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Common Cold Sample Text&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/common-cold-case.png\" class=\" wp-image-1621\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/common-cold-case.png?resize=626%2C646&#038;ssl=1\" alt=\"Common Cold Sample Text\" width=\"626\" height=\"646\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/common-cold-case.png?w=848&amp;ssl=1 848w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/common-cold-case.png?resize=291%2C300&amp;ssl=1 291w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/common-cold-case.png?resize=768%2C792&amp;ssl=1 768w\" sizes=\"(max-width: 626px) 100vw, 626px\" \/><\/a><figcaption id=\"caption-attachment-1621\" class=\"wp-caption-text\"><strong>Common Cold Sample Text<\/strong><\/figcaption><\/figure>\n<p>When you click <em><strong>&#8220;Raw&#8221;<\/strong><\/em> button at the bottom left, we get the result:<\/p>\n<figure id=\"attachment_1622\" aria-describedby=\"caption-attachment-1622\" style=\"width: 636px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Common-cold-result.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1622\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2019\/06\/24\/text-analysis-using-meaningclouds-deep-categorization-api\/common-cold-result\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Common-cold-result.png\" data-orig-size=\"849,781\" 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=\"Analysis Result\" data-image-description=\"&lt;p&gt;Analysis Result&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Analysis Result&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Common-cold-result.png\" class=\" wp-image-1622\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Common-cold-result.png?resize=636%2C585&#038;ssl=1\" alt=\"Analysis Result\" width=\"636\" height=\"585\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Common-cold-result.png?w=849&amp;ssl=1 849w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Common-cold-result.png?resize=300%2C276&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Common-cold-result.png?resize=768%2C706&amp;ssl=1 768w\" sizes=\"(max-width: 636px) 100vw, 636px\" \/><\/a><figcaption id=\"caption-attachment-1622\" class=\"wp-caption-text\"><strong>Analysis Result<\/strong><\/figcaption><\/figure>\n<p>You can see that the system has identified the key terms in the text and also computed overall relevance score of 40 (by the way, we can configure weights for various rules).<\/p>\n<p>Let us now look at an example of <em><strong>diarrhoea<\/strong><\/em>.<\/p>\n<figure id=\"attachment_1630\" aria-describedby=\"caption-attachment-1630\" style=\"width: 644px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/diarrhoea-case-1.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1630\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2019\/06\/24\/text-analysis-using-meaningclouds-deep-categorization-api\/diarrhoea-case-2\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/diarrhoea-case-1.png\" data-orig-size=\"855,871\" 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=\"Diarrhoea Example\" data-image-description=\"&lt;p&gt;Diarrhoea Example&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Diarrhoea Example&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/diarrhoea-case-1.png\" class=\" wp-image-1630\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/diarrhoea-case-1.png?resize=644%2C656&#038;ssl=1\" alt=\"Diarrhoea Example\" width=\"644\" height=\"656\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/diarrhoea-case-1.png?w=855&amp;ssl=1 855w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/diarrhoea-case-1.png?resize=294%2C300&amp;ssl=1 294w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/diarrhoea-case-1.png?resize=768%2C782&amp;ssl=1 768w\" sizes=\"(max-width: 644px) 100vw, 644px\" \/><\/a><figcaption id=\"caption-attachment-1630\" class=\"wp-caption-text\"><strong>Diarrhoea Example<\/strong><\/figcaption><\/figure>\n<p>And here is the analysis result:<\/p>\n<figure id=\"attachment_1624\" aria-describedby=\"caption-attachment-1624\" style=\"width: 666px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/diarrhoea-result.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1624\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2019\/06\/24\/text-analysis-using-meaningclouds-deep-categorization-api\/diarrhoea-result\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/diarrhoea-result.png\" data-orig-size=\"846,780\" 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=\"Analysis Result\" data-image-description=\"&lt;p&gt;Analysis Result&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Analysis Result&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/diarrhoea-result.png\" class=\" wp-image-1624\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/diarrhoea-result.png?resize=666%2C614&#038;ssl=1\" alt=\"Analysis Result\" width=\"666\" height=\"614\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/diarrhoea-result.png?w=846&amp;ssl=1 846w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/diarrhoea-result.png?resize=300%2C277&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/diarrhoea-result.png?resize=768%2C708&amp;ssl=1 768w\" sizes=\"(max-width: 666px) 100vw, 666px\" \/><\/a><figcaption id=\"caption-attachment-1624\" class=\"wp-caption-text\"><strong>Analysis Result<\/strong><\/figcaption><\/figure>\n<p>One thing worth pointing out is that the rules operate at <em><strong>&#8220;sentence&#8221;<\/strong><\/em> level (uses <em><strong>&#8220;Split Sentences&#8221;<\/strong><\/em> option). What this means is that the patterns are checked sentence by sentence. I feel this is an important option you have to consider while designing a model.<\/p>\n<p>Another useful capability is the support for exporting and\u00a0importing our models. This is needed if we are keeping track of different versions of our model.<\/p>\n<p>Needless to say, I am quite impressed with this new <em><strong>\u201cDeep Categorization\u201d<\/strong><\/em> feature since it opens up new techniques for identifying <em><strong>\u201chidden\u201d<\/strong><\/em> categories in the given text.<\/p>\n<p>One gentle warning may be in order here. Writing <em><strong>\u201cgood\u201d<\/strong><\/em> (expressive and efficient) pattern expressions for complex scenarios is really hard, and is no different from writing a <em><strong>\u201cgood program\u201d<\/strong><\/em> in any language. If we aren\u2019t careful enough, the rules can become <em><strong>\u201cfragile\u201d<\/strong><\/em> and fail to match valid scenarios. Of course, in these situations, it would be nice to have a tool that can take some sample sentences and generate the rules and pattern expression(s) for us! (Hope the tech team at <em><strong>MeaningCloud<\/strong><\/em> is listening!)<span class=\"Apple-converted-space\">\u00a0<\/span><\/p>\n<p>I trust you found this article interesting. I intend to spend more time exploring the deep categorization pattern language so that I can apply it to tougher problems.<\/p>\n<p>You might also be interested in looking at <em><strong>MeaningCloud&#8217;s Text Parsing<\/strong><\/em> engine, described in my earlier <a href=\"https:\/\/www.rangakrish.com\/index.php\/2018\/12\/09\/parsing-text-with-meaningclouds-text-analytics-api\/\" target=\"_blank\" rel=\"noopener\"><em><strong>blog<\/strong><\/em><\/a>.<\/p>\n<p>Have a nice day and great week ahead!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MeaningCloud\u00a0announced their premium offering \u201cDeep Categorization\u201d service quite recently. You can read about it in this nice blog\u00a0by Blanca Galego. Compared to the canonical classification models that rely on machine learning using large data sets, MeaningCloud\u2019s deep categorization models use hand-crafted rules that take advantage of \u201cmorphosyntactic, semantic and contextual information\u201d to classify a piece [&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":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[22,107,17],"tags":[211,25],"class_list":["post-1613","post","type-post","status-publish","format-standard","hentry","category-homeopathy","category-natural-language-processing","category-programming","tag-deep-text-categorization","tag-homeopathy"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9OLnF-q1","jetpack-related-posts":[{"id":1640,"url":"https:\/\/www.rangakrish.com\/index.php\/2019\/07\/11\/information-extraction-using-spacys-pattern-matcher\/","url_meta":{"origin":1613,"position":0},"title":"Information Extraction Using spaCy\u2019s Pattern Matcher","author":"admin","date":"July 11, 2019","format":false,"excerpt":"In the previous article, I explored the Deep Categorization capabilities of MeaningCloud. We saw how a powerful rule-based pattern matching language allowed us to map fragments of unstructured text to custom categories. In today\u2019s post, I want to go through spaCy\u2019s\u00a0pattern matching capabilities. The version I am using is 2.0.13.\u2026","rel":"","context":"In &quot;Homeopathy&quot;","block_context":{"text":"Homeopathy","link":"https:\/\/www.rangakrish.com\/index.php\/category\/homeopathy\/"},"img":{"alt_text":"Output","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/07\/Output.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/07\/Output.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/07\/Output.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":1368,"url":"https:\/\/www.rangakrish.com\/index.php\/2019\/01\/08\/parsing-text-with-apache-opennlp\/","url_meta":{"origin":1613,"position":1},"title":"Parsing Text with Apache OpenNLP","author":"admin","date":"January 8, 2019","format":false,"excerpt":"In my earlier posts I have written about parsing text using spaCy\u00a0and MeaningCloud's parsing API. For today's article, I decided to take a look at OpenNLP, an open-source ML-based Java toolkit for parsing natural language text. OpenNLP is a fairly mature library and has been around since 2004 (source: Wikipedia).\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":"Parse Tree","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/01\/Tree3.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1285,"url":"https:\/\/www.rangakrish.com\/index.php\/2018\/12\/09\/parsing-text-with-meaningclouds-text-analytics-api\/","url_meta":{"origin":1613,"position":2},"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":3321,"url":"https:\/\/www.rangakrish.com\/index.php\/2024\/02\/11\/using-similarity-search-in-homeopathy-repertorization-software\/","url_meta":{"origin":1613,"position":3},"title":"Using Similarity Search in Homeopathy Repertorization Software","author":"admin","date":"February 11, 2024","format":false,"excerpt":"Homeopathy Repertorization software such as RadarOpus, MacRepertory, Vithoulkas Compass, and Synergy Homeopathic Software (SHS) are widely used by homeopaths to speed up case taking, repertorization and case analysis. All of them have a \u201cSearch\u201d feature, where the given text is searched (typically based on key words and synonyms) against one\u2026","rel":"","context":"In &quot;Homeopathy&quot;","block_context":{"text":"Homeopathy","link":"https:\/\/www.rangakrish.com\/index.php\/category\/homeopathy\/"},"img":{"alt_text":"Vithoulkas Compass Example","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/02\/VCompass-300x65.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/02\/VCompass-300x65.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/02\/VCompass-300x65.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":3283,"url":"https:\/\/www.rangakrish.com\/index.php\/2023\/12\/26\/homeopathy-case-analysis-using-retrieval-augmented-generation\/","url_meta":{"origin":1613,"position":4},"title":"Homeopathy Case Analysis Using Retrieval-Augmented Generation","author":"admin","date":"December 26, 2023","format":false,"excerpt":"Homeopaths, after detailed case taking, usually \u2018\u201crepertorize\u201d\u00a0 the case using software such as RadarOpus, MacRepertory, Vithoulkas Compass, etc., and finally consult a Materia Medica to confirm the remedy selection. There are some highly experienced homeopaths who have the gift of identifying the correct remedy without even repertorizing the case, but\u2026","rel":"","context":"In &quot;Homeopathy&quot;","block_context":{"text":"Homeopathy","link":"https:\/\/www.rangakrish.com\/index.php\/category\/homeopathy\/"},"img":{"alt_text":"Example Chat","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/12\/Two-300x95.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/12\/Two-300x95.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/12\/Two-300x95.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":3660,"url":"https:\/\/www.rangakrish.com\/index.php\/2025\/04\/11\/using-claude-to-generate-rdf-triples\/","url_meta":{"origin":1613,"position":5},"title":"Using Claude to Generate RDF Triples","author":"admin","date":"April 11, 2025","format":false,"excerpt":"We all know that LLMs are now capable of generating structured data. I have used OpenAI models earlier to generate Tables and JSON data, but this time I wanted to try a more complex example.\u00a0 As someone interested in Homeopathy, I wanted to generate remedy descriptions as RDF triples, in\u2026","rel":"","context":"In &quot;Homeopathy&quot;","block_context":{"text":"Homeopathy","link":"https:\/\/www.rangakrish.com\/index.php\/category\/homeopathy\/"},"img":{"alt_text":"Lycopodium TTL Format","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/04\/Lyco-300x232.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/04\/Lyco-300x232.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/04\/Lyco-300x232.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/1613","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=1613"}],"version-history":[{"count":0,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/1613\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/media?parent=1613"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/categories?post=1613"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/tags?post=1613"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}