| |
Search SRILM-USER Archives
Re: Modifying ngram.cc
From: Andreas Stolcke <stolcke at ADDRESS HIDDEN>
Date: Fri, 08 Jul 2005 15:33:07 PDT
In message <BEF415D2.332F%lambert at ADDRESS HIDDEN>you wrote:
> Hi,
>
> This is kind of a C++ question
> I wrote the following copy constructor in Ngram.h
> Ngram(const Ngram
> &ng):LM(ng.vocab),contexts(ng.contexts),order(ng.order),_skipOOVs(ng._skipOO
> Vs),_trustTotals(ng._trustTotals){};
>
> I have the following declarations
>
> Ngram ngramLM(vocab*,order);
>
> While(//<some condition>)
> Ngram useLM(ngramLM);
>
> // Do some stuff with useLM
> .........
> ........
> }
>
> The problem is that the assignment useLM=ngramLM doesn't assign the original
> ngramLM. Any changes I make to useLM shows up in ngramLM too.
> I just want to make a copy (useLM) of the original ngramLM, work on that
> copy and then reinitialize another useLM with the original ngramLM.
>
> Any thoughts?
That's because there is not copy constructor defined for the Trie
(and all component classes) class. So what happens is that pointers to
tries are copied, and the
datastructures end up shared between orignal and copy.
Adding these is not difficult, just tedious, and wasn't needed
up to this point.
--Andreas
>
Click here to go to the SRILM home page.
|
|