void MusicInfo::divideWordsForinput(CharString inputstr,CharStringLink &outputname) { int begin = 0, lenth; const int maxNumOfWord = 12; hash <string> hm; string lyricsInstring; CharString linkNode; outputname.InitList(); while(begin < inputstr.m_length - 1) { lenth = maxNumOfWord; if (lenth >= inputstr.m_length - begin) //如果词的长度小于等于一次截取的长度 { lenth = inputstr.m_length - 1 - begin; } while(lenth >= 1) { linkNode = inputstr.substr(begin, lenth); lyricsInstring = linkNode.fromCharStoString(); if (lyricsInstring[0] >= 0) { if (lyricsInstring[0] < 'A' || lyricsInstring[0] > 'Z' && lyricsInstring[0] < 'a' || lyricsInstring[0] > 'z') { begin++; break; } } if (lyricsInstring[0] >= 'A' && lyricsInstring[0] <= 'z') { if (lyricsInstring.find(' ') < lenth) { lenth = lyricsInstring.find(' '); linkNode = inputstr.substr(begin, lenth); outputname.ListInsert(linkNode); begin += lenth; break; } else if (lyricsInstring.find('\n') < lenth) { lenth = lyricsInstring.find('\n'); linkNode = inputstr.substr(begin, lenth); outputname.ListInsert(linkNode); begin += lenth; break; } } if (useless_map.find(hm(lyricsInstring)) != useless_map.end()) { begin += 2; break; } if (lenth <= 2 || m_map.find(hm(lyricsInstring)) != m_map.end()) { outputname.ListInsert(linkNode); begin+=lenth; break; } else { lenth--; } } } }
void MusicInfo::divideWords(CharStringLink &outputname) { int begin = 0, lenth; const int maxNumOfWord = 12; hash <string> hm; string lyricsInstring; CharString linkNode; outputname.InitList(); while(M.lyrics.m_string[begin] != '\0') { lenth = maxNumOfWord; while(lenth >= 1) { linkNode = M.lyrics.substr(begin, lenth); lyricsInstring = linkNode.fromCharStoString(); if (lyricsInstring[0] >= 0) { if (lyricsInstring[0] < 'A' || lyricsInstring[0] > 'Z' && lyricsInstring[0] < 'a' || lyricsInstring[0] > 'z') { begin++; break; } } if (lyricsInstring[0] >= 'A' && lyricsInstring[0] <= 'z') { if (lyricsInstring.find(' ') < lenth) { lenth = lyricsInstring.find(' '); linkNode = M.lyrics.substr(begin, lenth); outputname.ListInsert(linkNode); begin += lenth; break; } else if (lyricsInstring.find('\n') < lenth) { lenth = lyricsInstring.find('\n'); linkNode = M.lyrics.substr(begin, lenth); outputname.ListInsert(linkNode); begin += lenth; break; } } if (useless_map.find(hm(lyricsInstring)) != useless_map.end()) { begin += 2; break; } if (lenth <= 2 || m_map.find(hm(lyricsInstring)) != m_map.end()) { outputname.ListInsert(linkNode); begin+=lenth; break; } else { lenth--; } } } }