{"id":1025,"date":"2018-08-19T07:20:19","date_gmt":"2018-08-19T01:50:19","guid":{"rendered":"http:\/\/www.rangakrish.com\/?p=1025"},"modified":"2018-08-19T07:30:14","modified_gmt":"2018-08-19T02:00:14","slug":"sicstus-prolog-building-a-windows-executable","status":"publish","type":"post","link":"https:\/\/www.rangakrish.com\/index.php\/2018\/08\/19\/sicstus-prolog-building-a-windows-executable\/","title":{"rendered":"Sicstus Prolog &#8211; Building a Windows Executable"},"content":{"rendered":"<p>In my <a href=\"http:\/\/www.rangakrish.com\/index.php\/2018\/08\/05\/sicstus-prolog-building-a-windows-dll\/\" target=\"_blank\" rel=\"noopener\">previous post<\/a>, I showed how to build a C-based Windows <em><strong>DLL<\/strong><\/em> to execute Prolog predicates in the <a href=\"https:\/\/sicstus.sics.se\/\" target=\"_blank\" rel=\"noopener\">Sicstus Prolog<\/a>\u00a0engine. Today, I want to show how to build an <em><strong>executable<\/strong><\/em> (on Windows) from a C\/C++ program that uses Sicstus prolog engine.<\/p>\n<p>The process is quite simple. In order to make things interesting, I am using a large-sized,<span class=\"Apple-converted-space\">\u00a0 <\/span><em><strong>real-world<\/strong><\/em> Prolog program to demonstrate this process. The example I will be using is the <a href=\"https:\/\/github.com\/ekaf\/wordnet-prolog\" target=\"_blank\" rel=\"noopener\"><em><strong>WordNet<\/strong> <strong>Prolog<\/strong><\/em><\/a> database (I downloaded the <em><strong>WNprolog-3.1.tar.gz<\/strong><\/em> file). The bundle contains documentation as well as Prolog files. There are 21 source files, out of which <em><strong>wn_s.pl<\/strong> <\/em>and <em><strong>wn_sk.pl<\/strong><\/em> are the largest, with 207,202 predicates each.<\/p>\n<p>First, I wrote a simple Prolog program to load all the <em><strong>WordNet<\/strong><\/em> Prolog files into Sicstus environment and save the final image as <em><strong>WordNet.sav<\/strong><\/em> file. That way, it is convenient and faster to eventually load the full <em><strong>WordNet<\/strong><\/em> database into Sicstus environment. Here is the program that does that (all referenced files are available <a href=\"http:\/\/www.rangakrish.com\/downloads\/exe-example-files.zip\" target=\"_blank\" rel=\"noopener\">here<\/a>):<\/p>\n<figure id=\"attachment_1026\" aria-describedby=\"caption-attachment-1026\" style=\"width: 649px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/08\/Creating-image.png\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" data-attachment-id=\"1026\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2018\/08\/19\/sicstus-prolog-building-a-windows-executable\/creating-image\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2018\/08\/Creating-image.png\" data-orig-size=\"972,325\" 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=\"Creating WordNet Prolog Image\" data-image-description=\"&lt;p&gt;Creating WordNet Prolog Image&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Creating WordNet Prolog Image&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2018\/08\/Creating-image.png\" class=\"wp-image-1026\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/08\/Creating-image.png?resize=649%2C217\" alt=\"Creating WordNet Prolog Image\" width=\"649\" height=\"217\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/08\/Creating-image.png?w=972&amp;ssl=1 972w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/08\/Creating-image.png?resize=300%2C100&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/08\/Creating-image.png?resize=768%2C257&amp;ssl=1 768w\" sizes=\"(max-width: 649px) 100vw, 649px\" \/><\/a><figcaption id=\"caption-attachment-1026\" class=\"wp-caption-text\"><strong>Creating WordNet Prolog Image<\/strong><\/figcaption><\/figure>\n<p>Here is the C++ program (in spirit it is just C) that loads the <em><strong>WordNet<\/strong><\/em> image into Sicstus Prolog engine, invokes two predicates in a nested fashion and prints the results.<\/p>\n<blockquote>\n<div>\n<div><span style=\"color: #0000ff;\">\/\/ Rangarajan Krishnamoorthy, August 16, 2018.<\/span><\/div>\n<div><span style=\"color: #0000ff;\">\/\/ Example to create an Executable to load and run WordNet Prolog<\/span><\/div>\n<div><span style=\"color: #0000ff;\">\/\/ files in Sicstus Prolog.<\/span><\/div>\n<div><span style=\"color: #0000ff;\">\/\/<\/span><\/div>\n<div><\/div>\n<div><span style=\"color: #0000ff;\">#include &lt;sicstus\/sicstus.h&gt;<\/span><\/div>\n<div><span style=\"color: #0000ff;\">#include &lt;iostream&gt;<\/span><\/div>\n<div><span style=\"color: #0000ff;\">using namespace std;<\/span><\/div>\n<div><\/div>\n<div><span style=\"color: #0000ff;\">int main()<\/span><\/div>\n<div><span style=\"color: #0000ff;\">{<\/span><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">\/\/ Initialize the Prolog engine<\/span><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">if (SP_FAILURE == SP_initialize(0, NULL, NULL)) {<\/span><\/div>\n<div style=\"padding-left: 60px;\"><span style=\"color: #0000ff;\">cout &lt;&lt; &#8220;Init error\\n&#8221;;<\/span><\/div>\n<div style=\"padding-left: 60px;\"><span style=\"color: #0000ff;\">return -1;<\/span><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">}<\/span><\/div>\n<div style=\"padding-left: 30px;\"><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">\/\/ Load the saved WordNet program image<\/span><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">int res = SP_restore(&#8220;WordNet.sav&#8221;);<\/span><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">if (res == SP_ERROR || res == SP_FAILURE) {<\/span><\/div>\n<div style=\"padding-left: 60px;\"><span style=\"color: #0000ff;\">cout &lt;&lt; &#8220;Restore error\\n&#8221;;<\/span><\/div>\n<div style=\"padding-left: 60px;\"><span style=\"color: #0000ff;\">return -2;<\/span><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">}<\/span><\/div>\n<div style=\"padding-left: 30px;\"><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">SP_qid goal, goal2;<\/span><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">SP_term_ref synset_id, wnum, ss_type, sense_num, tag_count, word;<\/span><\/div>\n<div style=\"padding-left: 30px;\"><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">\/\/ Create the &#8220;s&#8221; predicate<\/span><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">SP_pred_ref s_pred = SP_predicate(&#8220;s&#8221;, 6, NULL);<\/span><\/div>\n<div style=\"padding-left: 30px;\"><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">\/\/ Let us lookup the synset IDs for the word &#8220;lion&#8221;<\/span><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">SP_put_string(word = SP_new_term_ref(), &#8220;lion&#8221;);<\/span><\/div>\n<div style=\"padding-left: 30px;\"><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">\/\/ To keep things simple, let us restrict to &#8220;noun&#8221; form alone<\/span><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">SP_atom pos = SP_atom_from_string(&#8220;n&#8221;);<\/span><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">SP_put_atom(ss_type = SP_new_term_ref(), pos);<\/span><\/div>\n<div style=\"padding-left: 30px;\"><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">\/\/ Assign suitable variables to other arguments of the predicate<\/span><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">SP_put_variable(synset_id = SP_new_term_ref());<\/span><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">SP_put_variable(wnum = SP_new_term_ref());<\/span><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">SP_put_variable(sense_num = SP_new_term_ref());<\/span><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">SP_put_variable(tag_count = SP_new_term_ref());<\/span><\/div>\n<div style=\"padding-left: 30px;\"><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">\/\/ Let us create another predicate for getting the &#8220;gloss&#8221;<\/span><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">SP_pred_ref g_pred = SP_predicate(&#8220;g&#8221;, 2, NULL);<\/span><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">SP_term_ref gloss;<\/span><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">SP_put_variable(gloss = SP_new_term_ref());<\/span><\/div>\n<div style=\"padding-left: 30px;\"><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">\/\/ Prepare to execute the predicate<\/span><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">if (!(goal = SP_open_query(s_pred, synset_id, wnum, word, ss_type, sense_num, tag_count))) {<\/span><\/div>\n<div style=\"padding-left: 60px;\"><span style=\"color: #0000ff;\">cout &lt;&lt; &#8220;Open &#8216;s&#8217; query error\\n&#8221;;<\/span><\/div>\n<div style=\"padding-left: 60px;\"><span style=\"color: #0000ff;\">return -3;<\/span><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">}<\/span><\/div>\n<div style=\"padding-left: 30px;\"><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">\/\/ Keep trying for solutions<\/span><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">while (SP_next_solution(goal) == SP_SUCCESS) {<\/span><\/div>\n<div style=\"padding-left: 60px;\"><span style=\"color: #0000ff;\">SP_integer sid;<\/span><\/div>\n<div style=\"padding-left: 60px;\"><\/div>\n<div style=\"padding-left: 60px;\"><span style=\"color: #0000ff;\">\/\/ We are interested in synset ID<\/span><\/div>\n<div style=\"padding-left: 60px;\"><span style=\"color: #0000ff;\">SP_get_integer(synset_id, &amp;sid);<\/span><\/div>\n<div style=\"padding-left: 60px;\"><\/div>\n<div style=\"padding-left: 60px;\"><span style=\"color: #0000ff;\">cout &lt;&lt; &#8220;Solution found. ID is: &#8221; &lt;&lt; sid &lt;&lt; endl;<\/span><\/div>\n<div style=\"padding-left: 60px;\"><\/div>\n<div style=\"padding-left: 60px;\"><span style=\"color: #0000ff;\">\/\/ Nested query &#8211; let us find the gloss for matching IDs<\/span><\/div>\n<div style=\"padding-left: 60px;\"><span style=\"color: #0000ff;\">if (!(goal2 = SP_open_query(g_pred, synset_id, gloss))) {<\/span><\/div>\n<div style=\"padding-left: 90px;\"><span style=\"color: #0000ff;\">cout &lt;&lt; &#8220;Open &#8216;g&#8217; query error\\n&#8221;;<\/span><\/div>\n<div style=\"padding-left: 90px;\"><span style=\"color: #0000ff;\">continue;<\/span><\/div>\n<div style=\"padding-left: 60px;\"><span style=\"color: #0000ff;\">}<\/span><\/div>\n<div style=\"padding-left: 60px;\"><span style=\"color: #0000ff;\">while (SP_next_solution(goal2) == SP_SUCCESS) {<\/span><\/div>\n<div style=\"padding-left: 90px;\"><span style=\"color: #0000ff;\">const char *gloss_str = NULL;<\/span><\/div>\n<div style=\"padding-left: 90px;\"><\/div>\n<div style=\"padding-left: 90px;\"><span style=\"color: #0000ff;\">\/\/ We are interested in the &#8216;gloss&#8217; text<\/span><\/div>\n<div style=\"padding-left: 90px;\"><span style=\"color: #0000ff;\">SP_get_string(gloss, &amp;gloss_str);<\/span><\/div>\n<div style=\"padding-left: 90px;\"><\/div>\n<div style=\"padding-left: 90px;\"><span style=\"color: #0000ff;\">cout &lt;&lt; &#8220;Gloss = &#8221; &lt;&lt; gloss_str &lt;&lt; endl;<\/span><\/div>\n<div style=\"padding-left: 60px;\"><span style=\"color: #0000ff;\">}<\/span><\/div>\n<div style=\"padding-left: 60px;\"><span style=\"color: #0000ff;\">\/\/ Nested query must be closed before continuing with the higher level query.<\/span><\/div>\n<div style=\"padding-left: 60px;\"><span style=\"color: #0000ff;\">SP_close_query(goal2);<\/span><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">}<\/span><\/div>\n<div style=\"padding-left: 30px;\"><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">\/\/ Close the query<\/span><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">SP_close_query(goal);<\/span><\/div>\n<div style=\"padding-left: 30px;\"><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">\/\/ Shut down the Prolog engine<\/span><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">SP_deinitialize();<\/span><\/div>\n<div style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">return 0;<\/span><\/div>\n<div><span style=\"color: #0000ff;\">}<\/span><\/div>\n<div><\/div>\n<\/div>\n<\/blockquote>\n<p>The above program (<em><strong>WordNetExample.cpp<\/strong><\/em>) prints the <em><strong>Synset ID<\/strong><\/em> and its corresponding <em><strong>gloss<\/strong><\/em> for the word <em><strong>lion,\u00a0<\/strong><\/em>for<em><strong> Noun <\/strong><\/em>part of speech. The logic is fairly straightforward and I hope the comments make the program easier to understand. Detailed information about the various runtime functions is available in the official Sicstus documentation (in my installation, it is <em><strong>sicstus.pdf<\/strong><\/em>).<span class=\"Apple-converted-space\">\u00a0<\/span><\/p>\n<p>The next step is to launch the command prompt and configure the <em><strong>Visual Studio 2017<\/strong><\/em> 64 bit environment. We did this as part of building the <em><strong>DLL<\/strong><\/em> in the previous post, but here it is again.<\/p>\n<figure id=\"attachment_1029\" aria-describedby=\"caption-attachment-1029\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/08\/Configuring-VS2017.png\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"1029\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2018\/08\/19\/sicstus-prolog-building-a-windows-executable\/configuring-vs2017\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2018\/08\/Configuring-VS2017.png\" data-orig-size=\"986,326\" 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=\"Configuring VS2017\" data-image-description=\"&lt;p&gt;Configuring VS2017&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Configuring VS2017&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2018\/08\/Configuring-VS2017.png\" class=\"wp-image-1029\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/08\/Configuring-VS2017.png?resize=650%2C215\" alt=\"Configuring VS2017\" width=\"650\" height=\"215\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/08\/Configuring-VS2017.png?w=986&amp;ssl=1 986w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/08\/Configuring-VS2017.png?resize=300%2C99&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/08\/Configuring-VS2017.png?resize=768%2C254&amp;ssl=1 768w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><\/a><figcaption id=\"caption-attachment-1029\" class=\"wp-caption-text\">Configuring VS2017<\/figcaption><\/figure>\n<p>Sicstus Prolog <em><strong>BIN<\/strong><\/em> directory is assumed to be in the <em><strong>PATH<\/strong><\/em>. Next, CD to the directory where the our C++ file is located. Execute the following command:<\/p>\n<blockquote><p><span style=\"color: #0000ff;\">&gt; spld<span class=\"Apple-converted-space\">\u00a0 <\/span>&#8211;main=none WordNetExample.cpp -o WordNetExample.exe<\/span><\/p><\/blockquote>\n<p>It is important to set the <em><strong>main<\/strong><\/em> option to <em><strong>none<\/strong><\/em>. This causes our <em><strong>main<\/strong><\/em> to be executed.<\/p>\n<p>It takes just a few seconds to create the output file.<\/p>\n<p>Before running the program, we have to make sure that the file\u00a0<em><strong>WordNet.sa<\/strong><strong>v<\/strong><\/em> is in the same directory as the executable (remember we have not hardcoded any other path).<\/p>\n<figure id=\"attachment_1030\" aria-describedby=\"caption-attachment-1030\" style=\"width: 653px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/08\/Running-the-program.png\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"1030\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2018\/08\/19\/sicstus-prolog-building-a-windows-executable\/running-the-program\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2018\/08\/Running-the-program.png\" data-orig-size=\"919,138\" 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=\"Running the Executable\" data-image-description=\"&lt;p&gt;Running the Executable&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Running the Executable&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2018\/08\/Running-the-program.png\" class=\"wp-image-1030\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/08\/Running-the-program.png?resize=653%2C98\" alt=\"Running the Executable\" width=\"653\" height=\"98\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/08\/Running-the-program.png?w=919&amp;ssl=1 919w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/08\/Running-the-program.png?resize=300%2C45&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/08\/Running-the-program.png?resize=768%2C115&amp;ssl=1 768w\" sizes=\"(max-width: 653px) 100vw, 653px\" \/><\/a><figcaption id=\"caption-attachment-1030\" class=\"wp-caption-text\">Running the Executable<\/figcaption><\/figure>\n<p>As expected, the program prints the <em><strong>Synset ID<\/strong><\/em> and <em><strong>gloss<\/strong><\/em> for the two (Noun) senses of the word <em><strong>lion<\/strong><\/em>.<\/p>\n<p>Once thing I really like about Sicstus Prolog is its performance.<span class=\"Apple-converted-space\">\u00a0 <\/span>It took a mere 1.22 seconds<span class=\"Apple-converted-space\">\u00a0<\/span>to load the saved image (containing 21 Prolog files in compiled format) in its IDE. As a commercial product, it is widely respected for its speed. As part of my <em><strong>iLexicon<\/strong><\/em> project, I have several Prolog files containing descriptions of a large number (around 300 thousand) of English words, and Sicstus Prolog loads all of them effortlessly. Sicstus&#8217; official <a href=\"https:\/\/sicstus.sics.se\/performance.html\" target=\"_blank\" rel=\"noopener\">benchmarks<\/a> may be found here.<\/p>\n<p>Files referenced in today&#8217;s post (other than <em><strong>WordNet<\/strong><\/em> files) maybe downloaded from <a href=\"http:\/\/www.rangakrish.com\/downloads\/exe-example-files.zip\" target=\"_blank\" rel=\"noopener\">here<\/a>. <em><strong>WordNet<\/strong><\/em> Prolog files can be downloaded from <a href=\"https:\/\/github.com\/ekaf\/wordnet-prolog\" target=\"_blank\" rel=\"noopener\">here<\/a>.<\/p>\n<p>Have a nice weekend!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 make things interesting, I am [&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":[107,17,147],"tags":[151,128],"class_list":["post-1025","post","type-post","status-publish","format-standard","hentry","category-natural-language-processing","category-programming","category-prolog","tag-sicstus-prolog","tag-wordnet"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9OLnF-gx","jetpack-related-posts":[{"id":1004,"url":"https:\/\/www.rangakrish.com\/index.php\/2018\/08\/05\/sicstus-prolog-building-a-windows-dll\/","url_meta":{"origin":1025,"position":0},"title":"Sicstus Prolog &#8211; Building a Windows DLL","author":"admin","date":"August 5, 2018","format":false,"excerpt":"Last week I upgraded to the latest version (4.4.1) of Sicstus Prolog\u00a0for Windows.\u00a0Since the Prolog engine can be embedded (royalty free) in other applications, it is useful to understand how to create a DLL (on Windows) for this purpose. In today's article, I would like to outline this process in\u2026","rel":"","context":"In &quot;C++&quot;","block_context":{"text":"C++","link":"https:\/\/www.rangakrish.com\/index.php\/category\/c\/"},"img":{"alt_text":"Creating Prolog Program Image","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/08\/Saving-Prolog-Image.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/08\/Saving-Prolog-Image.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/08\/Saving-Prolog-Image.png?resize=525%2C300 1.5x"},"classes":[]},{"id":1770,"url":"https:\/\/www.rangakrish.com\/index.php\/2019\/11\/10\/calling-c-methods-from-sicstus-prolog-through-com-interface\/","url_meta":{"origin":1025,"position":1},"title":"Calling C# Methods from Sicstus Prolog through COM Interface","author":"admin","date":"November 10, 2019","format":false,"excerpt":"Recently\u00a0I needed to make use of a C# library (which I had implemented a few years ago) from Sicstus Prolog. Calling C\/C++ functions from Sicstus Prolog is fairly well documented. When it comes to C#\/.NET, the official documentation recommends the PrologBeans library. After going through the documentation, I felt that\u2026","rel":"","context":"In &quot;Programming&quot;","block_context":{"text":"Programming","link":"https:\/\/www.rangakrish.com\/index.php\/category\/programming\/"},"img":{"alt_text":"Prolog Client Code","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/11\/Prolog-Code.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/11\/Prolog-Code.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/11\/Prolog-Code.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":1677,"url":"https:\/\/www.rangakrish.com\/index.php\/2019\/08\/18\/using-berkeley-db-with-sicstus-prolog\/","url_meta":{"origin":1025,"position":2},"title":"Using Berkeley DB with Sicstus Prolog","author":"admin","date":"August 18, 2019","format":false,"excerpt":"One of the nice features of Sicstus Prolog\u00a0is the support for storing Terms\u00a0externally in a Berkeley DB\u00a0database. Since we can control how the terms are indexed in the database, it is possible to store and retrieve a large amount of Terms\u00a0(the limit is 2^32-1) fairly efficiently. This can be useful\u2026","rel":"","context":"In &quot;Programming&quot;","block_context":{"text":"Programming","link":"https:\/\/www.rangakrish.com\/index.php\/category\/programming\/"},"img":{"alt_text":"Iterating Over the DB","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/08\/iterate-db.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/08\/iterate-db.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/08\/iterate-db.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":3260,"url":"https:\/\/www.rangakrish.com\/index.php\/2023\/11\/26\/generating-polynomials-in-prolog\/","url_meta":{"origin":1025,"position":3},"title":"Generating Polynomials in Prolog","author":"admin","date":"November 26, 2023","format":false,"excerpt":"Polynomial is an important topic in High School maths curriculum. There are many online courses that explain the topic in great details with lots of examples and sample exercises. Wouldn\u2019t it be interesting if we can generate polynomials of given degree programmatically? It turns out that this is not such\u2026","rel":"","context":"In &quot;Programming&quot;","block_context":{"text":"Programming","link":"https:\/\/www.rangakrish.com\/index.php\/category\/programming\/"},"img":{"alt_text":"Generating Polynomials - Main Clauses","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/11\/Code1-300x163.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/11\/Code1-300x163.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/11\/Code1-300x163.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":2433,"url":"https:\/\/www.rangakrish.com\/index.php\/2021\/06\/06\/getting-to-know-visual-prolog-10\/","url_meta":{"origin":1025,"position":4},"title":"Getting to Know Visual Prolog 10","author":"admin","date":"June 6, 2021","format":false,"excerpt":"Visual Prolog\u00a0has its roots in Turbo Prolog, which was popularized by Borland in the mid 1980s. It is developed and supported by PDC A\/S, Denmark. So how is Visual Prolog different from other Prolog implementations out there, for example, SWI-Prolog or Sicstus Prolog? Here are the key differences: 1) It\u2026","rel":"","context":"In &quot;C++&quot;","block_context":{"text":"C++","link":"https:\/\/www.rangakrish.com\/index.php\/category\/c\/"},"img":{"alt_text":"Visual Prolog Project","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/06\/Project-300x183.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/06\/Project-300x183.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/06\/Project-300x183.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":1757,"url":"https:\/\/www.rangakrish.com\/index.php\/2019\/10\/13\/conjugating-phrasal-verbs\/","url_meta":{"origin":1025,"position":5},"title":"Conjugating Phrasal Verbs","author":"admin","date":"October 13, 2019","format":false,"excerpt":"In the last article, I showed how to generate verb conjugations in the \"iLexicon\" system. Today, let us see how this idea can be extended to English \"phrasal verbs\". According to Wikipedia: \"a phrasal verb is a phrase such as turn down or ran into which combines two or three\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":"Conjugation of \"Turn on\"","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/10\/Example3.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/1025","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=1025"}],"version-history":[{"count":0,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/1025\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/media?parent=1025"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/categories?post=1025"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/tags?post=1025"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}