A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/wolfgitpr/csharp-pinyin below:

wolfgitpr/csharp-pinyin: A lightweight Chinese/Cantonese to Pinyin library.

csharp-pinyin is a lightweight Chinese/Cantonese to Pinyin library.

Chinese dialects can be used to create their own dictionaries using makedict.

Initial version algorithm reference zh_CN, and undergo significant optimization.

pinyin-makedict is the tool for creating Chinese/Cantonese dictionaries.

using Pinyin;

Pinyin.Pinyin pinyinInstance = Pinyin.Pinyin.Instance; // or Pinyin.Jyutping.Instance;
string hans = "明月@1几32时有##一";
PinyinResVector pinyinRes = pinyinInstance.HanziToPinyin(key, ManTone.Style.NORMAL, Error.Default, false, false, false);

List<string> pinyin = pinyinInstance.GetDefaultPinyin("了", ManTone.Style.TONE3, false, false);
//  include/ChineseG2p.cs
public struct PinyinRes
{
    public string hanzi;               //  utf-16 string
    public string pinyin;              //  utf-16 string
    public List<string> candidates;    //  Candidate pinyin of Polyphonic Characters.
    public bool error;                 //  Whether the conversion failed.
};

public class PinyinResList : List<PinyinRes>
{
public:
    //  Convert to utf-16 string list.
    public List<string> ToStrList();
    //  Convert to utf-16 string with delimiter(default: " ").
    public string ToStr(string delimiter = " ");
};

//  ChineseG2p.cs
  enum class Error {
      // Keep original characters
      Default = 0,
      // Ignore this character (do not export)
      Ignore = 1
  };

/*
    @param hans : raw utf-16 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 PinyinResList.
*/
public PinyinResList HanziToPinyin(string hans,
                                        ManTone.Style style = ManTone.Style.TONE,
                                        Error error = Error.Default, bool candidates = true,
                                        bool vToU = false, bool neutralToneWithFive = false);

/*
    @param hans : raw utf-16 List<string>, each element of the vector is a character.
    ...
    @return PinyinResList.
*/
public PinyinResList HanziToPinyin(List<string> hans,
                                        ManTone.Style style = ManTone.Style.TONE,
                                        Error error = Error.Default, bool candidates = true,
                                        bool vToU = false, bool neutralToneWithFive = false);

//  Convert to Simplified Chinese.  utf-8 std::string
string TradToSim(string text);

//  Determine if it is a polyphonic character.
bool IsPolyphonic(string text);

//  Get a pronunciation list.
public List<string> GetDefaultPinyin(string hanzi,
                                     ManTone.Style style = ManTone.Style.TONE,
                                     bool vToU = false, bool neutralToneWithFive = false);
Open-source softwares used

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4