Implementing Patr - PowerPoint PPT Presentation

About This Presentation
Title:

Implementing Patr

Description:

Left Corner Recogniser ... FS0 is a category that would appear at the bottom left of a parse tree for it. ... reached, then FS1 is a left corner of FS2 if they ... – PowerPoint PPT presentation

Number of Views:41
Avg rating:3.0/5.0
Slides: 17
Provided by: michael307
Category:

less

Transcript and Presenter's Notes

Title: Implementing Patr


1
Implementing Patr
2
Bibliographic Note
Material in this presentation is based on Natural
Language Processing in Prolog G. Gazdar and C.
Mellish, Addison-Wesley 1989.
3
Some Differences between Patr and Prolog
  • Prolog requires explicit variables
  • Syntactic appearance of paths
  • Grammar Rules
  • Lexical Entries
  • Templates

4
Rule Format
  • R ule
  • S ---gt NP, VP -Scat s,NPcat
    np,VPcat vp,Shead VPhead,NP
    VPsubcatfirst.

5
Operator Definitions
  • op(500,xfy,).op(500,xfx,---gt).op(600,xfx,
    ).
  • op(400,xfx,ule).op(500,xfx,ord).

6
Definition of
  • XY if and only if X and Y denote unifiable
    items.
  • We achieve this by saying that there is a third
    item that they both denote, i.e.
  • X Y -
  • denotes(X,Z),
  • denotes(Y,Z).

7
Definition of denote(X,Y).
  • We must take account of the fact that X can be
    one of three things variable, atom, or path
  • denotes(Var,Var) - var(Var), !.
  • denotes(Atom,Atom) -
  • atomic(Atom), !.
  • denotes(VPath, Value) - pathval(V,Path,Value).

8
Modifying pathval
  • Notice that the second argument to pathval need
    not be atomic. However, our existing definition
    for pathval assumes that it is.
  • We therefore add a clause that applies pathval
    applies to the first element of the path to
    obtain a second value, and then applies the rest
    of the path the new value.

9
New Definition of pathval
  • pathval(AttrVal1 X, Attr, Val2, X)-
  • !,unify(Val1, Val2).
  • pathval(AV X, Attr, Val, AV Rem ) -
  • pathval(X, Attr, Val, Rem).
  • pathval(V1, AttrPath, Value, Rem) - !,
    pathval(V1,Attr,V2,Rem), pathval(V2,Path,Value,
    _).

10
Lexical Entries
  • W ord uther -
  • Wcat n,
  • Wheadtrans uther.
  • Uppercase can cause problems.
  • Use quote (e.g. Uther) if necessary.

11
Connecting Words to Lexical Entries
  • Represent strings as difference lists.
  • Define a predicate that associates words in
    string with lexical entry.
  • leaf(W, WordRest, Rest) - W ord Word.
  • leaf(C,X,X) - R ule C ---gt .

12
In Other (DCG) Words .
  • leaf(FS)--gt
  • Word, FS ord Word.
  • leaf(FS) -gt
  • _ ule Dag ---

13
Left Corner Recogniser
  • To recognise a string as an instance of FS1, we
    need to consider an initial leaf FS0 and prove
    that FS0 is a left corner of FS1, i.e. that FS0
    is a category that would appear at the bottom
    left of a parse tree for it.
  • rec(FS1) --gt
  • leaf(FS0), lc(FS0,FS1.

14
Definition of left cornerlc(FS1,FS2)
  • If the end of the string has been reached, then
    FS1 is a left corner of FS2 if they unify.
  • Otherwise there is a rule
  • FS0 ---gt FS1Rest such that
  • The rest of the string is recognised as Rest
  • FS0 is a left corner of FS1

15
Code for lc
  • lc(FS1,FS2) --gt , unify(FS1,FS2).
  • lc(FS1,FS2) --gt
  • R ule FS0 ---gt FS1 Rest ,
  • recognise_rest(Rest),
  • lc(FS0,FS2).

16
recognise_rest
  • recognise_rest( ) --gt .
  • recognise_rest(FS FSs) -
  • recognise(FS),
  • recognise_rest(FSs).
Write a Comment
User Comments (0)
About PowerShow.com