Advertisement
roneygomes

Earley Parser

Jan 15th, 2015
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. final_state <- final_state()
  2. root <- #
  3.  
  4. for parent in final_state.parents do:
  5. parse(root, root, parent)
  6.  
  7.  
  8. parse(root, node, state)
  9. if state = initial_state() then:
  10. return root
  11.  
  12. if state.is_finished() then:
  13. node.add_child(state.lhs)
  14.  
  15. # Todo estado que é part-of-speech está finalizado portanto um filho foi
  16. # certamente adicionado no passo anterior.
  17.  
  18. if is_part_of_speech(state.lhs) then:
  19. child <- node.get_child(0)
  20. child.add_child(state.rhs.first)
  21.  
  22. if dot_is_first(state) then:
  23. node <- node.parent
  24. else if not is_part_of_speech(state.lhs) and state.is_finished() then:
  25. node <- node.get_child(0)
  26.  
  27. for parent in state.parents do:
  28. if parent.lhs = state.prior_to_dot() or
  29. parent.rhs and parent.lhs = some_evaluated_state() then:
  30. parse(root, node, parent)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement