Books
in black and white
Main menu
Home About us Share a book
Books
Biology Business Chemistry Computers Culture Economics Fiction Games Guide History Management Mathematical Medicine Mental Fitnes Physics Psychology Scince Sport Technics
Ads

Communicating with Databases in Natural Language - Wallace M.

Wallace M. Communicating with Databases in Natural Language - Ellis Horwood Limited, 1985. - 170 p.
Download (direct link): comumunicatingwthisdatabase1985.djvu
Previous << 1 .. 22 23 24 25 26 27 < 28 > 29 30 31 32 33 34 .. 59 >> Next

convdesc(Const,Const, [ ],true) atomic (Const),!
The ‘convqual’ clause which converts compound DESCRIPTIONS is:
line 1: convqual(Desc is qual(V,Qual), Results, Rules) : —
line 2: convqual(Qual,Resultl,Rulel),
•f Most PROLOG implementations have the unfortunate habit of displaying ‘A B’ as [A I B]
line .3: convdesc(Desc,W,Result2,Rule2),
line 4: substitute(V,W,Rule.3),
union( Resultl, Result2, Results), conjunct( [Rulel,Rule2,Rule3], Rules).
The meat of this clause is at line 4, when the converted DESCRIPTION, W, is matched with the Curried variable, V. The predicate ‘substitute’ has two clauses:
/* If the converted DESCRIPTION or the Curried variable is still unbound, unify them, and return the trivial rule */
substitute(V, V,true)
/* But if they will not be unified, then return theii equality as a rule */
substitute (V, W, V=W)
Let us follow through the conversion of,
‘19.02.83’ is qual(V3, order ( id=V2,orderdate=V3))
Tracing ‘convdesc’ and ‘substitute’ as well, but no longer tracing ‘convieP:
line 1: Enter convqual( ‘19.02.83’ is qual(V.3,
order(id=V2, ordeidate=V.3
Results,
Rules)
line 2: Enter convqual(order( id=V2, oiderdate=V3),
Resultl,
Rulel)
line 2: Exit convqual(order(id=ordei id,
oideidate=ordei orderdate),
[],
true)
line 3: Enter convdesc(‘19.02.83’, W, Result2, Rule2)
line 3: Exit convdesc(‘19.02.8.3’, ‘19.02.8.3’, [], true)
line 4: Enter substitute (order orderdate, ‘19.02,8.3’, Rule.3)
line 4: Exit substitute( order,orderdate,
‘19,02,8,3’,
order „or dei date=‘ 19 „02,8 3 ’) line 1: Exit convqual( ‘19.02.83’ is qual(order orderdate,
ordei(id=order.id,
orderdate=order, orderdate)),
[],
order.ordeidate = ‘19.02,8.3’)
The first clause for ‘substitute’, line 4, fails because V already has value ‘order orderdate’ and cannot be unified with W which has value ‘19.02,8,3’,, Thus the second clause for substitute succeeds instead.
78 D&Qs
[Ch.
The last two lines of ‘convqual’ combine the results and the rules ‘conjunct’ drops superfluous occurrences of ‘true’ from the rule, and ‘union’ drops duplicated entries from the result specification.
3,2.4
The ‘convqual’ clause for compound QUALIFIERS also provides for the simplification described in section .3.1.4 above The only extra clause needed is the one for compound DESCRIPTIONS:
/* The conversion of a compound DESCRIPTION returns its Curried variable. The result and the rule are inherited from the conversion of its QUALIFIER */
line 7: convdesc(any-M-qual(V, Qual), V, Results, Rule) : —
line 8: convqual(Qual, Results, Rule).
We can now follow through the example of section .3.1.4
any-M-qual(V2, ‘19,02.83’ isqual(V3,order(id=V2,orderdate=V3)))is qual(Y2, place(custcode=Yl, ordercode=Y2) )
{ The relevant clause for ‘convqual’ is:
line 1: convqual(Desc is qual(V,Qual), Results, Rules) : —
line 2: convqual(Qual,Result 1,Rule 1),
line .3: convdesc(Desc,W,Result2,Rule2),
line 4: substitute(V,W,Rule,3),
line 5: union(Resultl,Result2,Results),
line 6: conjunct([Rulel,Rule2,Rule.3],Rule) }
(Tracing ‘convqual’, ‘convdesc’, and ‘substitute’)
line 1: Enter convqual( any-M-qual(V2,
‘19.02.8.3’ is qual(V3,
order(id=V2, orderdate=V3))) is qual(Y2, place(custcode=V 1, ordercode=V2)), Results,
Rules)
line 2: Enter convqual(place(custcode=Vl, ordercode=Y2),
Results,
Rulel)
line 2: Exit convqual( place(custcode=place.,custcode,
or dercode=place order code),
[].
true)
D&Qs 79
line .3: Enter convdesc( any-M-qual(V2,
( & 7) ‘19.02.83’ is qual(V3,
order (id=V2,orderdate=V.3))),
W,
Result2,
Rule 2)
line 8: Enter convqual( ‘19 02,8.3’ is qual(V3,
ordei( id=V2, orderdate=V,3)),
Result2,
Rule 2)
Enter convqual( order( id=V2, orderdate=V,3), XI, X2 )
Exit convqual( oider(id=order ,,id,orderdate=
order order date), [ ], true )
Enter convdesc(‘19.02,83’, X3, X4, X5)
Exit convdesc(‘19.02 83’, ‘19,02.8.3’, [],tiue)
Enter substitute(order orderdate, ‘19 02 8.3’, X6)
Exit substitute (order orderdate,
‘19.02,83’,
order ,,orderdate=‘19 02.8,3’) line 8: Exit convqual( ‘19.02,83’ is qual(order,orderdate,
oider(id= order,id,
order date=or der „ or dei date)),
[],
order.orderdate=‘19 02.83’) line 3: Exit convdesc( any-M-qual(order,id,
( & 7) ‘ 19.02.83’ is qual (or der, or der date,
order (id=order. id,
or der date=or der. orderdate))),
[].
oidei.orderdate=‘19.02.8.3’) line 4: Enter substitute(place.ordercode, order.id, Rule.3)
line 4: Exit substitute(place.ordercode,
order.id,
place „or der code= order, id) line 1: Exit convqual( any-M-qual(order,id,
‘19,02,83’ is qual(order orderdate, order(id=order,id,
or der date= or der .or derdate))) is qual(place„ordercode,
place( custcode=place customer, or dercode=place. order code)),
[],
order„orderdate=‘19,02,83’
& place.ordercode=order,id )
80 D&Qs
[Ch
Thus the final unifications are:
V2 = order,id
V.3 = order.orderdate
Y2 s place, order code
Y1 = place custcode
Results = []
Rules = order,orderdate = ‘19,02 83’ & place ordercode = order,id
Previous << 1 .. 22 23 24 25 26 27 < 28 > 29 30 31 32 33 34 .. 59 >> Next