User:Martinwheatman/Enguage

Enguage is the open source Natural-language understanding program which won the BCS SGAI Machine Intelligence Competition 2016. It was inspired both by John Searle's Chinese Room rule book, and by Terry Winograd's SHRDLU, as an interface to an OODb, where the tray of blocks is a space for classes and objects. Enguage development was influenced by Peircean Semiotics and broadly follows Speech Act Theory by emphasising doing things through utterance. It is self-generating, or autopoietic, because its interpretation of utterance is defined, itself, in natural language utterances. It recognises that interpretation is context dependent and attempts to find the most appropriate understanding through user interaction. Because of this interactivity, it can be described as a mediator rather than an interpreter. Enguage can be run as a CLI or used through an API within an application. The name Enguage is a portmanteau of language and engine.

Utterance
Utterance is an information bearing medium. Information, unlike data, is not a physical entity but the result of interpretation, modelled as Signs by Charles Sanders Peirce. Enguage interprets utterances as Signs by encoding them as values, rather than the truth-value approach of Linguistics.

In Speech Act terms, the locutionary act is performed by the user, and Enguage performs the illocutionary act. In obtaining the required response, the perlocutionary act can be ensured. Thus, the success of an utterance is measured by its effects.

Encoding
Enguage is grounded in natural numbers. Each utterance, thought and reply is a very large value represented as an array of strings of letters. This is similar to Gödel Numbering, but using a simpler encoding. So ["i", "need", "a", "coffee"] is a single value in an arbitrary base, in the same way [1, 0, 2, 4] might represent 1,024 in base 10. In such a way there are no zeros, which would represent the empty string, and there are no spaces, an utterance is a single value.

Semiotic Representation
Enguage enacts an utterance as a functioning Sign. This is illustrated in The Meaning of Meaning (1923), see figure 1. The user utterance corresponds to SYMBOL; THOUGHT OR REFERENCE is also one, or more, utterances; and the Enguage reply is the REFERENT object. The connection between the two is arbitrary, thus anything can be said; however, it requires that Interpretant to be supported. All connection is only through thought, although this might be just: reply "hello to you too".

Unequivocal Response
Enguage responds with one of several replies. Each reply should be unequivocal. This is to help the user identify any misinterpretation or misunderstandings. This is at least I do not understand. User interaction is used to select the intended interpretation and to disambiguate misunderstandings. Enguage deems the process of obtaining the most appropriate interpretation of an utterance as mediation.

Interpretation
The interpretation which Enguage performs is the mapping of an utterance to one of several replies, either as a direct reference (translation ) or through some train of thought (transformation ) which may involve machine interaction.

Each interpretation contains a pattern and a list of intentions, and is the embodiment of a Sign. A pattern matches an utterance to a sign. Each intention is an internal utterance or thought. Enguage maintains the felicity of the interpretation to create a train of thought. The definition of an interpretation can be written or captured by voice. The written interpretations of related utterances and Configurations of the concept are gathered within a file to form a repertoire.

Pattern
Enguage uses a pattern to match an utterance to a sign. The need to arbitrarily map each utterance onto a reply might suggest every utterance need its own interpretation; however, a pattern allows all the utterances it matches to use the same interpretation.

A pattern is represented in written form with uppercase words as parameters (e.g. variables), and lowercase words as string literals (i.e. constants). Variables may be prefixed by PHRASE-, NUMERIC- or SIGN- , to modify what they match. An example pattern from the need+needs repertoire is: «SUBJECT needs NUMERIC-QUANTITY UNITS of PHRASE-OBJECT». Patterns can be described vocally, this example would be described as, "variable subject needs numeric variable quantity variable units of phrase variable object". To summon the string literal variable one must say "variable variable"; this prevents the creation of VARIABLE as a variable, but this is an acceptable limitation.

A matched a utterance/pattern equates to a list of matched string literals and a list of parameters. This represents the SYMBOL in figure 1, or Representamen, functioning of a sign. So matching the utterance:


 * "I need a coffee", to the pattern:
 * «i need NUMERIC-QUANTITY PHRASE-OBJECT», equates to:
 * function i_need( Numeric quantity="a", Array of String object=["coffee"] );

A pattern does not equate to a syntax because a syntax contains abstract symbols such as S, NP, VP, N, etc., whereas a pattern is always grounded by string literals, e.g. the i need in «i need PHRASE-X». A pattern is more like a context-free syntax, in that programming languages contain a high degree of syntactic tokens, e.g. ';', ',', '(', ')', '{', '}'.

Intentions
The instructions operated when a sign is applicable to an utterance are known as intentions. In Enguage, these are also utterances, and because they are operated internally and do not have their replies returned to the user, they are sometime described as thoughts. This train of thoughts is followed until an utterance beginning with reply is found.

Because Enguage does things with words, this includes interfacing with other applications and programs, and offers intentions to this end.


 * perform - this intention, which accepts one quoted string as parameter, gives access to the inbuilt object database. The quoted string, like the pattern, contains lowercase constants, and uppercase variables. The syntax for this is " ...", such as "person create martin", or "   ...", such as "martin name set Martin Wheatman". Further examples can be found in the assets/concept repertoire files.
 * run - this intention give access to native programs on the host. An example of this is used in the test.txt repertoire and Enguage test suite.
 * tcpip - this intention allows the connection to a tcp/ip server, such as an http daemon. It takes 3 parameters: the server name, the port address ad the string to send. Examples are available in the Enguage test suite, such as:
 * tcpip https://en.wikipedia.org/ 80 "GET /wiki/User:Martinwheatman/Enguage"

Further, there a few parts-of-speech which act like intentions/control the operation of Enguage. While Enguage claims semiotic arbitrariness, it may be difficult to re-appropriate them.


 * reply - this accepts one quoted string, which is the value to be passed back to the calling level. Variables are substituted, and the ellipse is replaced with the answer.


 * if not,/if so, - these are the utterance prefixes to access the value of felicity, and so create a train of through. The default is if so.

Felicity
Enguage maintains a status of interpretation, its felicity. This word is used in its sense of eloquence: whether a positive reply is returned or whether it is an I don't understand or other negative reply. Normally, the felicity of an interpretation can encoded within the reply itself. Using an initial word followed by a comma, the words 'sorry', and 'no' record an infelicitous outcome, whereas 'ok', 'yes' and 'so' record a felicitous outcome. Further, a number can be returned which is also felicitous in cases of numeric calculation, such as "4, 2 plus 2 is 4". An infelicitous reply will result in only the subsequent thoughts beginning if not, being interpreted, until the next felicitous reply.

Reply and Answer
A reply is a formatted answer. Like felicity, an answer is obtained and maintained throughout interpretation. When a formatted answer is passed back it would be presented to the user, if outermost; however, it can be reformatted by any outer level of interpretation. So, a numeric answer might be 42, but the formatted reply is "42, 6 times 7 is 42".

Disambiguation
To target the most relevant interpretation, signs are ranked in order of their pattern complexity. This is calculated from the number and type of parameters within a pattern, so that "I need a coffee" will match «i need a coffee», before it matches «i need NUMERIC-QUANTITY OBJECT» .

If a reply is infelicitous: one which is not recognised by the user, or not the one expected, a mechanism exists to help achieve the intended one: the utterance is repeated with the prefix "no, ...".

Repertoire
A repertoires is a set of interpretations with a common word, or words, in the pattern. A repertoire file has the filename of that common word, or words, and an extension of .txt. For scaleability, a repertoire is only loaded when an utterance matches with the filename, so the need+needs repertoire is load on the utterance "I need a coffee" or "Martin needs a coffee". There is a time to live parameter, which specifies the number of utterance to which the repertoire name does not match before it is unloaded. This is given so that secondary utterances, which do not match the repertoire file name, can also be defined within the repertoire. For example, "I need a coffee" can be followed by "and another" for Enguage to record that I need two coffees. In addition to the '+' symbol to concatenate patterns, there is the underscore symbol '_' to match a space, and the hyphen '-' to match a gap between words.

The test repertoire is need+needs. It was developed to aid initial development of Enguage, and contains the utterances: «i need PHRASE-OBJECTS»; «i do not need PHRASE-OBJECTS»; do i need PHRASE-OBJECTS»; and, «what do i need». This has been developed to support who needs what, numeric quantities, and numeric quantities of units of X.

One or more repertoires support a concept.

Autopoiesis
Enguage does not understand language. It has 13 built-in signs to interpret written signs, and16 to interpret vocal utterances, which constructs Signs. Thus, language is extensible.

Concepts
Concepts are the things we can talk about. They are created and manipulated by utterances. While they are concrete, they display polymorphic properties:


 * the utterance "want is like need" will derive the concept want from the base concept need.
 * SIGN- prefix allows patterns to match complete utterances, e.g. "I need 3 eggs because I am baking a cake", will match the pattern «SIGN-WHAT because SIGN-CAUSE» . Both WHAT, "I need 3 eggs", and CAUSE,"I am baking a cake" are both concepts (need and baking) in their own right.

Conversational Interface
Enguage represents a model of conversation, see Figure 2, which uses Peircean Semiotic terminology: Sign/Representamen-Interpretant-Object. This illustration consists of two Ogden and Richards Semiotic Triangles, figure 1, placed top-to-bottom and bottom to top. The repy for one serves as the utternace of the other. By user utterances referencing Enguage replies, the machine's functions are accessed. The connection between the two Interpretant vertices, labelled as Quasi-Mind, as an attempt to illustrate the sharing of ideas: the person as Quasi-utterer, the machine as Quasi-interpreter.

By interacting directly with concepts, in natural language, a conversational interface is constructed. With concepts being implemented using concepts and the use of concepts within concepts a rich interactive environment emerges.

The Chinese Room
Despite winning the 2016 BCS SGAI Machine Intelligence Competition, Enguage makes no claims as to being intelligent. It does not aim to pass the Turing Test; or to maintain a conversation, beyond the immediate intentions of the user. But as the mechanism for constructing language interface, it hope to shed light on the discussion around the Chinese Room thought experiment, which aimed to show that computers do not need to understand language to process it. Enguage does show that an important feature of language is not only that it develops, it is an information system and is self-generating. It is not sufficient for the occupant of the room to swap symbols, it needs to construct the rules on swapping. This probably does not change the analysis of the Chinese Room argument.

Turing Completeness
It is worth mentioning that loops can be created by recursion.

Examples
Examples using Enguage include:


 * Needs repertoire including location qualifiers, e.g. I need milk from the dairy aisle;
 * Meeting repertoire including spatio-temporal qualifiers e.g. I'm meeting my brother at the pub at 10pm;
 * Verbal reasoning using the why+because repertoire, e.g. I need 3 eggs because I am baking a cake.

Enguage vocal programming examples include:


 * a simple greeting, i.e. to the phrase hello reply hello to you too.
 * creating and using a simple variable, i.e. to the phrase my name is variable name reply hello variable name.

Further examples (over 300) are available in the Enguage test suite:


 * run with: java Enguage --test