//------------------------------------------------------------------------- // Load the NGRAM table, selecting the nbSelected first void NGram::load(const String filename,Config &config){ XList input(filename,config); XLine *linep; // Pointor on the current test line input.getLine(0); unsigned long idx=0; while (((linep=input.getLine()) != NULL)&&(idx<getSize())){ for (unsigned long i=0;i<getOrder();i++){ short int a=linep->getElement(i).toLong(); setSymbol(idx,i,a); } if (linep->getElementCount()==(getOrder()+1)){ unsigned long count=linep->getElement(getOrder()).toLong(); setCount(idx,count);_totalCount+=count;} else setCount(idx,0); idx++; } if (idx!=getSize()){ cout << "WARNING ! Number of ngram in the file["<<idx<<"] < to the number requested ["<<getSize()<<"]"<<endl; setSize(idx); } if (verboseLevel>1){ cout <<"load symbol table from ["<<filename <<"]"<<endl; showTable(); } }