-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathPinyin.cpp
More file actions
42 lines (38 loc) · 2.24 KB
/
Pinyin.cpp
File metadata and controls
42 lines (38 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <cpp-pinyin/Pinyin.h>
namespace Pinyin
{
PinyinResVector Pinyin::hanziToPinyin(const std::string &hans, ManTone::Style style, Error error, bool candidates,
bool v_to_u, bool neutral_tone_with_five) const {
/*
@param hans : raw utf-8 std::string.
@param ManTone::Style : Preserve the pinyin tone.
@param errorType : Ignore words that have failed conversion. Default: Keep original.
@param candidates : Return all possible pinyin candidates. Default: true.
@param v_to_u : Convert v to ü. Default: false.
@param neutral_tone_with_five : Use 5 as neutral tone. Default: false.
@return PinyinResVector.
*/
return ChineseG2p::hanziToPinyin(hans, static_cast<int>(style), error, candidates, v_to_u,
neutral_tone_with_five);
}
PinyinResVector Pinyin::hanziToPinyin(const std::vector<std::string> &hans, ManTone::Style style,
Error error, bool candidates, bool v_to_u,
bool neutral_tone_with_five) const {
/*
@param hans : raw utf-8 std::string vector, each element of the vector is a character.
@param ManTone::Style : Preserve the pinyin tone.
@param errorType : Ignore words that have failed conversion. Default: Keep original.
@param candidates : Return all possible pinyin candidates. Default: true.
@param v_to_u : Convert v to ü. Default: false.
@param neutral_tone_with_five : Use 5 as neutral tone. Default: false.
@return PinyinResVector.
*/
return ChineseG2p::hanziToPinyin(hans, static_cast<int>(style), error, candidates, v_to_u,
neutral_tone_with_five);
}
// Convert to Simplified Chinese. utf-8 std::string
std::vector<std::string> Pinyin::getDefaultPinyin(const std::string &hanzi, ManTone::Style style,
bool v_to_u, bool neutral_tone_with_five) const {
return ChineseG2p::getDefaultPinyin(hanzi, static_cast<int>(style), v_to_u, neutral_tone_with_five);
}
}