13 template<
typename Grammar_t>
19 size_t max_partial_enum = 1000;
20 size_t min_ref_size = 4;
34 std::set<Node> unique;
37 auto nx = st.
count(n);
38 if(nx > max_partial_enum)
continue;
39 for(
size_t i=0;i<nx;i++) {
40 auto x = st.
toNode(i,root);
42 if(x.nt() == nt and (not unique.contains(x)) and x.count_nonnull() > min_ref_size and (not x.is_null())) {
53 std::set<Node> unique;
56 auto nx = st.
count(n);
57 if(nx > max_partial_enum)
continue;
58 for(
size_t i=0;i<nx;i++) {
59 auto x = st.
toNode(i,root);
61 if(x.nt() == nt and (not unique.contains(x)) and x.count_nonnull() > min_ref_size and (not x.is_null())) {
74 assert(
false &&
"*** You asked for a referent that was impossible!");
91 return this->grammar->makeNode(this->grammar->get_rule(nt, is.
get_value()));
97 if(possible_referents > 0 and is.
pop(2)==0) {
110 assert(n.is_complete());
116 auto ri = is.
pop(this->grammar->count_nonterminals(nt));
117 Rule* r = this->grammar->get_rule(nt, ri+numterm);
118 Node out = this->grammar->makeNode(r);
120 for(
auto v : is.
split(r->
N)) {
142 return toNode(is, nt, root);
value_t pop()
Definition: IntegerizedStack.h:82
enumerationidx_t count(const Node &n)
How many partial subtrees are there?
Definition: SubtreeEnumeration.h:24
Definition: SubtreeEnumeration.h:13
#define TAB
Definition: IO.h:19
Enumerate subtrees of a given tree.
nonterminal_t type(size_t i) const
Definition: Rule.h:152
Definition: PartialLZEnumeration.h:14
value_t get_value() const
Definition: IntegerizedStack.h:124
std::vector< value_t > split(size_t n)
Split into n children – this is the same as looping and popping, but provides a nicer interface NOTE...
Definition: IntegerizedStack.h:114
virtual size_t count_terminals() const
Definition: BaseNode.h:388
virtual bool is_complete() const
Definition: Node.h:188
size_t N
Definition: Rule.h:29
bool is_null() const
Definition: Node.h:165
size_t compute_possible_referents(const Node &root, const nonterminal_t nt)
Compute the number of things in n which could be referenced Here, we will require references to prior...
Definition: PartialLZEnumeration.h:32
virtual Node toNode(IntegerizedStack &is, const nonterminal_t nt, Node &root)
Convert to a node, using root as the root – NOTE that when root is null, we use out as the root...
Definition: PartialLZEnumeration.h:83
void assign(Node &n)
Assign will set everything to n BUT it will not copy the parent pointer etc since we're assuming this...
Definition: Node.h:59
#define CERR
Definition: IO.h:23
unsigned short nonterminal_t
Definition: Nonterminal.h:4
void set_child(const size_t i, Node &n)
Definition: Node.h:88
#define ENDL
Definition: IO.h:21
virtual enumerationidx_t toInteger(const Node &root, const Node &n)
Definition: PartialLZEnumeration.h:156
virtual Node toNode(IntegerizedStack &is, const Node &frm)
Convert to the is'th partial subtree of frm.
Definition: SubtreeEnumeration.h:46
size_t enumerationidx_t
Definition: IntegerizedStack.h:3
Definition: IntegerizedStack.h:12
PartialLZEnumeration(Grammar_t *g)
Definition: PartialLZEnumeration.h:23
virtual Node toNode(enumerationidx_t z, const nonterminal_t nt)
Definition: PartialLZEnumeration.h:146
virtual Node toNode(enumerationidx_t z, const nonterminal_t nt, Node &root)
Definition: PartialLZEnumeration.h:140
Node get_referent(const Node &root, size_t cnt, const nonterminal_t nt)
Definition: PartialLZEnumeration.h:52