{"id":846,"date":"2018-02-11T03:19:05","date_gmt":"2018-02-11T03:19:05","guid":{"rendered":"http:\/\/www.rangakrish.com\/?p=846"},"modified":"2018-02-11T04:48:02","modified_gmt":"2018-02-11T04:48:02","slug":"onomatopoeia-palindrome-and-semordnilap","status":"publish","type":"post","link":"https:\/\/www.rangakrish.com\/index.php\/2018\/02\/11\/onomatopoeia-palindrome-and-semordnilap\/","title":{"rendered":"Onomatopoeia, Palindrome and Semordnilap"},"content":{"rendered":"<p>I had earlier\u00a0briefly talked about the <a href=\"http:\/\/www.rangakrish.com\/index.php\/2017\/08\/06\/text-generation-using-ilanggen-framework\/\" target=\"_blank\" rel=\"noopener\"><b><i>Ilexicon <\/i><\/b><\/a>project that I have been working on for some time now. The goal is to build an intelligent <b><i>dictionary<\/i><\/b>\u00a0that will come in handy while implementing NLP applications such as recognizers and generators. In today&#8217;s post, I want to demonstrate some cool features available in <b><i>iLexicon<\/i><\/b>. At present <b><i>iLexicon <\/i><\/b>supports only English.<\/p>\n<p>Let us start with a simple query: List words having 2 syllables, 8 letters and containing the substring <strong>zz<\/strong>.<\/p>\n<p style=\"padding-left: 30px;\"><strong><span style=\"color: #008000;\">cg-user(1): (get-matching-words\u00a0 :word-pat &#8220;[a-z]+zz[a-z]+$&#8221; :num-syllables 2 :num-letters 8)<\/span><\/strong><\/p>\n<p style=\"padding-left: 30px;\"><strong><span style=\"color: #008000;\">(&#8220;blizzard&#8221; &#8220;grizzled&#8221; &#8220;frizzing&#8221; &#8220;frizzler&#8221; &#8220;grizzler&#8221; &#8220;quizzing&#8221; &#8220;whizzing&#8221;)<\/span><\/strong><\/p>\n<p><b><i>get-matching-words <\/i><\/b>is the main function to search for words in the lexicon. It has numerous options and supports rich queries, as you will discover soon. Here, it takes a word pattern specification (a regular expression), the number of syllables and the number of letters the word should be made of.<\/p>\n<p>Let us find out how many words are in the dictionary with <b><i>at least <\/i><\/b>8 letters:<\/p>\n<p style=\"padding-left: 30px;\"><strong><span style=\"color: #008000;\">cg-user(2): (length (get-matching-words :num-letters &#8216;(8 nil)))<\/span><\/strong><\/p>\n<p style=\"padding-left: 30px;\"><strong><span style=\"color: #008000;\">262647<\/span><\/strong><\/p>\n<p>Slightly more interesting query this time: Find all words that start with <em><strong>g<\/strong><\/em> and end with either <em><strong>e<\/strong><\/em> or <em><strong>m<\/strong><\/em>, which also rhyme with the word <em><strong>home<\/strong><\/em>.<\/p>\n<p style=\"padding-left: 30px;\"><strong><span style=\"color: #008000;\">cg-user(3): (get-matching-words :word-pat &#8220;^g[a-z]+[em]$&#8221; :rhyming-with &#8220;home&#8221;)<\/span><\/strong><\/p>\n<p style=\"padding-left: 30px;\"><strong><span style=\"color: #008000;\">(&#8220;gloam&#8221; &#8220;gnome&#8221;)<\/span><\/strong><\/p>\n<p>The lexicon knows about parts of speech, so we can ask a query like this: List all <b><i>Verbs <\/i><\/b>that have 15 letters in them.<\/p>\n<p style=\"padding-left: 30px;\"><strong><span style=\"color: #008000;\">cg-user(4): (get-matching-words :pos &#8220;[V]&#8221; :num-letters 15)<\/span><\/strong><\/p>\n<p style=\"padding-left: 30px;\"><strong><span style=\"color: #008000;\">(&#8220;circumstantiate&#8221; &#8220;consubstantiate&#8221; &#8220;conventionalise&#8221; &#8220;conventionalize&#8221; &#8220;cross-fertilize&#8221;<\/span><\/strong><\/p>\n<p style=\"padding-left: 30px;\"><strong><span style=\"color: #008000;\">\u00a0&#8220;cross-pollinate&#8221; &#8220;dedifferentiate&#8221; &#8220;haemagglutinate&#8221; &#8220;professionalise&#8221; &#8220;professionalize&#8221; &#8230;)<\/span><\/strong><\/p>\n<p>Because this is a large list, I have shown only a part of it.<\/p>\n<p>Another nice feature in the lexicon is the information about accent structure of words. This is quite useful when you are writing poetry, and you want words to conform to certain <b><i>foot <\/i><\/b>and <b><i>meter<\/i><\/b>. In the query below, I am asking for all <b><i>Adjectives <\/i><\/b>containing the substring <b><i>mon <\/i><\/b>and which have the syllable structure <b><i>unstressed-unstressed-stressed-unstressed-unstressed<\/i><\/b>:<\/p>\n<p style=\"padding-left: 30px;\"><strong><span style=\"color: #008000;\">cg-user(5): (get-matching-words\u00a0 :accent-structure &#8220;uusuu&#8221; :pos &#8220;[J]&#8221; :word-pat &#8220;mon&#8221;)<\/span><\/strong><\/p>\n<p style=\"padding-left: 30px;\"><strong><span style=\"color: #008000;\">(&#8220;acrimonious&#8221; &#8220;ammoniacal&#8221; &#8220;antimonious&#8221; &#8220;ceremonial&#8221; &#8220;ceremonious&#8221; &#8220;commonsensical&#8221; &#8220;demoniacal&#8221;\u00a0 &#8220;disharmonious&#8221; &#8220;inharmonious&#8221; &#8220;matrimonial&#8221; &#8230;)<\/span><\/strong><\/p>\n<p>We can ask for words that have a specific stem. The lexicon supports both <b><i>Porter <\/i><\/b>and <b><i>Snowball <\/i><\/b>stems.<\/p>\n<p style=\"padding-left: 30px;\"><strong><span style=\"color: #008000;\">cg-user(6): (get-matching-words :snowball-stem &#8220;terrac&#8221;)<\/span><\/strong><\/p>\n<p style=\"padding-left: 30px;\"><strong><span style=\"color: #008000;\">(&#8220;terrace&#8221; &#8220;terraced&#8221;)<\/span><\/strong><\/p>\n<p>Let us now focus on interesting word patterns similar to the ones listed in the title of this blog. Let us start with <a href=\"https:\/\/dictionary.cambridge.org\/dictionary\/english\/palindrome\" target=\"_blank\" rel=\"noopener\"><b><i>Palindromes <\/i><\/b><\/a>. The lexicon marks palindrome words as such, so you can query directly:<\/p>\n<p style=\"padding-left: 30px;\"><strong><span style=\"color: #008000;\">cg-user(7): (get-matching-words :word-pat &#8220;t$&#8221;\u00a0 :palindrome 1 :num-letters 5)<\/span><\/strong><\/p>\n<p style=\"padding-left: 30px;\"><strong><span style=\"color: #008000;\">(&#8220;tebet&#8221; &#8220;tenet&#8221; &#8220;tevet&#8221; &#8220;tibit&#8221;)<\/span><\/strong><\/p>\n<p>\u00a0Here I am asking for 5-letter words ending in <em><strong>t<\/strong><\/em> that are also palindromes.<\/p>\n<p>An <a href=\"https:\/\/en.wikipedia.org\/wiki\/Isogram\" target=\"_blank\" rel=\"noopener\"><b><i>Isogram <\/i><\/b><\/a>\u00a0is a word that has no repeating letters. Let us look for 5-letter isograms starting with the letter <em><strong>c<\/strong><\/em>:<\/p>\n<p style=\"padding-left: 30px;\"><strong><span style=\"color: #008000;\">cg-user(8): (get-matching-words :word-pat &#8220;^c&#8221; :num-letters 5 :isogram 1)<\/span><\/strong><\/p>\n<p style=\"padding-left: 30px;\"><strong><span style=\"color: #008000;\">(&#8220;cabin&#8221; &#8220;cabot&#8221; &#8220;cadge&#8221; &#8220;cadgy&#8221; &#8220;cagey&#8221; &#8220;caine&#8221; &#8220;caird&#8221; &#8220;cairn&#8221; &#8220;cager&#8221; &#8220;caius&#8221; &#8230;)<\/span><\/strong><\/p>\n<p><a href=\"http:\/\/www.dictionary.com\/browse\/onomatopoeia\" target=\"_blank\" rel=\"noopener\"><b><i>Onomatopoeia<\/i><\/b><\/a>\u00a0 means using words that sound similar to the entities they denote. Two examples are <em><strong>buzz<\/strong><\/em> and <em><strong>hiss<\/strong><\/em>.<\/p>\n<p>Here are some Onomatopoeic words that end in <em><strong>g<\/strong><\/em>:<\/p>\n<p style=\"padding-left: 30px;\"><strong><span style=\"color: #008000;\">cg-user(9): (get-matching-words :word-pat &#8220;g$&#8221;\u00a0 :onomatopoeia 1)<\/span><\/strong><\/p>\n<p style=\"padding-left: 30px;\"><strong><span style=\"color: #008000;\">(&#8220;bang&#8221; &#8220;bing&#8221; &#8220;bong&#8221; &#8220;clang&#8221; &#8220;ding-dong&#8221; &#8220;ding&#8221; &#8220;gong&#8221; &#8220;ping&#8221; &#8220;pong&#8221; &#8220;ring&#8221; &#8230;)<\/span><\/strong><\/p>\n<p><a href=\"https:\/\/www.macmillandictionary.com\/buzzword\/entries\/semordnilap.html\" target=\"_blank\" rel=\"noopener\"><b><i>Semordnilap<\/i><\/b><\/a>\u00a0refers to a word which, when read in reverse, means another word. Notice that <b><i>Semordnilap <\/i><\/b>is <b><i>Palindromes <\/i><\/b>spelt in reverse!<\/p>\n<p style=\"padding-left: 30px;\"><strong><span style=\"color: #008000;\">cg-user(10): (get-matching-words :word-pat &#8220;^p&#8221;\u00a0 :semordnilap 1 :num-letters &#8216;(4 6))<\/span><\/strong><\/p>\n<p style=\"padding-left: 30px;\"><strong><span style=\"color: #008000;\">(&#8220;part&#8221; &#8220;peek&#8221; &#8220;plew&#8221; &#8220;plug&#8221; &#8220;pool&#8221; &#8220;poort&#8221; &#8220;pope&#8221; &#8220;port&#8221; &#8220;pose&#8221; &#8220;prat&#8221; &#8220;proc&#8221; &#8220;prod&#8221; &#8230;)<\/span><\/strong><\/p>\n<p>In addition to all these interesting word patterns, iLexicon contains another useful feature. Given a word, it can give you other grammatical forms of the word. For instance, if you want the <b><i>comparative degree<\/i><\/b> of the adjective <b><i>good<\/i><\/b>, you can do this:<\/p>\n<p style=\"padding-left: 30px;\"><strong><span style=\"color: #008000;\">cg-user(11): (get-word-forms &#8220;good&#8221; &#8216;(D2))<\/span><\/strong><\/p>\n<p style=\"padding-left: 30px;\"><strong><span style=\"color: #008000;\">(&#8220;better&#8221;)<\/span><\/strong><\/p>\n<p>Here <b><i>D<\/i><\/b> stands for <b><i>degree <\/i><\/b>and <b><i>2<\/i><\/b> means <b><i>comparative<\/i><\/b>. So what is the <em><strong>positive<\/strong><\/em> form of <b><i>best<\/i><\/b>? Let us find out:<\/p>\n<p style=\"padding-left: 30px;\"><strong><span style=\"color: #008000;\">cg-user(12): (get-word-forms &#8220;best&#8221; &#8216;(D1))<\/span><\/strong><\/p>\n<p style=\"padding-left: 30px;\"><strong><span style=\"color: #008000;\">(&#8220;good&#8221; &#8220;well&#8221;)<\/span><\/strong><\/p>\n<p>We get both <b><i>good <\/i><\/b>and <b><i>well<\/i><\/b>. Useful, isn&#8217;t it?<\/p>\n<p>There are many more exotic features built into <b><i>iLexicon<\/i><\/b>, and of course, it is still work in progress. I will share with you more details about this project in due course.<\/p>\n<p>The core engine of iLexicon is written in <a href=\"https:\/\/franz.com\/products\/allegrocl\/\" target=\"_blank\" rel=\"noopener\">Allegro CL<\/a> on Windows.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I had earlier\u00a0briefly talked about the Ilexicon project that I have been working on for some time now. The goal is to build an intelligent dictionary\u00a0that will come in handy while implementing NLP applications such as recognizers and generators. In today&#8217;s post, I want to demonstrate some cool features available in iLexicon. At present iLexicon [&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":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[18,107,17],"tags":[41,130,131,133,132,134],"class_list":["post-846","post","type-post","status-publish","format-standard","hentry","category-lisp","category-natural-language-processing","category-programming","tag-dictionary","tag-ilexicon","tag-onomatopoeia","tag-palindrome","tag-semordnilap","tag-word-patterns"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9OLnF-dE","jetpack-related-posts":[{"id":856,"url":"https:\/\/www.rangakrish.com\/index.php\/2018\/02\/25\/sentiments-and-emotions-in-ilexicon\/","url_meta":{"origin":846,"position":0},"title":"Sentiments and Emotions in iLexicon","author":"admin","date":"February 25, 2018","format":false,"excerpt":"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\u2026","rel":"","context":"In &quot;LISP&quot;","block_context":{"text":"LISP","link":"https:\/\/www.rangakrish.com\/index.php\/category\/lisp\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":863,"url":"https:\/\/www.rangakrish.com\/index.php\/2018\/03\/11\/kangaroo-words\/","url_meta":{"origin":846,"position":1},"title":"Kangaroo Words","author":"admin","date":"March 11, 2018","format":false,"excerpt":"According to Wikipedia, \"A kangaroo word is a word that contains letters of another word, in order, with the same meaning. For example: the word 'masculine' contains the word 'male', which is a synonym of the first word; similarly, the word 'observe' contains its synonym 'see'.\" Interesting idea. The key\u2026","rel":"","context":"In &quot;LISP&quot;","block_context":{"text":"LISP","link":"https:\/\/www.rangakrish.com\/index.php\/category\/lisp\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1349,"url":"https:\/\/www.rangakrish.com\/index.php\/2018\/12\/30\/natural-language-interaction-with-ilexicon-using-luis\/","url_meta":{"origin":846,"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":846,"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":2366,"url":"https:\/\/www.rangakrish.com\/index.php\/2021\/03\/28\/implementing-ilexicon-using-litedb\/","url_meta":{"origin":846,"position":4},"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":1659,"url":"https:\/\/www.rangakrish.com\/index.php\/2019\/08\/04\/generating-poetry-in-prolog\/","url_meta":{"origin":846,"position":5},"title":"Generating Poetry in Prolog","author":"admin","date":"August 4, 2019","format":false,"excerpt":"In an earlier article, I showed how we can generate poetry (with limitations, of course!) using my iLangGen framework. That implementation (in Lisp) made use of iLexicon, a large dictionary of English words, which I have been building over the years. I subsequently ported iLexicon to Prolog and it now\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":"Generation Logic","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/08\/Code3.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/08\/Code3.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/08\/Code3.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/846","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=846"}],"version-history":[{"count":0,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/846\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/media?parent=846"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/categories?post=846"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/tags?post=846"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}