40 virtual void Reset(
const char *pfilename) = 0;
69 virtual void Reset(
const char *pfilename);
95 void GetIdx(
int *pIdx,
int nNum);
97 void RandomIdx(
int nNum);
104 template <
class Type>
115 int len = m_aSeq.
GetNum();
116 for (
int i = 0; i < len; i++) {
117 int s = rand() % (len - i);
119 int temp = m_aSeq[i + s];
120 m_aSeq[i + s] = m_aSeq[i];
129 if (m_nCur >= m_aSeq.
GetNum()) {
132 return m_aSeq[m_nCur++];
void Add(Type t)
add a value
CorpusTxt(const char *pfilename)
void Copy(const Array< T > &array)
Copy the array to current array.
virtual void Reset(const char *pfilename)=0
Open file and Load the file.
const char * GetFileName() const
get the file name
Array< Array< VocabID > * > m_aSeq
virtual bool GetSeq(int nLine, Array< VocabID > &aSeq)=0
get the sequence in nLine
void Random()
Random the sequence.
int m_nMaxLen
record the maximum length;
int GetNum() const
Get Array number.
void Add(T t)
Add a value to the tail of array.
virtual int GetMinLen() const
get the min length
RandSeq(Array< Type > &a)
virtual void GetLenCount(Array< int > &aLenCount)=0
get the length count
int m_nNum
record the length number;
char * GetBuffer() const
get buffer
int m_nMinLen
record the minimum length;
virtual int GetMaxLen() const
get the max length
virtual int GetNum() const
get the seq number
CorpusRandSelect(CorpusBase *pCorpus)