Presentation is loading. Please wait.

Presentation is loading. Please wait.

Unification algorithm We have seen examples of the use of unification. Now we will see, in detail, one way to implement a unification algorithm which implements.

Similar presentations


Presentation on theme: "Unification algorithm We have seen examples of the use of unification. Now we will see, in detail, one way to implement a unification algorithm which implements."— Presentation transcript:

1 Unification algorithm We have seen examples of the use of unification. Now we will see, in detail, one way to implement a unification algorithm which implements structure sharing

2 A data structure to support unification We need a special data structure to allow structure sharing during unification: – each feature structure is represented using two components, a content component and a pointer component. – the representation forms a Directed Acyclic Graph (DAG)

3 Example 1 The DAG representation for a simple feature structure: [Number SG, Person 3] Expand first to: [Content[Number[Content SG, Pointer NULL], Person[Content 3, Pointer NULL]], Pointer NULL] CONTENT POINTER NUMBER PERSON CONTENT POINTER CONTENT POINTER SG NULL 3

4 Example 2 The DAG representation for a simple feature structure: [Number SG] CONTENT POINTER NUMBER CONTENT POINTER SG NULL

5 Example 3 The DAG representation for a simple feature structure: [Person 3] CONTENT POINTER PERSON CONTENT POINTER 3 NULL

6 Algorithm (pg. 423 of text) function Unify(f1, f2) returns fs or failure f1.real  real contents of f1, *(f1.ptr) if ptr != null f2.real  real contents of f2, *(f2.ptr) if ptr != null if (f1.real is null) { f1.ptr  f2; return f2 } else if (f2.real is null) { f2.ptr  f1; return f1 } else if (f1.real == f2.real) {f1.ptr  f2; return f2 } else if (f1.real is complex and f2.real is complex) { f2.ptr  f1 foreach ftr2 in f2.real { ftr1  find/create feature ftr2 in f1.real if Unify(ftr2.value,ftr1.value) fails {return failure} return f1 else return failure

7 Example 4, initial state [Number SG]  [Person 3] CONTENT POINTER NUMBER CONTENT POINTER SG NULL CONTENT POINTER PERSON NULL CONTENT POINTER 3 NULL f2: f1:

8 Example 4, part 2 [Number SG]  [Person 3] (note sharing!) CONTENT POINTER NUMBER CONTENT POINTER SG NULL CONTENT POINTER PERSON CONTENT POINTER 3 NULL

9 Example 4, part 3 [Number SG]  [Person 3] (note sharing!) CONTENT POINTER NUMBER CONTENT POINTER SG NULL CONTENT PERSON CONTENT POINTER 3 NULL PERSON CONTENT POINTER NULL POINTER

10 Another example? We can work through example on page 424 of text if you’d like.


Download ppt "Unification algorithm We have seen examples of the use of unification. Now we will see, in detail, one way to implement a unification algorithm which implements."

Similar presentations


Ads by Google