Hi, I'll introduce you to programming in natural language.
In this demo, we'll glimpse at the steps needed to prepare an API for
programming with natural language, what we call NLCI, the Natural
Language Command Interpreter.
We use Gizmo, a Lego robot that can be programmed using a Java API.
As you can see, it's a high-level API that hides the mechanical
details, that is, the electric motor of Gizmo's Caterpillar drive, and
so on.
We'll configure NLCI with Gizmo's API, so that NLCI can translate
English prose into method sequences that Gizmo actually understands.
From the outside, NLCI is a black box that feeds on English prose and
generates source code.
NLCI is a modular architecture, and the text analysis do not depend on
the API that we'd like to address.
Thus, the API itself can be seen as a configuration for NLCI.
We model the API in an API ontology.
NLCI provides the structure of the API model, so that developers can
easily model new APIs.
If the API uses meaningful English identifiers and follows common
coding conventions, such as CamelCase, etc., the API automatically
expands its understanding to synonyms and other linguistic
information.
But how does such an ontology look like in reality?
In the top-left window, you can see the structure of the ontology.
In the lower left, we can see the available elements of the API.
Here are the real-world objects we want Gizmo to interact with.
We'll take a closer look at Gizmo itself.
As you can see on the right, there are quite a few methods to choose
from, including their overloads.
Building such an ontology can, of course, be done manually, but this
is error-prone and very cumbersome.
We've built ontologies for different use cases.
The ontology for OpenHAB, a smart home control application, is quite
small.
And we've created the classes by hand.
Then, we wrote a small generator that feeds an actual OpenHAB
configuration into the ontology.
The API for Gizmo covers roughly 20 classes and over 50 methods.
Nothing you would do by hand.
Fortunately, a generator that reads Java source code can be written
with less than 500 lines of code.
For complex formats, the generators themselves can be larger.
We wrote a generator that reads the class libraries of CMU's Alice, a
3D simulation software that has a little over 2000 lines of code.
Alice came with over 900 classes, so having a generator is well worth
the effort.
After NLCI is prepped with the API ontology, the various text analyses
take over.
The analyses comprise standard natural language processing tools,
including Stanford's Core NLP, and specialized modules that, for
instance, link the text elements with methods of the API.
We cannot cover the details of text analysis in this video, but
usually a developer only provides the API ontology.
The final stage uses all gained information and generates the desired
source code.
Note that the code generation depends on the programming language and
not on an API, so you can reuse your Java generator for any Java
project.
Here you can see the Java boilerplate code for Gizmo, but much more
interesting is where Gizmo moves to soda can and interacts with it.
The natural language input is printed above the code as comments.
As you can see, NLCI correctly resolves pronouns and handles synonyms.
The API itself only knows tens, not cans.
Would you like to know more?
Then come and talk to us.
In the demo, we'll show Gizmo's API, walk you through the steps of API
preprocessing, demystify the ontology, and dive a little bit deeper
into NLCI's text analysis.
Also, we'll bring Gizmo the robot.
Thanks for watching.