ModErn Text Analysis
META Enumerates Textual Applications
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
include
parser
state.h
Go to the documentation of this file.
1
9
#ifndef META_PARSER_STATE_H_
10
#define META_PARSER_STATE_H_
11
12
#include <memory>
13
#include <vector>
14
15
#include "
parser/transition.h
"
16
#include "
parser/trees/node.h
"
17
#include "
parser/trees/parse_tree.h
"
18
#include "
sequence/sequence.h
"
19
#include "
util/persistent_stack.h
"
20
21
namespace
meta
22
{
23
namespace
parser
24
{
25
36
class
state
37
{
38
public
:
42
using
stack_type
=
util::persistent_stack<std::unique_ptr<node>
>;
43
47
using
queue_type
= std::vector<std::unique_ptr<leaf_node>>;
48
53
state
(
const
parse_tree
& tree);
54
59
state
(
const
sequence::sequence
& sentence);
60
65
state
advance
(
const
transition
& trans)
const
;
66
74
bool
legal
(
const
transition
& trans)
const
;
75
81
transition
emergency_transition
()
const
;
82
87
const
node
*
stack_item
(
size_t
depth)
const
;
88
93
const
leaf_node
*
queue_item
(ssize_t depth)
const
;
94
98
size_t
stack_size
()
const
;
99
103
size_t
queue_size
()
const
;
104
108
bool
finalized
()
const
;
109
110
private
:
111
state
(
stack_type
stack, std::shared_ptr<queue_type> queue,
size_t
q_idx,
112
bool
done);
113
117
stack_type
stack_
;
118
122
std::shared_ptr<queue_type>
queue_
;
123
127
size_t
q_idx_
;
128
132
bool
done_
;
133
};
134
}
135
}
136
#endif
meta::parser::state::q_idx_
size_t q_idx_
The index of the front of the queue.
Definition:
state.h:127
meta::parser::node
A single node in a parse tree for a sentence.
Definition:
node.h:24
transition.h
node.h
meta::parser::state::queue_type
std::vector< std::unique_ptr< leaf_node >> queue_type
The underlying queue type.
Definition:
state.h:47
sequence.h
meta::parser::parse_tree
Represents the parse tree for a sentence.
Definition:
parse_tree.h:32
meta::parser::state::stack_item
const node * stack_item(size_t depth) const
Definition:
state.cpp:360
meta::parser::state::queue_size
size_t queue_size() const
Definition:
state.cpp:355
meta::parser::state
Represents the current parser state of a shift-reduce parser.
Definition:
state.h:36
parse_tree.h
meta::sequence::sequence
Represents a tagged sequence of observations.
Definition:
sequence.h:24
meta::parser::state::legal
bool legal(const transition &trans) const
Checks if a transition is legal from a current state.
Definition:
state.cpp:284
meta::parser::state::finalized
bool finalized() const
Definition:
state.cpp:378
meta::parser::state::stack_
stack_type stack_
The stack of partial parse trees.
Definition:
state.h:117
meta::parser::transition
Represents a transition taken by the parser.
Definition:
transition.h:27
meta::parser::state::emergency_transition
transition emergency_transition() const
Returns a transition used in situations where there is not a transition in the model satisfying the c...
Definition:
state.cpp:312
persistent_stack.h
meta::parser::state::done_
bool done_
Whether or not this state has finished parsing.
Definition:
state.h:132
meta::parser::state::advance
state advance(const transition &trans) const
Advances the current state by taking the given transition.
Definition:
state.cpp:55
meta
The ModErn Text Analysis toolkit is a suite of natural language processing, classification, information retreival, data mining, and other applications of text processing.
Definition:
analyzer.h:24
meta::util::persistent_stack
Definition:
persistent_stack.h:21
meta::parser::state::stack_size
size_t stack_size() const
Definition:
state.cpp:350
meta::parser::state::queue_item
const leaf_node * queue_item(ssize_t depth) const
Definition:
state.cpp:371
meta::parser::leaf_node
A leaf node (pre-terminal) in a parse tree.
Definition:
leaf_node.h:24
meta::parser::state::queue_
std::shared_ptr< queue_type > queue_
The queue of preterminals.
Definition:
state.h:122
meta::parser::state::state
state(const parse_tree &tree)
Constructs a state from a parse tree.
Definition:
state.cpp:20
Generated on Tue Mar 3 2015 23:20:16 for ModErn Text Analysis by
1.8.9.1