watdahel
Golden Member
struct Derivation {
public:
vector< string > parse_tree;
vector< string > tree_list;
};
queue< Derivation > fringe;
This is a parsing project I'm working on. Basically, given a sentence, find a parse tree using a bottom-up algorithm. Initially, a sentence is tokenized and put into the tree_list member of a Derivation object. This object is then put into the fringe. Another function pops the objects from the fringe and expands that "node," if possible, according to grammar, by creating new Derivation objects each containing possible derivation of the previous string and these new objects are placed in the fringe for further expansion later on.
My problem is with sentences with four or more words in it. It runs indefinitely until the program crashes. I have 512MB of memory and I monitored the consumption and the program quickly eats it all up and starts using the harddisk. A few moments later the program crashes. I'm pretty sure it's related to this memory problem.
Now, the fringe grows to contain nearly 100,000 Derivation objects when the program crashes. Do vectors occupy that much memory? Would using a string array use less memory? What can I do? Perhaps this is a losing battle for my current 512 MB memory?
public:
vector< string > parse_tree;
vector< string > tree_list;
};
queue< Derivation > fringe;
This is a parsing project I'm working on. Basically, given a sentence, find a parse tree using a bottom-up algorithm. Initially, a sentence is tokenized and put into the tree_list member of a Derivation object. This object is then put into the fringe. Another function pops the objects from the fringe and expands that "node," if possible, according to grammar, by creating new Derivation objects each containing possible derivation of the previous string and these new objects are placed in the fringe for further expansion later on.
My problem is with sentences with four or more words in it. It runs indefinitely until the program crashes. I have 512MB of memory and I monitored the consumption and the program quickly eats it all up and starts using the harddisk. A few moments later the program crashes. I'm pretty sure it's related to this memory problem.
Now, the fringe grows to contain nearly 100,000 Derivation objects when the program crashes. Do vectors occupy that much memory? Would using a string array use less memory? What can I do? Perhaps this is a losing battle for my current 512 MB memory?