const Reading proc_line(const hfst::HfstTransducer& t, const std::string& line) { std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> utf16conv; const auto& lemma_end = line.find("\" "); const auto& lemma = line.substr(2, lemma_end-2); const auto& tags = line.substr(lemma_end+2); const auto& suggen = proc_tags(tags); const auto& suggest = std::get<0>(suggen); const auto& errtype = utf16conv.from_bytes(std::get<1>(suggen)); const auto& gentags = std::get<2>(suggen); UStringSet sforms; const auto& tagsplus = join(gentags, "+"); const auto& ana = lemma+"+"+tagsplus; if(!suggest) { return {suggest, ana, errtype, sforms}; } const auto& paths = t.lookup_fd({ ana }, -1, 10.0); if(paths->size() > 0) { for(auto& p : *paths) { std::stringstream form; for(auto& symbol : p.second) { // TODO: this is a hack to avoid flag diacritics; is there a way to make lookup skip them? if(symbol.size()>0 && symbol[0]!='@') { form << symbol; } } sforms.insert(utf16conv.from_bytes(form.str())); } } return {suggest, ana, errtype, sforms}; }
//! get communication interface sets and the processors with which //! this processor communicates; sets are sorted by processor ErrorCode ParallelData::get_interface_sets(std::vector<EntityHandle> &iface_sets, std::vector<int> &iface_procs) { #define CONTINUE {result = tmp_result; continue;} iface_sets.clear(); iface_procs.clear(); Tag proc_tag = 0, procs_tag = 0; ErrorCode result = MB_SUCCESS; int my_rank; if (parallelComm) my_rank = parallelComm->proc_config().proc_rank(); else return MB_FAILURE; std::multimap<int, EntityHandle> iface_data; for (int i = 0; i < 2; i++) { ErrorCode tmp_result; if (0 == i) tmp_result = mbImpl->tag_get_handle(PARALLEL_SHARED_PROC_TAG_NAME, 1, MB_TYPE_INTEGER, proc_tag); else tmp_result = mbImpl->tag_get_handle(PARALLEL_SHARED_PROCS_TAG_NAME, MAX_SHARING_PROCS, MB_TYPE_INTEGER, proc_tag); if (MB_SUCCESS != tmp_result) CONTINUE; int tsize; tmp_result = mbImpl->tag_get_length(proc_tag, tsize); if (0 == tsize || MB_SUCCESS != tmp_result) CONTINUE; Range proc_sets; tmp_result = mbImpl->get_entities_by_type_and_tag(0, MBENTITYSET, &proc_tag, NULL, 1, proc_sets, Interface::UNION); if (MB_SUCCESS != tmp_result) CONTINUE; if (proc_sets.empty()) CONTINUE; std::vector<int> proc_tags(proc_sets.size()*tsize); tmp_result = mbImpl->tag_get_data(procs_tag, proc_sets, &proc_tags[0]); if (MB_SUCCESS != tmp_result) CONTINUE; int k; Range::iterator rit; for (k = 0, rit = proc_sets.begin(); rit != proc_sets.end(); rit++, k++) { for (int j = 0; j < tsize; j++) { if (my_rank != proc_tags[2*k+j] && proc_tags[2*k+j] >= 0) iface_data.insert(std::pair<int,EntityHandle>(proc_tags[2*k+j], *rit)); } } } // now get the results in sorted order std::multimap<int,EntityHandle>::iterator mit; for (mit = iface_data.begin(); mit != iface_data.end(); mit++) iface_procs.push_back((*mit).first), iface_sets.push_back((*mit).second); return result; }