Click here for more information

SAMPLE program examples: NL understanding, parsing




Please go to http://sampletalk.8m.com , which is updated version of this homepage. Information below is out-of-date and remains here only for keeping old links.





Build a program immediately from data processing examples




SAMPLE Language & Technology: http://sampletalk.8m.com/.

Build a program immediately from data processing examples. Program Examples


Natural language question understanding


Imagine that you have plenty of facts like jack eats apples in the corridor, represented in a natural language, and would like to develop a question-answering system that allows a user to derive consequences of these facts and to cause other actions related to such reasoning. (E.g. to qualify eating as a consumption). SAMPLE provides the simplest possible way for doing this. You will never need to make a separate parser, grammar, semantic models, and reasoning modules. Everything is obtained via a universal concept of matching text samples, where the samples may contain variables X (standing for Jack or somebody else, as in our example), A (standing for eat or some other action), F (standing for food or some other object) etc. All other existing knowledge-processing systems require much more complex programming in order to implement reasoning of this kind:






% Goal:

what does jack eat?..

% Knowledge base (inference rule with semantic patterns):

what does X A? F :- X As F in P,, consumption: Aing,, food: F,, place: P..

% Semantic knowledge:

consumption: drinking..

consumption: eating..

food: apples..

food: bananas..

beverage: coca cola..

place: corridor..

place: room..

% Known facts:

jack eats apples in the corridor..

mary drinks coca cola in the room..



The output (or, better, response) of this program will be what does jack eat? apples. On the way to derive this response, the program will print intermediate results like consumption: eating, food: apples, place: the corridor.


 


Abstraction of Natural Language reasoning


This program example demonstrates how we can obtain inference rules immediately from NL reasoning examples. Consider 3 obvious reasoning examples:


What is on roof? Bird (if object bird is situated on roof);

Who is Socrates? Human (since person Socrates is Human);

Where is Paris? In France (since object Paris is situated in France).

We simply replace specific object names with unique variable names having the form {something} and obtain the rules (see below), which are much more general. They provide reasoning like


What is on a table? Book (since object book is situated on a table);

Who is Julia? Daughter of Maria and Peter (since person Julia is a daughter of Maria and Peter);

Where is St. Petersburg? In Russia (since object St. Petersburg is situated in Russia)

and more, given program goals like the goals below. The program is as simple as this:






who is julia? {Function}.. % Possible program goals

where is new york? in {Place}..

person {Sombody} is son of maria and {His_father}..

person jack N is {Relative} of {Somebody}..

person {Son} 2 is son of Y and X 1..

what is on a table? X..

what is on {Roof}? {Bird}:-object {Bird} is situated on {Roof}..
% Reasoning rules

who is {Socrates}? {Human}:-person {Socrates} is {Human}..

where is {Paris}? in {France}:-object {Paris} is situated in {France}..

person joe is a son of maria and peter..
% Factual knowledge

person julia is a daughter of maria and peter..

person peter 2 is a son of maria and peter 1..

person jack 2 is a son of julia and jack 1..

object new york is situated in america..

object st.petersburg is situated in russia..

object book is situated on a table..



 


Morphologic and syntax analysis of a sentence


Given the sentence this large apple is tasty since it has ripened in the form of a program goal (see below), the program produces output tree for sentence [this large apple is tasty since it has ripened] is n-sent[n-sent[n-noun[det[this] aj[large] noun[apple]] verb0[is] aj[tasty]] cond[since] n-sent[it[it] verb1[has] verb[ripened]]]. This output represents parsing tree structure along with morphological tags.






%Goal (variable X is to be filled by the parsing tree; "[" and "]" restrict possible matching):

tree for sentence [this large apple is tasty since it has ripened] is X..

% Main rule:

tree for sentence [X] is T:- morphology for list [X] is Y,, tree for list[. Y .] is T..

% Morph. tagging:

morphology for list[A X] is B[A] Y:- A has tag B,, morphology for list [X] is Y..

morphology for list [A X] is B[A] Y[X]:- A has tag B,, X has tag Y..

% Building tree:

tree for list [A X B] is W:- n-S[X],, tree for list [A n-S[X] B] is W..

tree for list [. X .] is n-sent[X]:- n-sent[X]..

% Grammar patterns:

n-noun[this[_] aj[_] n-noun[_]]..
% "_" matches anything

n-noun[this[_] n-noun[_]]..

n-noun[aj[_] n-noun[_]]..

n-sent[noun[_] verb[_]]..

n-sent[noun[_] verb0[_] aj[_]]..

n-sent[it[_] verb1[_] verb[_]]..

n-sent[n-sent[_] since[_] n-sent[_]]..

% Morphologic dictionary:

this has tag det..

large has tag aj..

apple has tag noun..

is has tag verb0..

tasty has tag aj..

since has tag cond..

it has tag it..

has has tag verb1..

ripened has tag verb..



Have you noticed already that we are programming in a natural language?!


 


Parts Inventory


This is Sample version of classic Prolog program by Clocksin & Mellish. Using a description of a bike, this program produces list of all its basic parts. The main difference is its natural language form: we don't have to use specific Prolog syntax and can be as expressive in our NL expressions as we want. I even used English check speller for debugging this program!






% Goal (L stands for the generated list of basic parts of a bike)

parts of [bike] are L..

% Knowledge base

bike contains [wheel] [wheel] [frame]..

wheel contains [spoke] [rim] [hub]..

frame contains [rear frame] [front frame]..

front frame contains [fork] [handles]..

hub contains [gears] [axle]..

axle contains [bolt] [nut]..

basic part (rim).. basic part (rear frame).. basic part (gears).. basic part (nut).. basic part (spoke).. basic part (handles).. basic part (bolt).. basic part (fork)..

% Inference rules

parts of [X] are X :- basic part (X)..

parts of [X] are P :- X contains S ,, parts of list [S] are P..

parts of list [P T] are H G :- parts of P are H ,, parts of list [T] are G..

parts of list [[T]] are G :- parts of [T] are G..



As the result, this program will print parts of [bike] are [spoke] [rim] [gears] [bolt] [nut] [spoke] [rim] [gears] [bolt] [nut] [rear frame] [fork] [handles].


Programs like these will never need a detailed documentation: since text matching is the main programming concept, the reader of a program will always find explanation of program elements in similar elements. As important, universal concepts like contains, is, parts of, as well as any kind of jargon language designations, may be easily included into SAMPLE program, along with constraints and explanations how the corresponding objects behave.


SAMPLE Language & Technology: http://www.webspawner.com/users/samplex/




Back to Sample Language & Technology
Other examples: Logics; Recognition of regularities
Other examples: misc. SAMPLE programs
Metaphoric Conclusions

Send E-Mail to: gleibman@yahoo.com

Free Webpages This page created using the webpage creation facilities of Webspawner.
Copyright © 2001 Andrew Gleibman. All Rights Reserved