{"id":3573,"date":"2024-12-17T10:46:12","date_gmt":"2024-12-17T05:16:12","guid":{"rendered":"https:\/\/www.rangakrish.com\/?p=3573"},"modified":"2024-12-20T20:42:48","modified_gmt":"2024-12-20T15:12:48","slug":"using-prolog-to-solve-the-word-transformation-puzzle","status":"publish","type":"post","link":"https:\/\/www.rangakrish.com\/index.php\/2024\/12\/17\/using-prolog-to-solve-the-word-transformation-puzzle\/","title":{"rendered":"Using Prolog to Solve the Word Transformation Puzzle"},"content":{"rendered":"<p>In today\u2019s article, I want to share an interesting word puzzle, and then show how to solve it in <em><strong>Prolog<\/strong><\/em>.<\/p>\n<p><span style=\"text-decoration: underline;\">Here is the puzzle:<\/span><\/p>\n<p>You are given two words of the same length. You have to transform the first word into the second word, by changing only one letter at a time. The additional constraint is that each intermediate step must be a valid word!<\/p>\n<p>For example, here is one way to transform <em><strong>\u201ccold\u201d<\/strong><\/em> to <em><strong>\u201cwarm\u201d<\/strong><\/em>:<\/p>\n<p style=\"padding-left: 40px;\">1) cold -&gt; cord<\/p>\n<p style=\"padding-left: 40px;\">2) cord -&gt; card<\/p>\n<p style=\"padding-left: 40px;\">3) card -&gt; ward<\/p>\n<p style=\"padding-left: 40px;\">4) ward -&gt; warm<\/p>\n<p>A problem such as this one can be solved in any programming language. However, usually my first choice when it comes to puzzles is <em><strong>Prolog<\/strong><\/em>. Being a declarative language with built-in support for <em><strong>unification<\/strong><\/em> and <em><strong>backtracking<\/strong><\/em>, it is ideally suited for solving such problems. You may want to read my earlier article on <a href=\"https:\/\/www.rangakrish.com\/index.php\/2022\/10\/06\/why-learn-prolog\/\" target=\"_blank\" rel=\"noopener\"><em><strong>Prolog<\/strong><\/em><\/a>.<\/p>\n<p>Let us get started. We need a <em><strong>dictionary<\/strong><\/em> to check whether a sequence of characters is indeed a valid English word. For the sake of this toy problem, let us limit ourselves to a few 4 letter words:<\/p>\n<figure id=\"attachment_3574\" aria-describedby=\"caption-attachment-3574\" style=\"width: 400px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/12\/prolog1.jpg?ssl=1\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" data-attachment-id=\"3574\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2024\/12\/17\/using-prolog-to-solve-the-word-transformation-puzzle\/prolog1\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2024\/12\/prolog1.jpg\" data-orig-size=\"572,533\" 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=\"Our Dictionary\" data-image-description=\"&lt;p&gt;Our Dictionary&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Our Dictionary&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2024\/12\/prolog1.jpg\" class=\"wp-image-3574\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/12\/prolog1.jpg?resize=400%2C373&#038;ssl=1\" alt=\"Our Dictionary\" width=\"400\" height=\"373\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/12\/prolog1.jpg?resize=300%2C280&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/12\/prolog1.jpg?w=572&amp;ssl=1 572w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/a><figcaption id=\"caption-attachment-3574\" class=\"wp-caption-text\"><strong>Our Dictionary<\/strong><\/figcaption><\/figure>\n<p>We need a predicate to check if two valid words are neighbors (they differ by exactly one letter).<\/p>\n<figure id=\"attachment_3575\" aria-describedby=\"caption-attachment-3575\" style=\"width: 500px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/12\/prolog2.jpg?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"3575\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2024\/12\/17\/using-prolog-to-solve-the-word-transformation-puzzle\/prolog2\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2024\/12\/prolog2.jpg\" data-orig-size=\"909,529\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1734342532&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=\"Check for Neighboring Words\" data-image-description=\"&lt;p&gt;Check for Neighboring Words&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Check for Neighboring Words&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2024\/12\/prolog2.jpg\" class=\"wp-image-3575\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/12\/prolog2.jpg?resize=500%2C291&#038;ssl=1\" alt=\"Check for Neighboring Words\" width=\"500\" height=\"291\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/12\/prolog2.jpg?resize=300%2C175&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/12\/prolog2.jpg?resize=768%2C447&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/12\/prolog2.jpg?w=909&amp;ssl=1 909w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><figcaption id=\"caption-attachment-3575\" class=\"wp-caption-text\"><strong>Check for Neighboring Words<\/strong><\/figcaption><\/figure>\n<p>Here is the main predicate <em><strong>print_word_chain<\/strong><\/em>:<\/p>\n<figure id=\"attachment_3576\" aria-describedby=\"caption-attachment-3576\" style=\"width: 500px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/12\/prolog3.jpg?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"3576\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2024\/12\/17\/using-prolog-to-solve-the-word-transformation-puzzle\/prolog3\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2024\/12\/prolog3.jpg\" data-orig-size=\"938,831\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1734347928&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=\"Checking Valid Transformation\" data-image-description=\"&lt;p&gt;Checking Valid Transformation&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Checking Valid Transformation&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2024\/12\/prolog3.jpg\" class=\"wp-image-3576\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/12\/prolog3.jpg?resize=500%2C443&#038;ssl=1\" alt=\"Checking Valid Transformation\" width=\"500\" height=\"443\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/12\/prolog3.jpg?resize=300%2C266&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/12\/prolog3.jpg?resize=768%2C680&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/12\/prolog3.jpg?w=938&amp;ssl=1 938w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><figcaption id=\"caption-attachment-3576\" class=\"wp-caption-text\"><strong>Checking Valid Transformation<\/strong><\/figcaption><\/figure>\n<p>We need a helper to perform <em><strong>breadth-first search<\/strong><\/em> to trace the solution path:<\/p>\n<figure id=\"attachment_3577\" aria-describedby=\"caption-attachment-3577\" style=\"width: 500px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/12\/prolog4.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3577\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2024\/12\/17\/using-prolog-to-solve-the-word-transformation-puzzle\/prolog4\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2024\/12\/prolog4.jpg\" data-orig-size=\"770,623\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1734347889&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=\"Breadth First Search\" data-image-description=\"&lt;p&gt;Breadth First Search&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Breadth First Search&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2024\/12\/prolog4.jpg\" class=\"wp-image-3577\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/12\/prolog4.jpg?resize=500%2C405&#038;ssl=1\" alt=\"Breadth First Search\" width=\"500\" height=\"405\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/12\/prolog4.jpg?resize=300%2C243&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/12\/prolog4.jpg?resize=768%2C621&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/12\/prolog4.jpg?w=770&amp;ssl=1 770w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><figcaption id=\"caption-attachment-3577\" class=\"wp-caption-text\"><strong>Breadth First Search<\/strong><\/figcaption><\/figure>\n<p>When you run the program, here is the output:<\/p>\n<figure id=\"attachment_3578\" aria-describedby=\"caption-attachment-3578\" style=\"width: 550px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/12\/prolog-output.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3578\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2024\/12\/17\/using-prolog-to-solve-the-word-transformation-puzzle\/prolog-output-2\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2024\/12\/prolog-output.jpg\" data-orig-size=\"1332,572\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1734342406&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=\"Program Output\" data-image-description=\"&lt;p&gt;Program Output&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Program Output&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2024\/12\/prolog-output-1024x440.jpg\" class=\"wp-image-3578\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/12\/prolog-output.jpg?resize=550%2C236&#038;ssl=1\" alt=\"Program Output\" width=\"550\" height=\"236\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/12\/prolog-output.jpg?resize=300%2C129&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/12\/prolog-output.jpg?resize=1024%2C440&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/12\/prolog-output.jpg?resize=768%2C330&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/12\/prolog-output.jpg?w=1332&amp;ssl=1 1332w\" sizes=\"(max-width: 550px) 100vw, 550px\" \/><\/a><figcaption id=\"caption-attachment-3578\" class=\"wp-caption-text\"><strong>Program Output<\/strong><\/figcaption><\/figure>\n<p>The program works as expected. The above program was tested in <em><strong>Sicstus Prolog ver 4.8<\/strong><\/em> on <em><strong>Windows 10<\/strong><\/em>. You can download the code <a href=\"https:\/\/www.rangakrish.com\/downloads\/word-puzzle.pro\"><em><strong>here<\/strong><\/em><\/a>.<\/p>\n<p>Have a nice week!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In today\u2019s article, I want to share an interesting word puzzle, and then show how to solve it in Prolog. Here is the puzzle: You are given two words of the same length. You have to transform the first word into the second word, by changing only one letter at a time. The additional constraint [&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":[17,147],"tags":[148,410],"class_list":["post-3573","post","type-post","status-publish","format-standard","hentry","category-programming","category-prolog","tag-prolog","tag-word-puzzle"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9OLnF-VD","jetpack-related-posts":[{"id":3589,"url":"https:\/\/www.rangakrish.com\/index.php\/2025\/01\/04\/word-transformation-puzzle-part-2-implementation-in-common-lisp\/","url_meta":{"origin":3573,"position":0},"title":"Word Transformation Puzzle &#8211; Part 2: Implementation in Common Lisp","author":"admin","date":"January 4, 2025","format":false,"excerpt":"In the last article\u00a0I discussed an interesting word puzzle and showed how to solve it using Prolog. Here is the problem statement: \u201cYou are given two words of the same length. You have to transform the first word into the second word, by changing only one letter at a time.\u2026","rel":"","context":"In &quot;LISP&quot;","block_context":{"text":"LISP","link":"https:\/\/www.rangakrish.com\/index.php\/category\/lisp\/"},"img":{"alt_text":"Getting Word Neighbors","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/code1-300x127.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/code1-300x127.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/code1-300x127.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":2366,"url":"https:\/\/www.rangakrish.com\/index.php\/2021\/03\/28\/implementing-ilexicon-using-litedb\/","url_meta":{"origin":3573,"position":1},"title":"Implementing iLexicon using LiteDB","author":"admin","date":"March 28, 2021","format":false,"excerpt":"iLexicon is an \"intelligent\" dictionary that can be used to build Natural Language applications. I have two implementations, one in Lisp and another in Prolog. Both implementations are memory-based, in order to speed up performance. I have written several articles referencing it, for example see this. \u00a0 LiteDB is a\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":"Sample Commands","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/03\/Session1.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1025,"url":"https:\/\/www.rangakrish.com\/index.php\/2018\/08\/19\/sicstus-prolog-building-a-windows-executable\/","url_meta":{"origin":3573,"position":2},"title":"Sicstus Prolog &#8211; Building a Windows Executable","author":"admin","date":"August 19, 2018","format":false,"excerpt":"In my previous post, I showed how to build a C-based Windows DLL to execute Prolog predicates in the Sicstus Prolog\u00a0engine. Today, I want to show how to build an executable (on Windows) from a C\/C++ program that uses Sicstus prolog engine. The process is quite simple. In order to\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":"Creating WordNet Prolog Image","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/08\/Creating-image.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/08\/Creating-image.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/08\/Creating-image.png?resize=525%2C300 1.5x"},"classes":[]},{"id":2922,"url":"https:\/\/www.rangakrish.com\/index.php\/2022\/10\/06\/why-learn-prolog\/","url_meta":{"origin":3573,"position":3},"title":"Why Learn Prolog?","author":"admin","date":"October 6, 2022","format":false,"excerpt":"There are several programming languages in use today and a simple google search will throw up interesting recommendations of a subset of these languages to learn, usually based on popularity ranking. As is expected, the popularity of a programming language varies over time and hence a language that was in\u2026","rel":"","context":"In &quot;Programming&quot;","block_context":{"text":"Programming","link":"https:\/\/www.rangakrish.com\/index.php\/category\/programming\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1727,"url":"https:\/\/www.rangakrish.com\/index.php\/2019\/09\/15\/exploring-word-patterns\/","url_meta":{"origin":3573,"position":4},"title":"Exploring Word Patterns","author":"admin","date":"September 15, 2019","format":false,"excerpt":"Working with word patterns can be an exciting (and challenging) creative activity. Such patterns come into picture while playing word games, solving word puzzles or even writing poetry. It is precisely to facilitate such tasks that I am building my \"iLexicon\" system.\u00a0 One popular word game goes like this: The\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":"Prolog Predicates for Word Pair Generation","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/09\/Code.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/09\/Code.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/09\/Code.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":534,"url":"https:\/\/www.rangakrish.com\/index.php\/2017\/05\/22\/definite-clause-grammars-dcg-in-lisp\/","url_meta":{"origin":3573,"position":5},"title":"Definite Clause Grammars (DCG) in Lisp","author":"admin","date":"May 22, 2017","format":false,"excerpt":"Definite Clause Grammars (DCG) are an elegant formalism for specifying context free grammars, and part of their popularity is due to their support in the Prolog language. Most books on Natural Language processing usually include a brief coverage of DCGs, even though Natural languages are not context-free. Because of the\u2026","rel":"","context":"In &quot;LISP&quot;","block_context":{"text":"LISP","link":"https:\/\/www.rangakrish.com\/index.php\/category\/lisp\/"},"img":{"alt_text":"DCG Grammar","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2017\/05\/DCG-Grammar.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2017\/05\/DCG-Grammar.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2017\/05\/DCG-Grammar.png?resize=525%2C300 1.5x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/3573","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=3573"}],"version-history":[{"count":0,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/3573\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/media?parent=3573"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/categories?post=3573"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/tags?post=3573"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}