Paring Technologie Outline Paring Technologie Outline Bottom Up paring Paring Technologie Paring Technologie Bottom-up paring Step in a hift-reduce pare top-down: try to grow a tree down from a category x to tring w 1...w n. Lead naturally to the tack-baed algorithm jut dicued bottom-up: try to build tree up from a tring w 1...w n to a category x. Thi alo lead naturally to a tack-baed algorithm: the o-called hift-reduce algorithm 1. In each picture the dotted line encloe a foret a collection of ubtree of the eventual tree. The box part how the tree-top of the foret it tart at the bottom left and in the firt tep add height in accordance with a rule of the grammar. conventionally called a reduction
Paring Technologie Paring Technologie Step in a hift-reduce pare Step in a hift-reduce pare 3. 3. 4. beide trying to add height to the tree in the foret, the parer alo ometime add the next lexical item to the foret conventionally called a hift another reduction added height to a tree in the foret: note thi create a new final tree in the foret Paring Technologie Paring Technologie Step in a hift-reduce pare Step in a hift-reduce pare 4. 6. another reduction again added height to a tree in the foret: note again thi create a new final tree in the foret final reduction height added above the two tree in the foret. Again thi create a new final tree in the foret
Paring Technologie Paring Technologie 1. 4. 6. 3. In picture 2, 4 and 5, growth i purely vertical, firt above the word, then above. In picture 6, the two vertical tree contructed o far are joined together. In all of 2,4,5,6, the tep of adding ome height to the collection of tree by uing a grammar rule i called a reduction: it not the height which i reduced, but (ometime) the number of tree in the foret. clearly poible to have different evolution of the foret 1. 4. 6. 3. intead of building up at once from, firt i added to the foret, and then i added above it. then ome height i added above, with the node, before ome more height i added above with the node then you get the final tep merging the and tree Paring Technologie Paring Technologie Picking a particular foret-growth regime firt (red where height i built): top node econd: top node the firt alway build height on the lat n tree in the foret : a uffix of the foret the econd doe not: build height on when it not the lat tree in the foret The key fact i thi: if the foret can be evolved at all to a ucceful concluion then it can be evolved by building on uffixe only Tree top a a tack Once you chooe uffixe-only regime for evolving the foret, the box repreenting the tree-top behave like a tack. recall for top-down paring, a particular growth regime alo gave a tack: the equence of node available for left-expanion/leaf-cancellation behaved like a tack at it left end. For bottom-up paring, the equence of node availabe for uffix-only reduction/hifting behave like a tack at it right end (once again) thi lead to the idea that one can manage the earch for a pare tree by managing a earch through a pace of tack tate can now ge outline of bottom-up algorithm let w be an array repreenting the iut i be the index of the current word ue T for the top of the tree in the foret
Bottom-up algorithm (without backtracking) et T to empty, progre indicator i = 0 MOVES: loop thru the rule { //REDUCTION if (rule i A D 1... D n and T top-mot element are D n... D 1 ){ nb. order pop D n... D 1 from T, puh A on T goto MOVES if(could not reduce tack T and i < ize of iut) {//SHIFT puh w[i] on T et i = i + 1 goto MOVES YES_NO: if ((T i jut initial ymbol) && (i == ize of iut)) { ucceed ele { fail Paring Technologie there may be more than one way to reduce the tack the preceding algorithm jut determinitically pick firt poible yntax rule the correct pare might require a hift even though a reduce i poible the preceding algorithm jut determinitically opt to reduce if it i at all poible thee are hort-cut which have to be addreed either add backtracking to reviit all choice or try to control choice by looking ahead in the iut firt look at a few example auming thi determinitic algorithm Paring Technologie Paring Technologie An example The pre-ordering perpecte on top down paring uppoe grammar --> a,,b --> a,b initial() SUCCEED For thi grammar, the hort-cut work iut i: a a b b howing top of tack at the right STACK WORDS type of move a a b b a a b b hift a a b b hift a a b b hift a b reduce, uing a, b a b hift reduce, uing a,, b adv,, adv maybe The entence ha the pare tree 1: 2: 3: 4: 5: 6: the numbering order the node o that mother precede all dtr (and decendant) node in a dtr tree come before node in dtr to the right thi ordering reflect the action of the top-down parer
Paring Technologie The pot-ordering perpecte on bottom up paring The entence ha the pare tree 6: 2: 5: adv,, adv maybe 1: 4: 3: the numbering thi time order the node o that a mother node follow dtr node (and decendant) once again node in a dtr tree come before node in dtr to the right the action of the tandard hift-reduce bottom-up parer correpond to thi pot-order traveral of the tree