Natural Language Interaction with iLexicon Using LUIS

Written by on December 30, 2018 in LISP, Natural Language Processing, Programming with 0 Comments

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 language instead of through Lisp. That idea had never crossed my mind until then. Later, I started thinking about how I could build a simple NLP front-end to that system. I remembered a project that an intern did with me over a year ago using Microsoft LUIS and decided to explore that option.

So, here is what we want: The user would pose queries such as “Give me a list of pronouns” or “What are some verbs with 4 syllables?”. The system needs to respond by returning the words that satisfy the query. The natural language communication is one way – from user to the system. The interaction is still in the context of Lisp, but it can be converted to an independent app with a little bit of extra effort.

The three components of the system are shown in the following diagram.

System Architecture

System Architecture

As the above diagram shows, iLexicon runs as a server process, and exposes a REST API. The client app (Lisp environment) additionally interacts with LUIS.

I have earlier built a C++ client application (written in C++ Builder 10.3) that interacts with the iLexicon server. But that app does not provide NLP front-end. Here is a sample session with that application:

C++ Client

C++ Client

When the client app sends an NLP query to LUIS, it gets a JSON response in return. Here is an example of the JSON object from LUIS for the query “give me some verbs with 6 letters”:

Result JSON

Result JSON

The Lisp client converts the result JSON to appropriate parameters compatible with iLexicon REST server and invokes that API. The returned result is parsed and presented as a Lisp expression.

Working with LUIS to design the intents and entities was a straightforward task. As in any development effort, this is an iterative process. In this particular case, I started off with a handful of sample sentences and kept adding more as and when I found out some sentences were not parsed correctly. The Test console was quite helpful here. When I was confident that I had the right model, I Published the model and got an end-point for use from an external application.

By the way, LUIS is typically used as part of a chatbot framework along with Microsoft Bot Framework, but I did not need the latter since I was not building a chatbot. Although I could have used any other NLP parsing service such as or a library such as spaCy, that would have meant more work from my side.

Here is the Lisp code fragment that talks to LUIS:

Talking to LUIS

Talking to LUIS

And here is the function that talks to iLexicon REST server:

Talking to iLexicon

Talking to iLexicon

OK, let us look at some typical NLP queries and their responses.

CL-USER 10 > (execute-nlp-query “show me some 5 letter palindromes”)
(“aeaea” “alula” “aviva” “civic” “enone” “kaiak” “kayak” “kazak” “kelek” “kodok” “laval”
“level” “ma’am” “madam” “menem” “minim” “oruro” “radar” “refer” “rotor”
“seles” “senes” “sinis” “siris” “tebet” “tenet” “tevet” “igigi” “tibit” “xanax”
“malam” “noyon” “nomon” “reger”)

CL-USER 11 > (execute-nlp-query “i would like some 4 syllable nouns that are a type of building “)
(“architecture” “aviary” “crenelation” “dormitory” “fabrication” “mortuary” “presbytery”
“rustication” “crenellation”)

CL-USER 12 > (execute-nlp-query “what are some pronouns?”)
(“her” “herself” “him” “himself” “it” “itself” “myself” “oneself” “our” “ourselves” “she”
“that” “them” “themselves” “they” “this” “we” “whoever” “whom” “whomsoever”
 “whose” “ye” “you” “yourself”)

CL-USER 13 > (execute-nlp-query “give me some verbs that have 6 letters and 3 syllables?”)
(“aerify” “argufy” “aurify” “aviate” “awaken” “basify” “canopy” “citify” “codify” “elicit”
“embody” “enable” “enamel” “enamor” “gasify” “ideate” “intuit” “iodize” “ionise”
“ionize” “minify” “modify” “mutiny” “nazify” “notify” “occupy” “orient” “ossify”
“overdo” “pacify” “parody” “purify” “ramify” “rarefy” “ratify” “rebury” “refuel”
“remedy” “reopen” “resume” “salute” “tumefy” “typify” “vacuum” “verify” “vilify”
“vivify” “iodise” “recopy” “uglify”

I could go on and on with more examples, but that will suffice for now. I just wanted to show that it is possible to build simple NLP front-ends using tools such as LUIS. If you are interested in building chatbots, then Amazon Lex  is another promising candidate.

Thanks for your wonderful support all these years! Wish you all a fantastic 2019!!


Tags: ,


If you enjoyed this article, subscribe now to receive more just like it.

Subscribe via RSS Feed

Leave a Reply

Your email address will not be published. Required fields are marked *