| | |
| | | #include "precomp.h" |
| | | /** |
| | | * Copyright FunASR (https://github.com/alibaba-damo-academy/FunASR). All Rights Reserved. |
| | | * MIT License (https://opensource.org/licenses/MIT) |
| | | */ |
| | | |
| | | #include "precomp.h" |
| | | |
| | | namespace funasr { |
| | | CTokenizer::CTokenizer(const char* sz_yamlfile):m_ready(false) |
| | | { |
| | | OpenYaml(sz_yamlfile); |
| | | } |
| | | |
| | | CTokenizer::CTokenizer():m_ready(false) |
| | | { |
| | | } |
| | | |
| | | CTokenizer::~CTokenizer() |
| | | { |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | if (node.IsScalar()) {//�DZ����� |
| | | cout << node.as<string>() << endl; |
| | | LOG(INFO) << node.as<string>(); |
| | | } |
| | | } |
| | | |
| | | bool CTokenizer::OpenYaml(const char* sz_yamlfile) |
| | | { |
| | | YAML::Node m_Config = YAML::LoadFile(sz_yamlfile); |
| | | if (m_Config.IsNull()) |
| | | return false; |
| | | YAML::Node m_Config; |
| | | try{ |
| | | m_Config = YAML::LoadFile(sz_yamlfile); |
| | | }catch(exception const &e){ |
| | | LOG(INFO) << "Error loading file, yaml file error or not exist."; |
| | | exit(-1); |
| | | } |
| | | |
| | | try |
| | | { |
| | | auto Tokens = m_Config["token_list"]; |
| | |
| | | } |
| | | } |
| | | catch (YAML::BadFile& e) { |
| | | std::cout << "read error!" << std::endl; |
| | | LOG(ERROR) << "Read error!"; |
| | | return false; |
| | | } |
| | | m_ready = true; |
| | |
| | | result.push_back(m_punc2id[item]); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | bool CTokenizer::IsPunc(string& Punc) |
| | | { |
| | | if (m_punc2id.find(Punc) != m_punc2id.end()) |
| | | return true; |
| | | else |
| | | return false; |
| | | } |
| | | |
| | | vector<string> CTokenizer::SplitChineseString(const string & str_info) |
| | |
| | | } |
| | | id_out= String2Ids(str_out); |
| | | } |
| | | |
| | | } // namespace funasr |