transition_state.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #ifndef NLP_SAFT_OPENSOURCE_DRAGNN_CORE_INTERFACES_TRANSITION_STATE_H_
  2. #define NLP_SAFT_OPENSOURCE_DRAGNN_CORE_INTERFACES_TRANSITION_STATE_H_
  3. #include <memory>
  4. #include <vector>
  5. #include "syntaxnet/base.h"
  6. namespace syntaxnet {
  7. namespace dragnn {
  8. // TransitionState defines the minimal interface required to pass data between
  9. // Component objects. It is used to initialize one Component from the output of
  10. // another, and every backend should define one. Note that inheriting from
  11. // TransitionState directly is not sufficient to use the Beam class, which
  12. // requires extra functionality given by inheriting from the
  13. // ClonableTransitionState interface. (ClonableTransitionState is a subclass
  14. // of TransitionState, so inheriting from ClonableTransitionState is sufficient
  15. // to allow Components to pass your backing states.)
  16. class TransitionState {
  17. public:
  18. virtual ~TransitionState() {}
  19. // Initialize this TransitionState from a previous TransitionState. The
  20. // ParentBeamIndex is the location of that previous TransitionState in the
  21. // provided beam.
  22. virtual void Init(const TransitionState &parent) = 0;
  23. // Return the beam index of the state passed into the initializer of this
  24. // TransitionState.
  25. virtual const int ParentBeamIndex() const = 0;
  26. // Get the current beam index for this state.
  27. virtual const int GetBeamIndex() const = 0;
  28. // Set the current beam index for this state.
  29. virtual void SetBeamIndex(const int index) = 0;
  30. // Get the score associated with this transition state.
  31. virtual const float GetScore() const = 0;
  32. // Set the score associated with this transition state.
  33. virtual void SetScore(const float score) = 0;
  34. // Depicts this state as an HTML-language string.
  35. virtual string HTMLRepresentation() const = 0;
  36. };
  37. } // namespace dragnn
  38. } // namespace syntaxnet
  39. #endif // NLP_SAFT_OPENSOURCE_DRAGNN_CORE_INTERFACES_TRANSITION_STATE_H_