bool MeowPinyin::RecursiveQuanpinResult(unsigned int index, unsigned int offset_pinyin, PINYIN_RESULT pr) { if (index >= segments.size()) { results.push_back(pr); return true; } PINYIN_SEGMENT *segment = &segments[index]; size_t length = segment->solutions_quanpin.size(); std::sort(segment->solutions_quanpin.begin(), segment->solutions_quanpin.end(), SegmentSolutionCompare); // foreah solutions_quanpin for (unsigned int i = 0; i < length; i++) { for (unsigned int j = 0; j < segment->solutions_quanpin[i].length; j++) { pr.pinyin.push_back(segment->solutions_quanpin[i].result[j]); } RecursiveQuanpinResult(index + 1, offset_pinyin, pr); for (unsigned int j = 0; j < segment->solutions_quanpin[i].length; j++) { pr.pinyin.pop_back(); } } return false; }
void MeowPinyin::GenerateResult() { PINYIN_RESULT pr; pr.length = 0; pr.power = 0; RecursiveQuanpinResult(0, 0, pr); if (results.size() == 0) { RecursiveQuanpinPendingResult(0, 0, pr); } if (results.size() == 0) { RecursiveQuanpinFirstResult(0, 0, pr); } }