Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
dissa2 old.docx
Скачиваний:
27
Добавлен:
12.06.2018
Размер:
790.09 Кб
Скачать

Продолжение Приложения а

char *buffer = new char[strID.length() + 1];

strcpy(buffer, strID.c_str());

idstr = strtod(buffer,NULL);

nPos=nPosTab+1;

}

else if (-1 != nPosSpace && nPosSpace < nPosEnd) {

strWrd = line.substr(nPos,nPosSpace-nPos);

nPos=nPosSpace+1;

}

else if (-1 == nPosSpace && nPos <= nPosEnd) {

strWrd = line.substr(nPos,nPosEnd-nPos);

nPos=nPosEnd+1;

}

else if (nPos != nPosEnd) {

error("format is not correct!");

exit(1);

}

if (strWrd != "" ){

std::multimap<string,string>::const_iterator itMap = w2v.begin();

itMap = w2v.find(strWrd);

if(itMap != w2v.end() ){

string strTmp = (*itMap).second;

int n=0;

int nTab;

int nEnd=strTmp.length();

float wgt;

int ncls;

string strCh;

while (n < strTmp.length()){

nTab = strTmp.find('\t', n);

if (-1 != nTab && nTab < nEnd) {

strCh = strTmp.substr(n,nTab-n);

char *buffer = new char[strCh.length() + 1];

strcpy(buffer, strCh.c_str());

ncls = strtod(buffer,NULL);

n=nTab+1;

}

else if (-1 == nTab && n <= nEnd) {

Продолжение Приложения а

strCh = strTmp.substr(n,nEnd-n);

char *buffer = new char[strCh.length() + 1];

strcpy(buffer, strCh.c_str());

wgt = strtod(buffer,NULL);

n=nEnd+1;

}

}

if (0==cntmap){

cls.insert ( std::pair<int,float>(ncls,wgt) );

cntmap=1;

}

else{

std::map<int,float>::const_iterator it = cls.begin();

it = cls.find(ncls);

if(it != cls.end() ){

cls.at(ncls) = (*it).second+wgt;

}

else{

cls.insert ( std::pair<int,float>(ncls,wgt) );

}

}

}

}

}

if (cls.size()+1 > th1){

vCls.push_back( cls );

vId.push_back( idstr );

}

if (epo != -1 && cntepo > epo ){

cout << "." ;

firstClast(vCls, vId, th2, vMapCls, vIdStr);

vCls.clear();

vId.clear();

postClast (vIdStr,vMapCls, th3, th4, vOutIdStr, vOutMapCls);

vIdStr.clear();

vMapCls.clear();

Продолжение Приложения а

if (vOutIdStr.size() != vOutMapCls.size() ){

error("something strange: size of outID and outMap is't equal!");

exit(1);

}

cntepo=0;

}

} //end while

} //close file

if(vCls.size()==0 ){

error ("No words or other lang!\n");

exit(0);

}

else if ( epo == -1 ){

cout << "beginning clasterization \n" ;

firstClast(vCls, vId, th2, vMapCls, vIdStr);

vCls.clear();

vId.clear();

cout << "post clastering \n" ;

postClast (vIdStr,vMapCls, th3, th4, vOutIdStr, vOutMapCls);

vIdStr.clear();

vMapCls.clear();

if (vOutIdStr.size() != vOutMapCls.size() ){

error("something strange: size of outID and outMap is't equal!");

exit(1);

}

}

else{

cout << "\npost clastering \n" ;

std::vector < std::vector < int > > vOutIdStr_epo;

std::vector < std::vector <std::map<int,float> > > vOutMapCls_epo;

postClast (vOutIdStr,vOutMapCls, th3, th4, vOutIdStr_epo, vOutMapCls_epo);

vOutIdStr.clear();

vOutMapCls.clear();

vOutIdStr.resize(vOutIdStr_epo.size());

vOutIdStr=vOutIdStr_epo;

vOutMapCls.resize(vOutMapCls_epo.size());

vOutMapCls=vOutMapCls_epo;

if (vOutIdStr.size() != vOutMapCls.size() ){

error("something strange: size of outID and outMap is't equal!");

exit(1);

}

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]