Skip to content

English Engine for Grammar

Ian edited this page Aug 10, 2024 · 4 revisions

Overview

Background

The algorithms used for this system are based upon the Direct Context Grammar architecture of SWI-Prolog, which uses a modified "if-then" operator:

(X-->Y) which is equivalent to a strict equality.

The principle development of this was funded by NASA, and the research was conducted at Augustana University in Sioux Falls, South Dakota. The work was presented at the annual Augustana Symposium in 2010 by Ian Malloy.

This program began in 2010 as a skeleton for natural language processing while I was an undergraduate studying cognitive science. Predictive capabilities based on statistics were formalized outside the program, but have yet to be implemented. It had also been planned to incorporate a "best search first." The best search first was later implemented in an expert system, though it hasn't been adapted for this buffer.

Sentence Structure

The following [trace] ?- sentence. list gives the rules for parsing a sentence based on user input. As of the writing of this wiki, the variables of sentences, words, nouns, prepositions, determinants, noun phrases, preposition phrases, and verb phrases have limited arity.

l:sentence :-

`user:`
`(   (   idea`
    `;   question`
    `;   command`
    `),`
    `l:noun_p,`
    `l:prep_p,`
    `l:verb_p`
`).`

l:sentence :-

`user:read(49).`

l:sentence :-

`user:objective(_).`

l:sentence :-

`user:`
`(   (   l:noun_p,`
        `l:verb_p`
    `;   l:noun_p,`
        `l:prep_p,`
        `l:word`
    `;   l:verb,`
        `l:noun_p,`
        `l:prep_p,`
        `l:word`
    `)`
`).`

l:sentence(A, B) :-

`user:l:grab(l:sentence, l:word(A, B, objective)).`

l:sentence(A, B) :-

`user:l:word(A, input, B).`

l:sentence(A, B) :-

`user:`
`(   getsentence(A),`
    `objective((B| A))`
`).`

l:sentence(A, B) :-

`user:`
`(   (   l:noun_p(A, C),`
        `l:verb_p(C, B)`
    `;   l:noun_p(A, D),`
        `l:prep_p(D, E),`
        `l:word(E, B)`
    `;   l:verb(A, F),`
        `l:noun_p(F, G),`
        `l:prep_p(G, H),`
        `l:word(H, B)`
    `)`
`).`

l:sentence(A, B, C) :-

`user:`
`(   l:noun_p(A, B, D),`
    `l:verb_p(A, D, C)`
`).`

pldoc_wiki:sentence([A, B], [], [A, B|C], D) :-

`\+ code_type(A, period),`
`code_type(B, period),`
`E=C,`
`space_or_eos(E, F),`
`!,`
`D=F.`

pldoc_wiki:sentence([32|T0], T, A, B) :-

`space(A, C),`
`!,`
`D=C,`
`ws(D, E),`
`sentence(T0, T, E, B).`

pldoc_wiki:sentence([A|B], C, [A|D], E) :-

`sentence(B, C, D, E).`

pldoc_wiki:sentence([32|T], T, A, B) :-

`eos(A, B).`

sentence :-

`copy_list((idea-:-command)).`

sentence :-

`l:sentence.`

Applications

The goal of the EEG buffer is to supplement SWI-Prolog's Natural Language Processing Primitives by providing rules based inference and input streaming. Future developments will incorporate capabilities from SWI-Prolog's Python Interface and the Expert System developed by Ian Malloy in partial fulfillment for an MSc in cyber warfare.

Clone this wiki locally