39 File file(pfilename,
"rt");
41 while (pLine = file.
GetLine()) {
44 char *p = strtok(pLine,
" \t\n");
47 p = strtok(NULL,
" \t\n");
70 for (
int i = 0; i <
GetNum(); i++) {
84 RandomIdx(m_pCorpus->GetNum());
88 m_aRandIdx.SetNum(nNum);
89 for (
int i = 0; i < nNum; i++) {
98 for (
int i = 0; i < nNum; i++) {
99 if (m_nCurIdx >= m_pCorpus->GetNum()) {
100 RandomIdx(m_pCorpus->GetNum());
103 pIdx[i] = m_aRandIdx[m_nCurIdx];
110 if (m_nCurIdx >= m_pCorpus->GetNum()) {
111 RandomIdx(m_pCorpus->GetNum());
114 m_pCorpus->GetSeq(m_aRandIdx[m_nCurIdx], aSeq);
void Copy(const Array< T > &array)
Copy the array to current array.
#define SAFE_DELETE(p)
memory release
void RandomPos(int *a, int len, int n)
void GetSeq(Array< VocabID > &aSeq)
Get x.
virtual void Reset(const char *pfilename)
Open file and Load the file.
Array< Array< VocabID > * > m_aSeq
void RandomIdx(int nNum)
Generate the random idx.
virtual void GetLenCount(Array< int > &aLenCount)
get the length count
void SetNum(int n)
Set Array number, to melloc enough memory.
virtual char * GetLine(bool bPrecent=false)
Read a line into the buffer.
void Clean()
Clean the array. Just set the top of array to -1 and donot release the memory.
int m_nMaxLen
record the maximum length;
void Reset(CorpusBase *p)
Reset the class.
int GetNum() const
Get Array number.
void Add(T t)
Add a value to the tail of array.
void GetIdx(int *pIdx, int nNum)
Get Ranodm Index.
int m_nNum
record the length number;
virtual bool GetSeq(int nLine, Array< VocabID > &aSeq)
get the sequence in nLine
void Fill(T m)
set all the values to m
int m_nMinLen
record the minimum length;
virtual int GetNum() const
get the seq number