ZGen  0.2.0
a linearization system for natural language.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Public Attributes | Friends | List of all members
ZGen::ShiftReduce::StateItem Class Reference

#include <state.h>

Public Member Functions

 StateItem ()
 
 StateItem (const dependency_t *ref)
 
void set_reference (const dependency_t *_ref)
 
void clear ()
 
StateItemoperator= (const StateItem &item)
 assign operator More...
 
bool operator< (const StateItem &other) const
 less than operator More...
 
bool operator> (const StateItem &other) const
 greater than operator More...
 
void copy (const StateItem &other)
 
bool shift (postag_t postag, word_t word, int word_id)
 
bool shift (postag_t postag, word_t word, int word_id, StateItem *other) const
 
bool left_arc (deprel_t deprel)
 
bool left_arc (deprel_t deprel, StateItem *other) const
 
bool right_arc (deprel_t deprel)
 
bool right_arc (deprel_t deprel, StateItem *other) const
 

Public Attributes

int top0
 
int top1
 The top word in the stack of the current state. More...
 
const dependency_tref
 The second top word. More...
 
const StateItemprevious
 The reference to the sentence. More...
 
floatval_t score
 The previous state. More...
 
std::vector< int > stack
 The score for the current state. More...
 
std::vector< word_tword_sequence
 The sequence of words leading by the current state. More...
 
std::vector< postag_tpostag_sequence
 The sequence of postags leading by the current state. More...
 
std::bitset< kMaxNumberOfWordsbuffer
 The word indices in buffer for current state. More...
 
int rank [kMaxNumberOfWords]
 The rank of the form, with word considered. More...
 
int postags [kMaxNumberOfWords]
 The postags cache. More...
 
int heads [kMaxNumberOfWords]
 The tree(heads) for the current status. More...
 
int deprels [kMaxNumberOfWords]
 The tree(deprels) for the current state. More...
 
int nr_left_children [kMaxNumberOfWords]
 The number of left children. More...
 
int nr_right_children [kMaxNumberOfWords]
 The number of right children. More...
 
int nr_left_descendant [kMaxNumberOfWords]
 The sum of left descendants. More...
 
int nr_right_descendant [kMaxNumberOfWords]
 The sum of right descendants. More...
 
int left_most_child [kMaxNumberOfWords]
 CACHE: use to store the left most child for the word. More...
 
int right_most_child [kMaxNumberOfWords]
 CACHE: use to store the right most child for the word. More...
 
int left_2nd_most_child [kMaxNumberOfWords]
 CACHE: use to store the 2nd-left-most child. More...
 
int right_2nd_most_child [kMaxNumberOfWords]
 CACHE: use to store the 2nd-right-most child. More...
 
action_t last_action
 The action that result in the current state. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const StateItem &item)
 

Constructor & Destructor Documentation

ZGen::ShiftReduce::StateItem::StateItem ( )
ZGen::ShiftReduce::StateItem::StateItem ( const dependency_t ref)

Member Function Documentation

void ZGen::ShiftReduce::StateItem::clear ( )

Clear the state item.

void ZGen::ShiftReduce::StateItem::copy ( const StateItem other)

Copy other state into the current state.

Parameters
[in]otherThe other state.
bool ZGen::ShiftReduce::StateItem::left_arc ( deprel_t  deprel)

Perform left arc on current state, result in a new state on itself.

Parameters
[in]deprelThe dependency relation.
Returns
bool If successfully performed action, return true; Otherwise false.
bool ZGen::ShiftReduce::StateItem::left_arc ( deprel_t  deprel,
StateItem other 
) const

An output wrapper for left arc by performing left arc and result in a new state.

bool ZGen::ShiftReduce::StateItem::operator< ( const StateItem other) const

less than operator

StateItem & ZGen::ShiftReduce::StateItem::operator= ( const StateItem item)

assign operator

bool ZGen::ShiftReduce::StateItem::operator> ( const StateItem other) const

greater than operator

bool ZGen::ShiftReduce::StateItem::right_arc ( deprel_t  deprel)

Perform right arc on current state, result in a new state on itself.

Parameters
[in]deprelThe dependency relation.
Returns
bool If successfully performed action, return true; Otherwise false.
bool ZGen::ShiftReduce::StateItem::right_arc ( deprel_t  deprel,
StateItem other 
) const

An output wrapper for right arc by performing left arc and result in a new state.

void ZGen::ShiftReduce::StateItem::set_reference ( const dependency_t _ref)

Set the sentence reference to the current StateItem, it won't check whether the reference is seted.

Parameters
[in]_refThe pointer to the sentence
bool ZGen::ShiftReduce::StateItem::shift ( postag_t  postag,
word_t  word,
int  word_id 
)

Perform shift on current state, result in a new state on itself.

Parameters
[in]postagThe PoSTag (represented in integer).
[in]wordThe word (represented in integer).
[in]word_idThe index of the word in this sentence.
Returns
bool If successfully shift, return true. otherwise false.
bool ZGen::ShiftReduce::StateItem::shift ( postag_t  postag,
word_t  word,
int  word_id,
StateItem other 
) const

Perform shift on current state and result in a new state.

Parameters
[in]postagThe PoSTag (represented in integer).
[in]wordThe word (represented in integer).
[in]word_idThe index of the word in this sentence.
[out]otherThe pointer to the output state.
Returns
bool If successfully shift, return true, otherwise false

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const StateItem item 
)
friend

Member Data Documentation

std::bitset<kMaxNumberOfWords> ZGen::ShiftReduce::StateItem::buffer

The word indices in buffer for current state.

int ZGen::ShiftReduce::StateItem::deprels[kMaxNumberOfWords]

The tree(deprels) for the current state.

int ZGen::ShiftReduce::StateItem::heads[kMaxNumberOfWords]

The tree(heads) for the current status.

action_t ZGen::ShiftReduce::StateItem::last_action

The action that result in the current state.

int ZGen::ShiftReduce::StateItem::left_2nd_most_child[kMaxNumberOfWords]

CACHE: use to store the 2nd-left-most child.

int ZGen::ShiftReduce::StateItem::left_most_child[kMaxNumberOfWords]

CACHE: use to store the left most child for the word.

int ZGen::ShiftReduce::StateItem::nr_left_children[kMaxNumberOfWords]

The number of left children.

int ZGen::ShiftReduce::StateItem::nr_left_descendant[kMaxNumberOfWords]

The sum of left descendants.

int ZGen::ShiftReduce::StateItem::nr_right_children[kMaxNumberOfWords]

The number of right children.

int ZGen::ShiftReduce::StateItem::nr_right_descendant[kMaxNumberOfWords]

The sum of right descendants.

std::vector< postag_t > ZGen::ShiftReduce::StateItem::postag_sequence

The sequence of postags leading by the current state.

int ZGen::ShiftReduce::StateItem::postags[kMaxNumberOfWords]

The postags cache.

const StateItem* ZGen::ShiftReduce::StateItem::previous

The reference to the sentence.

int ZGen::ShiftReduce::StateItem::rank[kMaxNumberOfWords]

The rank of the form, with word considered.

const dependency_t* ZGen::ShiftReduce::StateItem::ref

The second top word.

int ZGen::ShiftReduce::StateItem::right_2nd_most_child[kMaxNumberOfWords]

CACHE: use to store the 2nd-right-most child.

int ZGen::ShiftReduce::StateItem::right_most_child[kMaxNumberOfWords]

CACHE: use to store the right most child for the word.

floatval_t ZGen::ShiftReduce::StateItem::score

The previous state.

std::vector<int> ZGen::ShiftReduce::StateItem::stack

The score for the current state.

The stack for the current state

int ZGen::ShiftReduce::StateItem::top0
int ZGen::ShiftReduce::StateItem::top1

The top word in the stack of the current state.

std::vector< word_t > ZGen::ShiftReduce::StateItem::word_sequence

The sequence of words leading by the current state.


The documentation for this class was generated from the following files: