Input: a sequence of words in a sentenceOutput: a list of governors and dependency relations |
stack, buffer ← make_stack(), make_buffer(eojeols)action ← make_list()buffer ← reverse(buffer) |
pred_head ← make_list(size=len(eojeols) + 1)pred_rel ← make_list(size=len(eojeols) + 1) |
for i in range(len(eojeols) * 2) |
if is_empty(buffer) then |
end algorithm |
next_action, relation ← oracle(stack, buffer, action) |
if next_action = 'RIGHT-ARC' then |
action.push(next_action) |
else if next_action = 'REDUCE' then |
action.push(next_action) |
pred_head[buffer.top()] ← stack.top() |
pred_rel[buffer.top()] ← relation |
stack.push(buffer.pop()) |
else |
raise parse_error |
end forreturn pred_head, pred_rel |