init commit
This commit is contained in:
72
back_end_code/RoadFlow.Pinyin/Pinyin4Name.cs
Normal file
72
back_end_code/RoadFlow.Pinyin/Pinyin4Name.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using RoadFlow.Pinyin.data;
|
||||
using RoadFlow.Pinyin.exception;
|
||||
using System.Linq;
|
||||
using RoadFlow.Pinyin.format;
|
||||
|
||||
namespace RoadFlow.Pinyin
|
||||
{
|
||||
/// <summary>
|
||||
/// 处理姓名专用
|
||||
/// </summary>
|
||||
public static class Pinyin4Name
|
||||
{
|
||||
#region // 获取单字拼音
|
||||
/// <summary>
|
||||
/// 获取姓的拼音,如果是复姓则由空格分隔
|
||||
/// </summary>
|
||||
/// <param name="firstName">要查询拼音的姓</param>
|
||||
/// <returns>返回姓的拼音,若未找到姓,则返回null</returns>
|
||||
/// <exception cref="UnsupportedUnicodeException">当要获取拼音的字符不是汉字时抛出此异常</exception>
|
||||
public static string GetPinyin(string firstName)
|
||||
{
|
||||
if (firstName.All(PinyinUtil.IsHanzi))
|
||||
{
|
||||
return NameDB.Instance.GetPinyin(firstName);
|
||||
}
|
||||
// 不是汉字
|
||||
throw new UnsupportedUnicodeException("不支持的字符: 请输入汉字字符");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取姓的首字母,如果是复姓则由空格分隔首字母
|
||||
/// </summary>
|
||||
/// <param name="firstName">要查询拼音的姓</param>
|
||||
/// <returns>返回姓的拼音首字母,若未找到姓,则返回null</returns>
|
||||
/// <exception cref="UnsupportedUnicodeException">当要获取拼音的字符不是汉字时抛出此异常</exception>
|
||||
public static string GetFirstLetter(string firstName)
|
||||
{
|
||||
var pinyin = GetPinyin(firstName);
|
||||
if (pinyin == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return string.Join(" ", pinyin.Split(' ').Select(py => py[0]));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取格式化后的拼音
|
||||
/// </summary>
|
||||
/// <param name="firstName">要查询拼音的姓</param>
|
||||
/// <param name="format">输出拼音格式化参数</param>
|
||||
/// <see cref="PinyinOutputFormat"/>
|
||||
/// <seealso cref="PinyinFormatter"/>
|
||||
/// <returns>返回格式化后的拼音,若未找到姓,则返回null</returns>
|
||||
/// <exception cref="UnsupportedUnicodeException">当要获取拼音的字符不是汉字时抛出此异常</exception>
|
||||
public static string GetPinyinWithFormat(string firstName, PinyinOutputFormat format)
|
||||
{
|
||||
return string.Join(" ", GetPinyin(firstName).Split(' ').Select(item => PinyinFormatter.Format(item, format)));
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 根据拼音查询匹配的姓
|
||||
/// </summary>
|
||||
/// <param name="pinyin"></param>
|
||||
/// <param name="matchAll">是否全部匹配,为true时,匹配整个拼音,否则匹配开头字符,此参数用于告知传入的拼音是完整拼音还是仅仅是声母</param>
|
||||
/// <returns>匹配的姓数组</returns>
|
||||
public static string[] GetHanzi(string pinyin, bool matchAll)
|
||||
{
|
||||
return NameDB.Instance.GetHanzi(pinyin.ToLower(), matchAll);
|
||||
}
|
||||
}
|
||||
}
|
||||
256
back_end_code/RoadFlow.Pinyin/Pinyin4Net.cs
Normal file
256
back_end_code/RoadFlow.Pinyin/Pinyin4Net.cs
Normal file
@@ -0,0 +1,256 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using RoadFlow.Pinyin.exception;
|
||||
using RoadFlow.Pinyin.format;
|
||||
using RoadFlow.Pinyin.data;
|
||||
using System;
|
||||
|
||||
namespace RoadFlow.Pinyin
|
||||
{
|
||||
public static class Pinyin4Net
|
||||
{
|
||||
#region // 获取单字拼音
|
||||
/// <summary>
|
||||
/// 获取汉字的拼音数组
|
||||
/// </summary>
|
||||
/// <param name="hanzi">要查询拼音的汉字字符</param>
|
||||
/// <returns>汉字的拼音数组,若未找到汉字拼音,则返回空数组</returns>
|
||||
/// <exception cref="UnsupportedUnicodeException">当要获取拼音的字符不是汉字时抛出此异常</exception>
|
||||
public static string[] GetPinyin(char hanzi)
|
||||
{
|
||||
if (PinyinUtil.IsHanzi(hanzi))
|
||||
{
|
||||
return PinyinDB.Instance.GetPinyin(hanzi);
|
||||
}
|
||||
// 不是汉字
|
||||
throw new UnsupportedUnicodeException("不支持的字符: 请输入汉字");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取唯一拼音(单音字)或者第一个拼音(多音字)
|
||||
/// </summary>
|
||||
/// <param name="hanzi">要查询拼音的汉字字符</param>
|
||||
/// <returns>返回唯一拼音(单音字)或者第一个拼音(多音字)</returns>
|
||||
/// <exception cref="UnsupportedUnicodeException">当要获取拼音的字符不是汉字时抛出此异常</exception>
|
||||
public static string GetUniqueOrFirstPinyin(char hanzi)
|
||||
{
|
||||
return GetPinyin(hanzi)[0];
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取格式化后的拼音
|
||||
/// </summary>
|
||||
/// <param name="hanzi">要查询拼音的汉字字符</param>
|
||||
/// <param name="format">拼音输出格式化参数</param>
|
||||
/// <see cref="PinyinOutputFormat"/>
|
||||
/// <seealso cref="PinyinFormatter"/>
|
||||
/// <returns>经过格式化的拼音</returns>
|
||||
/// <exception cref="UnsupportedUnicodeException">当要获取拼音的字符不是汉字时抛出此异常</exception>
|
||||
public static string[] GetPinyinWithFormat(char hanzi, PinyinOutputFormat format)
|
||||
{
|
||||
return GetPinyin(hanzi).Select(item => PinyinFormatter.Format(item, format)).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取格式化后的唯一拼音(单音字)或者第一个拼音(多音字)
|
||||
/// </summary>
|
||||
/// <param name="hanzi">要查询拼音的汉字字符</param>
|
||||
/// <param name="format">拼音输出格式化参数</param>
|
||||
/// <see cref="PinyinOutputFormat"/>
|
||||
/// <seealso cref="PinyinFormatter"/>
|
||||
/// <returns>格式化后的唯一拼音(单音字)或者第一个拼音(多音字)</returns>
|
||||
/// <exception cref="UnsupportedUnicodeException">当要获取拼音的字符不是汉字时抛出此异常</exception>
|
||||
public static string GetUniqueOrFirstPinyinWithFormat(char hanzi, PinyinOutputFormat format)
|
||||
{
|
||||
return PinyinFormatter.Format(GetUniqueOrFirstPinyin(hanzi), format);
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 获取一个字符串内所有汉字的拼音(多音字取第一个读音,带格式)
|
||||
/// </summary>
|
||||
/// <param name="text">要获取拼音的汉字字符串</param>
|
||||
/// <param name="format">拼音输出格式化参数</param>
|
||||
/// <param name="caseSpread">是否将前面的格式中的大小写扩展到其它非拼音字符,默认为false。firstLetterOnly为false时有效 </param>
|
||||
/// <param name="firstLetterOnly">是否只取拼音首字母,为true时,format无效</param>
|
||||
/// <param name="multiFirstLetter">firstLetterOnly为true时有效,多音字的多个读音首字母是否全取,如果多音字拼音首字母相同,只保留一个</param>
|
||||
/// <returns>firstLetterOnly为true时,只取拼音首字母格式为[L],后面追加空格;multiFirstLetter为true时,多音字的多个拼音首字母格式为[L, H],后面追加空格</returns>
|
||||
public static string GetPinyin(string text, PinyinOutputFormat format, bool caseSpread, bool firstLetterOnly, bool multiFirstLetter)
|
||||
{
|
||||
if (string.IsNullOrEmpty(text)) return "";
|
||||
|
||||
var pinyin = new StringBuilder();
|
||||
var firstLetterBuf = new List<string>();
|
||||
|
||||
foreach (var item in text)
|
||||
{
|
||||
if (!PinyinUtil.IsHanzi(item))
|
||||
{
|
||||
pinyin.Append(item);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!firstLetterOnly)
|
||||
{
|
||||
pinyin.Append(GetUniqueOrFirstPinyinWithFormat(item, format) + " ");
|
||||
continue;
|
||||
}
|
||||
if (!multiFirstLetter)
|
||||
{
|
||||
pinyin.AppendFormat("[{0}] ", GetUniqueOrFirstPinyin(item)[0]);
|
||||
continue;
|
||||
}
|
||||
|
||||
firstLetterBuf.Clear();
|
||||
|
||||
firstLetterBuf.AddRange(GetPinyin(item)
|
||||
.Select(py => py[0].ToString())
|
||||
// 这句是处理多音字,多音字的拼音可能首字母是一样的,
|
||||
// 如果是一样的,肯定就只返回一次
|
||||
.Distinct());
|
||||
|
||||
pinyin.AppendFormat("[{0}] ", string.Join(",", firstLetterBuf.ToArray()));
|
||||
}
|
||||
|
||||
#region // 扩展大小写格式
|
||||
if (firstLetterOnly || !caseSpread)
|
||||
{
|
||||
return pinyin.ToString().Trim();
|
||||
}
|
||||
|
||||
switch (format.GetCaseFormat)
|
||||
{
|
||||
case CaseFormat.CAPITALIZE_FIRST_LETTER:
|
||||
return CapitalizeFirstLetter(pinyin);
|
||||
case CaseFormat.LOWERCASE:
|
||||
return pinyin.ToString().Trim().ToLower();
|
||||
case CaseFormat.UPPERCASE:
|
||||
return pinyin.ToString().Trim().ToUpper();
|
||||
default:
|
||||
return pinyin.ToString().Trim();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取一个字符串内所有汉字的拼音(多音字取第一个读音,带格式)
|
||||
/// </summary>
|
||||
/// <param name="text">要获取拼音的汉字字符串</param>
|
||||
/// <param name="format">拼音输出格式化参数</param>
|
||||
/// <param name="caseSpread">是否将前面的格式中的大小写扩展到其它非拼音字符,默认为false。firstLetterOnly为false时有效 </param>
|
||||
/// <param name="pinyinHandler">
|
||||
/// 拼音处理器,在获取到拼音后通过这个来处理,
|
||||
/// 如果传null,则默认取第一个拼音(多音字),
|
||||
/// 参数:
|
||||
/// 1 string[] 拼音数组
|
||||
/// 2 char 当前的汉字
|
||||
/// 3 string 要转成拼音的字符串
|
||||
/// return 拼音字符串,这个返回值将作为这个汉字的拼音放到结果中
|
||||
/// </param>
|
||||
/// <returns>firstLetterOnly为true时,只取拼音首字母格式为[L],后面追加空格;multiFirstLetter为true时,多音字的多个拼音首字母格式为[L, H],后面追加空格</returns>
|
||||
public static string GetPinyin(string text, PinyinOutputFormat format, bool caseSpread, Func<string[], char, string, string> pinyinHandler)
|
||||
{
|
||||
if (string.IsNullOrEmpty(text)) return "";
|
||||
|
||||
var pinyin = new StringBuilder();
|
||||
var firstLetterBuf = new List<string>();
|
||||
|
||||
foreach (var item in text)
|
||||
{
|
||||
if (!PinyinUtil.IsHanzi(item))
|
||||
{
|
||||
pinyin.Append(item);
|
||||
continue;
|
||||
}
|
||||
|
||||
var pinyinTemp = PinyinDB.Instance.GetPinyin(item);
|
||||
|
||||
pinyin.Append(pinyinHandler == null ?
|
||||
pinyinTemp[0] :
|
||||
pinyinHandler.Invoke(pinyinTemp, item, text));
|
||||
|
||||
firstLetterBuf.Clear();
|
||||
|
||||
firstLetterBuf.AddRange(GetPinyin(item)
|
||||
.Where(py => !firstLetterBuf.Contains(py[0].ToString()))
|
||||
.Select(py => py[0].ToString()));
|
||||
|
||||
pinyin.AppendFormat("[{0}] ", string.Join(",", firstLetterBuf.ToArray()));
|
||||
}
|
||||
#region // 扩展大小写格式
|
||||
if (!caseSpread)
|
||||
{
|
||||
return pinyin.ToString().Trim();
|
||||
}
|
||||
|
||||
switch (format.GetCaseFormat)
|
||||
{
|
||||
case CaseFormat.CAPITALIZE_FIRST_LETTER:
|
||||
return CapitalizeFirstLetter(pinyin).Trim();
|
||||
case CaseFormat.LOWERCASE:
|
||||
return pinyin.ToString().ToLower();
|
||||
case CaseFormat.UPPERCASE:
|
||||
return pinyin.ToString().ToUpper();
|
||||
default:
|
||||
return pinyin.ToString();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取一个字符串内所有汉字的拼音(多音字取第一个读音,带格式),format中指定的大小写模式不会扩展到非拼音字符
|
||||
/// </summary>
|
||||
/// <param name="text">要获取拼音的汉字字符串</param>
|
||||
/// <param name="format">拼音输出格式化参数</param>
|
||||
/// <returns>格式化后的拼音字符串</returns>
|
||||
public static string GetPinyin(string text, PinyinOutputFormat format)
|
||||
{
|
||||
return GetPinyin(text, format, false, false, false);
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据单个拼音查询匹配的汉字
|
||||
/// </summary>
|
||||
/// <param name="pinyin">要查询汉字的单个拼音</param>
|
||||
/// <param name="matchAll">是否全部匹配,为true时,匹配整个拼音,否则匹配开头字符</param>
|
||||
/// <returns></returns>
|
||||
public static string[] GetHanzi(string pinyin, bool matchAll)
|
||||
{
|
||||
return PinyinDB.Instance.GetHanzi(pinyin.ToLower(), matchAll);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将首字母搞成大写的
|
||||
/// </summary>
|
||||
/// <param name="buffer"></param>
|
||||
/// <returns></returns>
|
||||
private static string CapitalizeFirstLetter(StringBuilder buffer)
|
||||
{
|
||||
// 遇到空格后,将后面一个非空格的字符设置为大写
|
||||
for (var i = 0; i < buffer.Length; i++)
|
||||
{
|
||||
if (buffer[i] != ' ')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// 当前是最后一个字符
|
||||
if (i == buffer.Length - 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var nextchar = buffer[i + 1];
|
||||
|
||||
// 后一个字符是空格
|
||||
if (nextchar == ' ')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
buffer[i + 1] = char.ToUpper(nextchar);
|
||||
}
|
||||
|
||||
return buffer.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
21
back_end_code/RoadFlow.Pinyin/PinyinUtil.cs
Normal file
21
back_end_code/RoadFlow.Pinyin/PinyinUtil.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace RoadFlow.Pinyin
|
||||
{
|
||||
/// <summary>
|
||||
/// 拼音工具类
|
||||
/// </summary>
|
||||
public static class PinyinUtil
|
||||
{
|
||||
/// <summary>
|
||||
/// 判断字符是否是汉字
|
||||
/// </summary>
|
||||
/// <param name="ch">要判断的字符</param>
|
||||
/// <returns></returns>
|
||||
public static bool IsHanzi(char ch)
|
||||
{
|
||||
return Regex.IsMatch(ch.ToString(), @"[\u4e00-\u9fbb]");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
7
back_end_code/RoadFlow.Pinyin/RoadFlow.Pinyin.csproj
Normal file
7
back_end_code/RoadFlow.Pinyin/RoadFlow.Pinyin.csproj
Normal file
@@ -0,0 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"runtimeTarget": {
|
||||
"name": ".NETCoreApp,Version=v5.0",
|
||||
"signature": ""
|
||||
},
|
||||
"compilationOptions": {},
|
||||
"targets": {
|
||||
".NETCoreApp,Version=v5.0": {
|
||||
"RoadFlow.Pinyin/1.0.0": {
|
||||
"runtime": {
|
||||
"RoadFlow.Pinyin.dll": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"libraries": {
|
||||
"RoadFlow.Pinyin/1.0.0": {
|
||||
"type": "project",
|
||||
"serviceable": false,
|
||||
"sha512": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
530
back_end_code/RoadFlow.Pinyin/data/NameDB.cs
Normal file
530
back_end_code/RoadFlow.Pinyin/data/NameDB.cs
Normal file
@@ -0,0 +1,530 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace RoadFlow.Pinyin.data
|
||||
{
|
||||
/// <summary>
|
||||
/// 使用姓名数据库查询
|
||||
/// </summary>
|
||||
internal class NameDB
|
||||
{
|
||||
// 实例
|
||||
private static NameDB instance;
|
||||
|
||||
private readonly Dictionary<string, string> map;
|
||||
|
||||
/// <summary>
|
||||
/// 获取单实例
|
||||
/// </summary>
|
||||
public static NameDB Instance
|
||||
{
|
||||
get { return instance ?? (instance = new NameDB()); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 私有构造
|
||||
/// </summary>
|
||||
private NameDB()
|
||||
{
|
||||
map = new Dictionary<string, string>();
|
||||
|
||||
loadResource();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载拼音库资源
|
||||
/// </summary>
|
||||
private void loadResource()
|
||||
{
|
||||
foreach (var buf in DATA.Split('\n').Where(buf => !string.IsNullOrEmpty(buf)))
|
||||
{
|
||||
var temp = buf.Split('=');
|
||||
// 取姓
|
||||
var name = temp[0];
|
||||
|
||||
// 取拼音串 小心有个 \r 的回车符号
|
||||
var pinyin = temp[1].Trim();
|
||||
|
||||
map.Add(name, pinyin.Replace('-', ' '));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取汉字的拼音
|
||||
/// </summary>
|
||||
/// <param name="hanzi"></param>
|
||||
/// <returns>若未找到汉字拼音,则返回空</returns>
|
||||
public string GetPinyin(string hanzi)
|
||||
{
|
||||
return map.ContainsKey(hanzi) ? map[hanzi] : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据拼音获取汉字
|
||||
/// </summary>
|
||||
/// <param name="pinyin">拼音</param>
|
||||
/// <param name="matchAll">是否全部匹配,为true时,匹配整个拼音,否则匹配开头字符,此参数用于告知传入的拼音是完整拼音还是仅仅是声母</param>
|
||||
/// <returns></returns>
|
||||
public string[] GetHanzi(string pinyin, bool matchAll)
|
||||
{
|
||||
var reg = new Regex("[0-9]");
|
||||
// 完全匹配
|
||||
if (matchAll)
|
||||
{
|
||||
// 查询到匹配的拼音的汉字
|
||||
return map.Where(item => reg.Replace(item.Value, "").Equals(pinyin))
|
||||
.Select(item => item.Key).ToArray();
|
||||
}
|
||||
// 匹配开头部分
|
||||
else
|
||||
{
|
||||
// 查询到匹配的拼音的unicode编码
|
||||
return map.Where(item => reg.Replace(item.Value, "").StartsWith(pinyin))
|
||||
.Select(item => item.Key).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private const string DATA = @"艾=ai4
|
||||
安=an1
|
||||
敖=ao2
|
||||
巴=ba1
|
||||
白=bai2
|
||||
柏=bai3
|
||||
班=ban1
|
||||
包=bao1
|
||||
暴=bao4
|
||||
鲍=bao4
|
||||
贝=bei4
|
||||
贲=ben1
|
||||
毕=bi4
|
||||
边=bian1
|
||||
卞=bian4
|
||||
别=bie2
|
||||
邴=bing3
|
||||
薄=bo2
|
||||
卜=bu3
|
||||
步=bu4
|
||||
蔡=cai4
|
||||
苍=cang1
|
||||
曹=cao2
|
||||
岑=cen2
|
||||
柴=chai2
|
||||
单于=chan2-yu2
|
||||
昌=chang1
|
||||
常=chang2
|
||||
巢=chao2
|
||||
晁=chao2
|
||||
车=che1
|
||||
陈=chen2
|
||||
成=cheng2
|
||||
程=cheng2
|
||||
池=chi2
|
||||
充=chong1
|
||||
储=chu3
|
||||
褚=chu3
|
||||
淳于=chun2-yu2
|
||||
从=cong2
|
||||
崔=cui1
|
||||
戴=dai4
|
||||
党=dang3
|
||||
邓=deng4
|
||||
狄=di2
|
||||
第五=di4-wu3
|
||||
刁=diao1
|
||||
丁=ding1
|
||||
东方=dong1-fang1
|
||||
东=dong1
|
||||
董=dong3
|
||||
窦=dou4
|
||||
都=du1
|
||||
堵=du3
|
||||
杜=du4
|
||||
段=duan4
|
||||
鄂=e4
|
||||
樊=fan2
|
||||
范=fan4
|
||||
方=fang1
|
||||
房=fang2
|
||||
费=fei4
|
||||
丰=feng1
|
||||
封=feng1
|
||||
酆=feng1
|
||||
冯=feng2
|
||||
凤=feng4
|
||||
伏=fu2
|
||||
扶=fu2
|
||||
福=fu2
|
||||
符=fu2
|
||||
傅=fu4
|
||||
富=fu4
|
||||
干=gan1
|
||||
甘=gan1
|
||||
高=gao1
|
||||
郜=gao4
|
||||
戈=ge1
|
||||
盖=ge3
|
||||
葛=ge3
|
||||
耿=geng3
|
||||
公孙=gong1-sun1
|
||||
公羊=gong1-yang2
|
||||
公冶=gong1-ye3
|
||||
宗政=gong1-ye3
|
||||
公=gong1
|
||||
宫=gong1
|
||||
弓=gong1
|
||||
龚=gong1
|
||||
巩=gong3
|
||||
贡=gong4
|
||||
勾=gou1
|
||||
古=gu3
|
||||
谷=gu3
|
||||
顾=gu4
|
||||
关=guan1
|
||||
管=guan3
|
||||
广=guang3
|
||||
桂=gui4
|
||||
郭=guo1
|
||||
国=guo2
|
||||
韩=han2
|
||||
杭=hang2
|
||||
郝=hao3
|
||||
何=he2
|
||||
和=he2
|
||||
赫连=he4-lian2
|
||||
贺=he4
|
||||
衡=heng2
|
||||
弘=hong2
|
||||
洪=hong2
|
||||
红=hong2
|
||||
侯=hou2
|
||||
後=hou4
|
||||
胡=hu2
|
||||
扈=hu4
|
||||
花=hua1
|
||||
滑=hua2
|
||||
华=hua4
|
||||
怀=huai2
|
||||
桓=huan2
|
||||
宦=huan4
|
||||
皇甫=huang2-fu3
|
||||
黄=huang2
|
||||
惠=hui4
|
||||
霍=huo4
|
||||
姬=ji1
|
||||
嵇=ji1
|
||||
吉=ji2
|
||||
汲=ji2
|
||||
纪=ji3
|
||||
冀=ji4
|
||||
季=ji4
|
||||
暨=ji4
|
||||
蓟=ji4
|
||||
计=ji4
|
||||
家=jia1
|
||||
郏=jia2
|
||||
贾=jia3
|
||||
简=jian3
|
||||
姜=jiang1
|
||||
江=jiang1
|
||||
蒋=jiang3
|
||||
焦=jiao1
|
||||
金=jin1
|
||||
靳=jin4
|
||||
经=jing1
|
||||
荆=jing1
|
||||
井=jing3
|
||||
景=jing3
|
||||
居=ju1
|
||||
鞠=ju1
|
||||
阚=kan4
|
||||
康=kang1
|
||||
柯=ke1
|
||||
空=kong1
|
||||
孔=kong3
|
||||
寇=kou4
|
||||
蒯=kuai3
|
||||
匡=kuang1
|
||||
夔=kui2
|
||||
隗=kui2
|
||||
赖=lai4
|
||||
蓝=lan2
|
||||
郎=lang2
|
||||
劳=lao2
|
||||
雷=lei2
|
||||
冷=leng3
|
||||
黎=li2
|
||||
李=li3
|
||||
利=li4
|
||||
厉=li4
|
||||
郦=li4
|
||||
廉=lian2
|
||||
连=lian2
|
||||
梁=liang2
|
||||
廖=liao4
|
||||
林=lin2
|
||||
蔺=lin4
|
||||
令狐=ling2-hu2
|
||||
凌=ling2
|
||||
刘=liu2
|
||||
柳=liu3
|
||||
隆=long2
|
||||
龙=long2
|
||||
娄=lou2
|
||||
闾丘=lu2-qiu1
|
||||
卢=lu2
|
||||
吕=lu3
|
||||
鲁=lu3
|
||||
禄=lu4
|
||||
路=lu4
|
||||
逯=lu4
|
||||
陆=lu4
|
||||
栾=luan2
|
||||
罗=luo2
|
||||
骆=luo4
|
||||
麻=ma2
|
||||
马=ma3
|
||||
满=man3
|
||||
毛=mao2
|
||||
茅=mao2
|
||||
梅=mei2
|
||||
蒙=meng2
|
||||
孟=meng4
|
||||
糜=mi2
|
||||
米=mi3
|
||||
宓=mi4
|
||||
苗=miao2
|
||||
缪=miao4
|
||||
闵=min3
|
||||
明=ming2
|
||||
万俟=mo4-qi2
|
||||
莫=mo4
|
||||
慕容=mu4-rong2
|
||||
慕=mu4
|
||||
牧=mu4
|
||||
穆=mu4
|
||||
那=na1
|
||||
能=nai4
|
||||
倪=ni2
|
||||
乜=nie4
|
||||
聂=nie4
|
||||
宁=ning4
|
||||
牛=niu2
|
||||
钮=niu3
|
||||
农=nong2
|
||||
欧阳=ou1-yang2
|
||||
欧=ou1
|
||||
潘=pan1
|
||||
庞=pang2
|
||||
逄=pang2
|
||||
裴=pei2
|
||||
彭=peng2
|
||||
蓬=peng2
|
||||
皮=pi2
|
||||
平=ping2
|
||||
濮阳=pu2-yang2
|
||||
濮=pu2
|
||||
蒲=pu2
|
||||
浦=pu3
|
||||
戚=qi1
|
||||
祁=qi2
|
||||
齐=qi2
|
||||
钱=qian2
|
||||
强=qiang2
|
||||
乔=qiao2
|
||||
秦=qin2
|
||||
秋=qiu1
|
||||
邱=qiu1
|
||||
仇=qiu2
|
||||
裘=qiu2
|
||||
屈=qu1
|
||||
麴=qu1
|
||||
璩=qu2
|
||||
瞿=qu2
|
||||
全=quan2
|
||||
权=quan2
|
||||
阙=que1
|
||||
冉=ran3
|
||||
饶=rao2
|
||||
任=ren2
|
||||
容=rong2
|
||||
戎=rong2
|
||||
荣=rong2
|
||||
融=rong2
|
||||
茹=ru2
|
||||
阮=ruan3
|
||||
芮=rui4
|
||||
桑=sang1
|
||||
沙=sha1
|
||||
山=shan1
|
||||
单=shan4
|
||||
上官=shang4-guan1
|
||||
尚=shang4
|
||||
韶=shao2
|
||||
邵=shao4
|
||||
厍=she4
|
||||
申屠=shen1-tu2
|
||||
申=shen1
|
||||
莘=shen1
|
||||
沈=shen3
|
||||
慎=shen4
|
||||
盛=sheng
|
||||
师=shi1
|
||||
施=shi1
|
||||
时=shi2
|
||||
石=shi2
|
||||
史=shi3
|
||||
寿=shou4
|
||||
殳=shu1
|
||||
舒=shu1
|
||||
束=shu4
|
||||
双=shuang1
|
||||
水=shui3
|
||||
司空=si1-kong1
|
||||
司马=si1-ma3
|
||||
司徒=si1-tu2
|
||||
司=si1
|
||||
松=song1
|
||||
宋=song4
|
||||
苏=su1
|
||||
宿=su4
|
||||
孙=sun1
|
||||
索=suo3
|
||||
邰=tai2
|
||||
太叔=tai4-shu1
|
||||
澹台=tan2-tai2
|
||||
谈=tan2
|
||||
谭=tan2
|
||||
汤=tang1
|
||||
唐=tang2
|
||||
陶=tao2
|
||||
滕=teng2
|
||||
田=tian2
|
||||
通=tong1
|
||||
佟=tong2
|
||||
童=tong2
|
||||
钭=tou3
|
||||
屠=tu2
|
||||
万=wan4
|
||||
汪=wang1
|
||||
王=wang2
|
||||
危=wei1
|
||||
韦=wei2
|
||||
卫=wei4
|
||||
蔚=wei4
|
||||
魏=wei4
|
||||
温=wen1
|
||||
闻人=wen2-ren2
|
||||
文=wen2
|
||||
闻=wen2
|
||||
翁=weng1
|
||||
沃=wo4
|
||||
乌=wu1
|
||||
巫=wu1
|
||||
邬=wu1
|
||||
吴=wu2
|
||||
毋=wu2
|
||||
伍=wu3
|
||||
武=wu3
|
||||
奚=xi1
|
||||
郗=xi1
|
||||
习=xi2
|
||||
席=xi2
|
||||
郤=xi4
|
||||
夏侯=xia4-hou2
|
||||
夏=xia4
|
||||
鲜于=xian1-yu2
|
||||
咸=xian2
|
||||
向=xiang4
|
||||
相=xiang4
|
||||
项=xiang4
|
||||
萧=xiao1
|
||||
解=xie4
|
||||
谢=xie4
|
||||
辛=xin1
|
||||
邢=xing2
|
||||
幸=xing4
|
||||
熊=xiong2
|
||||
胥=xu1
|
||||
须=xu1
|
||||
徐=xu2
|
||||
许=xu3
|
||||
轩辕=xuan1-yuan2
|
||||
宣=xuan1
|
||||
薛=xue1
|
||||
荀=xun2
|
||||
燕=yan1
|
||||
严=yan2
|
||||
言=yan2
|
||||
阎=yan2
|
||||
颜=yan2
|
||||
晏=yan4
|
||||
杨=yang2
|
||||
羊=yang2
|
||||
仰=yang3
|
||||
养=yang3
|
||||
姚=yao2
|
||||
叶=ye4
|
||||
伊=yi1
|
||||
易=yi4
|
||||
益=yi4
|
||||
羿=yi4
|
||||
殷=yin1
|
||||
阴=yin1
|
||||
尹=yin3
|
||||
印=yin4
|
||||
应=ying1
|
||||
雍=yong1
|
||||
尤=you2
|
||||
游=you2
|
||||
於=yu1
|
||||
于=yu2
|
||||
余=yu2
|
||||
俞=yu2
|
||||
虞=yu2
|
||||
鱼=yu2
|
||||
宇文=yu3-wen2
|
||||
庾=yu3
|
||||
禹=yu3
|
||||
尉迟=yu4-chi2
|
||||
喻=yu4
|
||||
郁=yu4
|
||||
元=yuan2
|
||||
袁=yuan2
|
||||
乐=yue4
|
||||
越=yue4
|
||||
云=yun2
|
||||
宰=zai3
|
||||
昝=zan3
|
||||
臧=zang1
|
||||
曾=zeng1
|
||||
查=zha1
|
||||
翟=zhai2
|
||||
詹=zhan1
|
||||
湛=zhan4
|
||||
张=zhang1
|
||||
章=zhang1
|
||||
长孙=zhang3-sun1
|
||||
赵=zhao4
|
||||
甄=zhen1
|
||||
郑=zheng4
|
||||
支=zhi1
|
||||
钟离=zhong1-li2
|
||||
仲孙=zhong1-sun1
|
||||
终=zhong1
|
||||
钟=zhong1
|
||||
仲=zhong4
|
||||
周=zhou1
|
||||
诸葛=zhu1-ge3
|
||||
朱=zhu1
|
||||
诸=zhu1
|
||||
竺=zhu2
|
||||
祝=zhu4
|
||||
庄=zhuang1
|
||||
卓=zhuo2
|
||||
訾=zi3
|
||||
宗=zong1
|
||||
邹=zou1
|
||||
祖=zu3
|
||||
左=zuo3";
|
||||
}
|
||||
}
|
||||
21012
back_end_code/RoadFlow.Pinyin/data/PinyinDB.cs
Normal file
21012
back_end_code/RoadFlow.Pinyin/data/PinyinDB.cs
Normal file
File diff suppressed because it is too large
Load Diff
15
back_end_code/RoadFlow.Pinyin/exception/PinyinException.cs
Normal file
15
back_end_code/RoadFlow.Pinyin/exception/PinyinException.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
|
||||
namespace RoadFlow.Pinyin.exception
|
||||
{
|
||||
/// <summary>
|
||||
/// 拼音异常类
|
||||
/// </summary>
|
||||
public class PinyinException : Exception
|
||||
{
|
||||
public PinyinException(string message) : base(message)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace RoadFlow.Pinyin.exception
|
||||
{
|
||||
/// <summary>
|
||||
/// 转换拼音的字符非汉字字符
|
||||
/// </summary>
|
||||
public class UnsupportedUnicodeException : PinyinException
|
||||
{
|
||||
public UnsupportedUnicodeException(string message) : base(message)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
21
back_end_code/RoadFlow.Pinyin/format/CaseFormat.cs
Normal file
21
back_end_code/RoadFlow.Pinyin/format/CaseFormat.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
namespace RoadFlow.Pinyin.format
|
||||
{
|
||||
/// <summary>
|
||||
/// 大小写格式
|
||||
/// </summary>
|
||||
public enum CaseFormat
|
||||
{
|
||||
/// <summary>
|
||||
/// 首字母大写,此选项对 a e o 几个独音无效
|
||||
/// </summary>
|
||||
CAPITALIZE_FIRST_LETTER,
|
||||
/// <summary>
|
||||
/// 全小写
|
||||
/// </summary>
|
||||
LOWERCASE,
|
||||
/// <summary>
|
||||
/// 全大写
|
||||
/// </summary>
|
||||
UPPERCASE
|
||||
}
|
||||
}
|
||||
172
back_end_code/RoadFlow.Pinyin/format/PinyinFormatter.cs
Normal file
172
back_end_code/RoadFlow.Pinyin/format/PinyinFormatter.cs
Normal file
@@ -0,0 +1,172 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using RoadFlow.Pinyin.exception;
|
||||
|
||||
namespace RoadFlow.Pinyin.format
|
||||
{
|
||||
/// <summary>
|
||||
/// 拼音格式化
|
||||
/// </summary>
|
||||
public static class PinyinFormatter
|
||||
{
|
||||
/// <summary>
|
||||
/// 将拼音格式化成指定的格式
|
||||
/// </summary>
|
||||
/// <param name="py">待格式化的拼音</param>
|
||||
/// <param name="format">格式</param>
|
||||
/// <see cref="ToneFormat"/>
|
||||
/// <see cref="CaseFormat"/>
|
||||
/// <see cref="VCharFormat"/>
|
||||
/// <returns></returns>
|
||||
public static string Format(string py, PinyinOutputFormat format)
|
||||
{
|
||||
// "v"或"u:"不能添加声调
|
||||
if (ToneFormat.WITH_TONE_MARK == format.GetToneFormat &&
|
||||
(
|
||||
VCharFormat.WITH_V == format.GetVCharFormat
|
||||
|| VCharFormat.WITH_U_AND_COLON == format.GetVCharFormat
|
||||
)
|
||||
)
|
||||
{
|
||||
throw new PinyinException("\"v\"或\"u:\"不能添加声调");
|
||||
}
|
||||
var pinyin = py;
|
||||
switch (format.GetToneFormat)
|
||||
{
|
||||
case ToneFormat.WITHOUT_TONE:
|
||||
// 不带声调
|
||||
var reg = new Regex("[1-5]");
|
||||
pinyin = reg.Replace(pinyin, "");
|
||||
break;
|
||||
case ToneFormat.WITH_TONE_MARK:
|
||||
// 带声调标志
|
||||
pinyin = pinyin.Replace("u:", "v");
|
||||
pinyin = convertToneNumber2ToneMark(pinyin);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (format.GetVCharFormat)
|
||||
{
|
||||
case VCharFormat.WITH_V:
|
||||
// 输出v
|
||||
pinyin = pinyin.Replace("u:", "v");
|
||||
break;
|
||||
case VCharFormat.WITH_U_UNICODE:
|
||||
// 输出ü
|
||||
pinyin = pinyin.Replace("u:", "ü");
|
||||
break;
|
||||
}
|
||||
|
||||
switch (format.GetCaseFormat)
|
||||
{
|
||||
case CaseFormat.UPPERCASE:
|
||||
// 大写
|
||||
pinyin = pinyin.ToUpper();
|
||||
break;
|
||||
case CaseFormat.LOWERCASE:
|
||||
// 小写
|
||||
pinyin = pinyin.ToLower();
|
||||
break;
|
||||
case CaseFormat.CAPITALIZE_FIRST_LETTER:
|
||||
// 首字母大写
|
||||
|
||||
// 不处理单拼音 a e o
|
||||
if (!new List<string> { "a", "e", "o"}.Contains(pinyin.ToLower()))
|
||||
{
|
||||
pinyin = pinyin.Substring(0, 1).ToUpper() + (pinyin.Length == 1 ? "" : pinyin.Substring(1));
|
||||
}
|
||||
break;
|
||||
}
|
||||
return pinyin;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 将拼音的声调数字转换成字符
|
||||
/// </summary>
|
||||
/// <param name="pinyin"></param>
|
||||
/// <returns></returns>
|
||||
private static string convertToneNumber2ToneMark(string pinyin)
|
||||
{
|
||||
var lowerCasePinyinStr = pinyin.ToLower();
|
||||
var reg = new Regex("[a-z]*[1-5]?");
|
||||
if (!reg.IsMatch(lowerCasePinyinStr)) return lowerCasePinyinStr;
|
||||
|
||||
const char defautlCharValue = '$';
|
||||
const int defautlIndexValue = -1;
|
||||
|
||||
var unmarkedVowel = defautlCharValue;
|
||||
var indexOfUnmarkedVowel = defautlIndexValue;
|
||||
|
||||
const char charA = 'a';
|
||||
const char charE = 'e';
|
||||
const string ouStr = "ou";
|
||||
const string allUnmarkedVowelStr = "aeiouv";
|
||||
const string allMarkedVowelStr = "āáăàaēéĕèeīíĭìiōóŏòoūúŭùuǖǘǚǜü";
|
||||
reg = new Regex("[a-z]*[1-5]");
|
||||
if (!reg.IsMatch(lowerCasePinyinStr)) return lowerCasePinyinStr.Replace("v", "ü");
|
||||
|
||||
var tuneNumber = (int)char.GetNumericValue(lowerCasePinyinStr[lowerCasePinyinStr.Length - 1]);
|
||||
|
||||
var indexOfA = lowerCasePinyinStr.IndexOf(charA);
|
||||
var indexOfE = lowerCasePinyinStr.IndexOf(charE);
|
||||
var ouIndex = lowerCasePinyinStr.IndexOf(ouStr, StringComparison.Ordinal);
|
||||
|
||||
if (-1 != indexOfA)
|
||||
{
|
||||
indexOfUnmarkedVowel = indexOfA;
|
||||
unmarkedVowel = charA;
|
||||
}
|
||||
else if (-1 != indexOfE)
|
||||
{
|
||||
indexOfUnmarkedVowel = indexOfE;
|
||||
unmarkedVowel = charE;
|
||||
}
|
||||
else if (-1 != ouIndex)
|
||||
{
|
||||
indexOfUnmarkedVowel = ouIndex;
|
||||
unmarkedVowel = ouStr[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
reg = new Regex("[" + allUnmarkedVowelStr + "]");
|
||||
|
||||
for (var i = lowerCasePinyinStr.Length - 1; i >= 0; i--)
|
||||
{
|
||||
if (!reg.IsMatch(lowerCasePinyinStr[i].ToString())) continue;
|
||||
|
||||
indexOfUnmarkedVowel = i;
|
||||
unmarkedVowel = lowerCasePinyinStr[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (defautlCharValue == unmarkedVowel || defautlIndexValue == indexOfUnmarkedVowel)
|
||||
return lowerCasePinyinStr;
|
||||
|
||||
var rowIndex = allUnmarkedVowelStr.IndexOf(unmarkedVowel);
|
||||
var columnIndex = tuneNumber - 1;
|
||||
|
||||
var vowelLocation = rowIndex * 5 + columnIndex;
|
||||
|
||||
var markedVowel = allMarkedVowelStr[vowelLocation];
|
||||
|
||||
var resultBuffer = new StringBuilder();
|
||||
// 声母
|
||||
resultBuffer.Append(lowerCasePinyinStr.Substring(0, indexOfUnmarkedVowel).Replace("v", "ü"));
|
||||
// 有声调的部分
|
||||
resultBuffer.Append(markedVowel);
|
||||
// 剩下的部分
|
||||
resultBuffer.Append(lowerCasePinyinStr.Substring(indexOfUnmarkedVowel + 1).Replace("v", "ü"));
|
||||
|
||||
var result = resultBuffer.ToString();
|
||||
// 替换声调数字
|
||||
result = new Regex("[0-9]").Replace(result, "");
|
||||
|
||||
return result;
|
||||
// only replace v with ü (umlat) character
|
||||
}
|
||||
}
|
||||
}
|
||||
103
back_end_code/RoadFlow.Pinyin/format/PinyinOutputFormat.cs
Normal file
103
back_end_code/RoadFlow.Pinyin/format/PinyinOutputFormat.cs
Normal file
@@ -0,0 +1,103 @@
|
||||
using System;
|
||||
|
||||
namespace RoadFlow.Pinyin.format
|
||||
{
|
||||
/// <summary>
|
||||
/// 拼音输出格式
|
||||
/// </summary>
|
||||
public class PinyinOutputFormat
|
||||
{
|
||||
// 声调格式
|
||||
// 大小写格式
|
||||
// 字符v的格式
|
||||
|
||||
/// <summary>
|
||||
/// 获取声调格式
|
||||
/// </summary>
|
||||
public ToneFormat GetToneFormat { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取大小写格式
|
||||
/// </summary>
|
||||
public CaseFormat GetCaseFormat { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取字符v的格式
|
||||
/// </summary>
|
||||
public VCharFormat GetVCharFormat { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 使用默认值初始化输出格式
|
||||
/// ToneFormat.WITH_TONE_MARK,
|
||||
/// CaseFormat.LOWERCASE,
|
||||
/// VCharFormat.WITH_U_UNICODE
|
||||
/// </summary>
|
||||
public PinyinOutputFormat()
|
||||
{
|
||||
GetToneFormat = ToneFormat.WITH_TONE_MARK;
|
||||
GetCaseFormat = CaseFormat.LOWERCASE;
|
||||
GetVCharFormat = VCharFormat.WITH_U_UNICODE;
|
||||
}
|
||||
/// <summary>
|
||||
/// 通过构造初始化输入格式
|
||||
/// </summary>
|
||||
/// <param name="toneFormat">声调格式</param>
|
||||
/// <param name="caseFormat">大小写格式</param>
|
||||
/// <param name="vCharFormat">字符V的格式</param>
|
||||
public PinyinOutputFormat(ToneFormat toneFormat, CaseFormat caseFormat, VCharFormat vCharFormat)
|
||||
{
|
||||
SetFormat(toneFormat, caseFormat, vCharFormat);
|
||||
}
|
||||
/// <summary>
|
||||
/// 通过构造初始化输入格式
|
||||
/// </summary>
|
||||
/// <param name="toneFormat">声调格式字符串</param>
|
||||
/// <param name="caseFormat">大小写格式字符串</param>
|
||||
/// <param name="vCharFormat">字符V的格式字符串</param>
|
||||
/// <see cref="ToneFormat"/>
|
||||
/// <see cref="CaseFormat"/>
|
||||
/// <see cref="VCharFormat"/>
|
||||
public PinyinOutputFormat(string toneFormat, string caseFormat, string vCharFormat)
|
||||
{
|
||||
SetFormat(toneFormat, caseFormat, vCharFormat);
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置输入格式
|
||||
/// </summary>
|
||||
/// <param name="toneFormat">声调格式</param>
|
||||
/// <param name="caseFormat">大小写格式</param>
|
||||
/// <param name="vCharFormat">字符V的格式</param>
|
||||
public void SetFormat(ToneFormat toneFormat, CaseFormat caseFormat, VCharFormat vCharFormat)
|
||||
{
|
||||
GetToneFormat = toneFormat;
|
||||
GetCaseFormat = caseFormat;
|
||||
GetVCharFormat = vCharFormat;
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置输入格式
|
||||
/// </summary>
|
||||
/// <param name="toneFormat">声调格式字符串</param>
|
||||
/// <param name="caseFormat">大小写格式字符串</param>
|
||||
/// <param name="vCharFormat">字符V的格式字符串</param>
|
||||
/// <see cref="ToneFormat"/>
|
||||
/// <see cref="CaseFormat"/>
|
||||
/// <see cref="VCharFormat"/>
|
||||
public void SetFormat(string toneFormat, string caseFormat, string vCharFormat)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(toneFormat))
|
||||
{
|
||||
GetToneFormat = (ToneFormat)Enum.Parse(typeof(ToneFormat), toneFormat);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(caseFormat))
|
||||
{
|
||||
GetCaseFormat = (CaseFormat)Enum.Parse(typeof(CaseFormat), caseFormat);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(vCharFormat))
|
||||
{
|
||||
GetVCharFormat = (VCharFormat)Enum.Parse(typeof(VCharFormat), vCharFormat);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
21
back_end_code/RoadFlow.Pinyin/format/ToneFormat.cs
Normal file
21
back_end_code/RoadFlow.Pinyin/format/ToneFormat.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
namespace RoadFlow.Pinyin.format
|
||||
{
|
||||
/// <summary>
|
||||
/// 声调格式
|
||||
/// </summary>
|
||||
public enum ToneFormat
|
||||
{
|
||||
/// <summary>
|
||||
/// 带声调标志
|
||||
/// </summary>
|
||||
WITH_TONE_MARK,
|
||||
/// <summary>
|
||||
/// 不带声调
|
||||
/// </summary>
|
||||
WITHOUT_TONE,
|
||||
/// <summary>
|
||||
/// 带声调数字值
|
||||
/// </summary>
|
||||
WITH_TONE_NUMBER
|
||||
}
|
||||
}
|
||||
21
back_end_code/RoadFlow.Pinyin/format/VCharFormat.cs
Normal file
21
back_end_code/RoadFlow.Pinyin/format/VCharFormat.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
namespace RoadFlow.Pinyin.format
|
||||
{
|
||||
/// <summary>
|
||||
/// V(ü)字符格式
|
||||
/// </summary>
|
||||
public enum VCharFormat
|
||||
{
|
||||
/// <summary>
|
||||
/// 将 ü 输出为 u:
|
||||
/// </summary>
|
||||
WITH_U_AND_COLON,
|
||||
/// <summary>
|
||||
/// 将 ü 输出为 v
|
||||
/// </summary>
|
||||
WITH_V,
|
||||
/// <summary>
|
||||
/// 将 ü 输出为ü
|
||||
/// </summary>
|
||||
WITH_U_UNICODE
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// <autogenerated />
|
||||
using System;
|
||||
using System.Reflection;
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v5.0", FrameworkDisplayName = "")]
|
||||
@@ -0,0 +1,23 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 此代码由工具生成。
|
||||
// 运行时版本:4.0.30319.42000
|
||||
//
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
||||
// 重新生成代码,这些更改将会丢失。
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("RoadFlow.Pinyin")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("RoadFlow.Pinyin")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("RoadFlow.Pinyin")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
// 由 MSBuild WriteCodeFragment 类生成。
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
02797b3b1ac008042c71232e8b194fcdfbf705c6
|
||||
@@ -0,0 +1,10 @@
|
||||
is_global = true
|
||||
build_property.TargetFramework = net5.0
|
||||
build_property.TargetPlatformMinVersion =
|
||||
build_property.UsingMicrosoftNETSdkWeb =
|
||||
build_property.ProjectTypeGuids =
|
||||
build_property.PublishSingleFile =
|
||||
build_property.IncludeAllContentForSelfExtract =
|
||||
build_property._SupportedPlatformList = Android,iOS,Linux,macOS,Windows
|
||||
build_property.RootNamespace = RoadFlow.Pinyin
|
||||
build_property.ProjectDir = D:\WORK\g公司\codes\ewide_core_flow\back_end_code\RoadFlow.Pinyin\
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,11 @@
|
||||
H:\在家办公2\ewide_core-WorkOrderSys\ewide_core\Api\RoadFlow\RoadFlow.Pinyin\bin\Debug\net5.0\RoadFlow.Pinyin.deps.json
|
||||
H:\在家办公2\ewide_core-WorkOrderSys\ewide_core\Api\RoadFlow\RoadFlow.Pinyin\bin\Debug\net5.0\RoadFlow.Pinyin.dll
|
||||
H:\在家办公2\ewide_core-WorkOrderSys\ewide_core\Api\RoadFlow\RoadFlow.Pinyin\bin\Debug\net5.0\ref\RoadFlow.Pinyin.dll
|
||||
H:\在家办公2\ewide_core-WorkOrderSys\ewide_core\Api\RoadFlow\RoadFlow.Pinyin\bin\Debug\net5.0\RoadFlow.Pinyin.pdb
|
||||
H:\在家办公2\ewide_core-WorkOrderSys\ewide_core\Api\RoadFlow\RoadFlow.Pinyin\obj\Debug\net5.0\RoadFlow.Pinyin.GeneratedMSBuildEditorConfig.editorconfig
|
||||
H:\在家办公2\ewide_core-WorkOrderSys\ewide_core\Api\RoadFlow\RoadFlow.Pinyin\obj\Debug\net5.0\RoadFlow.Pinyin.AssemblyInfoInputs.cache
|
||||
H:\在家办公2\ewide_core-WorkOrderSys\ewide_core\Api\RoadFlow\RoadFlow.Pinyin\obj\Debug\net5.0\RoadFlow.Pinyin.AssemblyInfo.cs
|
||||
H:\在家办公2\ewide_core-WorkOrderSys\ewide_core\Api\RoadFlow\RoadFlow.Pinyin\obj\Debug\net5.0\RoadFlow.Pinyin.csproj.CoreCompileInputs.cache
|
||||
H:\在家办公2\ewide_core-WorkOrderSys\ewide_core\Api\RoadFlow\RoadFlow.Pinyin\obj\Debug\net5.0\RoadFlow.Pinyin.dll
|
||||
H:\在家办公2\ewide_core-WorkOrderSys\ewide_core\Api\RoadFlow\RoadFlow.Pinyin\obj\Debug\net5.0\ref\RoadFlow.Pinyin.dll
|
||||
H:\在家办公2\ewide_core-WorkOrderSys\ewide_core\Api\RoadFlow\RoadFlow.Pinyin\obj\Debug\net5.0\RoadFlow.Pinyin.pdb
|
||||
@@ -0,0 +1,4 @@
|
||||
// <autogenerated />
|
||||
using System;
|
||||
using System.Reflection;
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v5.0", FrameworkDisplayName = "")]
|
||||
@@ -0,0 +1,23 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 此代码由工具生成。
|
||||
// 运行时版本:4.0.30319.42000
|
||||
//
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
||||
// 重新生成代码,这些更改将会丢失。
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("RoadFlow.Pinyin")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("RoadFlow.Pinyin")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("RoadFlow.Pinyin")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
// 由 MSBuild WriteCodeFragment 类生成。
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
936415f9a1eb407199571fe1359444b053bae617
|
||||
@@ -0,0 +1,10 @@
|
||||
is_global = true
|
||||
build_property.TargetFramework = net5.0
|
||||
build_property.TargetPlatformMinVersion =
|
||||
build_property.UsingMicrosoftNETSdkWeb =
|
||||
build_property.ProjectTypeGuids =
|
||||
build_property.PublishSingleFile =
|
||||
build_property.IncludeAllContentForSelfExtract =
|
||||
build_property._SupportedPlatformList = Android,iOS,Linux,macOS,Windows
|
||||
build_property.RootNamespace = RoadFlow.Pinyin
|
||||
build_property.ProjectDir = H:\在家办公2\ewide_core-master\ewide_core\Api\RoadFlow.Pinyin\
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
1b094c0bb61fcec63bcd3a15e30494d5aecafd2b
|
||||
@@ -0,0 +1,12 @@
|
||||
H:\在家办公2\ewide_core-master\ewide_core\Api\RoadFlow.Pinyin\bin\Release\net5.0\RoadFlow.Pinyin.deps.json
|
||||
H:\在家办公2\ewide_core-master\ewide_core\Api\RoadFlow.Pinyin\bin\Release\net5.0\RoadFlow.Pinyin.dll
|
||||
H:\在家办公2\ewide_core-master\ewide_core\Api\RoadFlow.Pinyin\bin\Release\net5.0\ref\RoadFlow.Pinyin.dll
|
||||
H:\在家办公2\ewide_core-master\ewide_core\Api\RoadFlow.Pinyin\bin\Release\net5.0\RoadFlow.Pinyin.pdb
|
||||
H:\在家办公2\ewide_core-master\ewide_core\Api\RoadFlow.Pinyin\obj\Release\net5.0\RoadFlow.Pinyin.csproj.AssemblyReference.cache
|
||||
H:\在家办公2\ewide_core-master\ewide_core\Api\RoadFlow.Pinyin\obj\Release\net5.0\RoadFlow.Pinyin.GeneratedMSBuildEditorConfig.editorconfig
|
||||
H:\在家办公2\ewide_core-master\ewide_core\Api\RoadFlow.Pinyin\obj\Release\net5.0\RoadFlow.Pinyin.AssemblyInfoInputs.cache
|
||||
H:\在家办公2\ewide_core-master\ewide_core\Api\RoadFlow.Pinyin\obj\Release\net5.0\RoadFlow.Pinyin.AssemblyInfo.cs
|
||||
H:\在家办公2\ewide_core-master\ewide_core\Api\RoadFlow.Pinyin\obj\Release\net5.0\RoadFlow.Pinyin.csproj.CoreCompileInputs.cache
|
||||
H:\在家办公2\ewide_core-master\ewide_core\Api\RoadFlow.Pinyin\obj\Release\net5.0\RoadFlow.Pinyin.dll
|
||||
H:\在家办公2\ewide_core-master\ewide_core\Api\RoadFlow.Pinyin\obj\Release\net5.0\ref\RoadFlow.Pinyin.dll
|
||||
H:\在家办公2\ewide_core-master\ewide_core\Api\RoadFlow.Pinyin\obj\Release\net5.0\RoadFlow.Pinyin.pdb
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,65 @@
|
||||
{
|
||||
"format": 1,
|
||||
"restore": {
|
||||
"D:\\WORK\\g公司\\codes\\ewide_core_flow\\back_end_code\\RoadFlow.Pinyin\\RoadFlow.Pinyin.csproj": {}
|
||||
},
|
||||
"projects": {
|
||||
"D:\\WORK\\g公司\\codes\\ewide_core_flow\\back_end_code\\RoadFlow.Pinyin\\RoadFlow.Pinyin.csproj": {
|
||||
"version": "1.0.0",
|
||||
"restore": {
|
||||
"projectUniqueName": "D:\\WORK\\g公司\\codes\\ewide_core_flow\\back_end_code\\RoadFlow.Pinyin\\RoadFlow.Pinyin.csproj",
|
||||
"projectName": "RoadFlow.Pinyin",
|
||||
"projectPath": "D:\\WORK\\g公司\\codes\\ewide_core_flow\\back_end_code\\RoadFlow.Pinyin\\RoadFlow.Pinyin.csproj",
|
||||
"packagesPath": "C:\\Users\\z1303\\.nuget\\packages\\",
|
||||
"outputPath": "D:\\WORK\\g公司\\codes\\ewide_core_flow\\back_end_code\\RoadFlow.Pinyin\\obj\\",
|
||||
"projectStyle": "PackageReference",
|
||||
"fallbackFolders": [
|
||||
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
|
||||
],
|
||||
"configFilePaths": [
|
||||
"C:\\Users\\z1303\\AppData\\Roaming\\NuGet\\NuGet.Config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
|
||||
],
|
||||
"originalTargetFrameworks": [
|
||||
"net5.0"
|
||||
],
|
||||
"sources": {
|
||||
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
|
||||
"https://api.nuget.org/v3/index.json": {}
|
||||
},
|
||||
"frameworks": {
|
||||
"net5.0": {
|
||||
"targetAlias": "net5.0",
|
||||
"projectReferences": {}
|
||||
}
|
||||
},
|
||||
"warningProperties": {
|
||||
"warnAsError": [
|
||||
"NU1605"
|
||||
]
|
||||
}
|
||||
},
|
||||
"frameworks": {
|
||||
"net5.0": {
|
||||
"targetAlias": "net5.0",
|
||||
"imports": [
|
||||
"net461",
|
||||
"net462",
|
||||
"net47",
|
||||
"net471",
|
||||
"net472",
|
||||
"net48"
|
||||
],
|
||||
"assetTargetFallback": true,
|
||||
"warn": true,
|
||||
"frameworkReferences": {
|
||||
"Microsoft.NETCore.App": {
|
||||
"privateAssets": "all"
|
||||
}
|
||||
},
|
||||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\5.0.400\\RuntimeIdentifierGraph.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
|
||||
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
|
||||
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
|
||||
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
|
||||
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\z1303\.nuget\packages\;C:\Program Files\dotnet\sdk\NuGetFallbackFolder</NuGetPackageFolders>
|
||||
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
|
||||
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.11.0</NuGetToolVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||
<SourceRoot Include="C:\Users\z1303\.nuget\packages\" />
|
||||
<SourceRoot Include="C:\Program Files\dotnet\sdk\NuGetFallbackFolder\" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
71
back_end_code/RoadFlow.Pinyin/obj/project.assets.json
Normal file
71
back_end_code/RoadFlow.Pinyin/obj/project.assets.json
Normal file
@@ -0,0 +1,71 @@
|
||||
{
|
||||
"version": 3,
|
||||
"targets": {
|
||||
"net5.0": {}
|
||||
},
|
||||
"libraries": {},
|
||||
"projectFileDependencyGroups": {
|
||||
"net5.0": []
|
||||
},
|
||||
"packageFolders": {
|
||||
"C:\\Users\\z1303\\.nuget\\packages\\": {},
|
||||
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder": {}
|
||||
},
|
||||
"project": {
|
||||
"version": "1.0.0",
|
||||
"restore": {
|
||||
"projectUniqueName": "D:\\WORK\\g公司\\codes\\ewide_core_flow\\back_end_code\\RoadFlow.Pinyin\\RoadFlow.Pinyin.csproj",
|
||||
"projectName": "RoadFlow.Pinyin",
|
||||
"projectPath": "D:\\WORK\\g公司\\codes\\ewide_core_flow\\back_end_code\\RoadFlow.Pinyin\\RoadFlow.Pinyin.csproj",
|
||||
"packagesPath": "C:\\Users\\z1303\\.nuget\\packages\\",
|
||||
"outputPath": "D:\\WORK\\g公司\\codes\\ewide_core_flow\\back_end_code\\RoadFlow.Pinyin\\obj\\",
|
||||
"projectStyle": "PackageReference",
|
||||
"fallbackFolders": [
|
||||
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
|
||||
],
|
||||
"configFilePaths": [
|
||||
"C:\\Users\\z1303\\AppData\\Roaming\\NuGet\\NuGet.Config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
|
||||
],
|
||||
"originalTargetFrameworks": [
|
||||
"net5.0"
|
||||
],
|
||||
"sources": {
|
||||
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
|
||||
"https://api.nuget.org/v3/index.json": {}
|
||||
},
|
||||
"frameworks": {
|
||||
"net5.0": {
|
||||
"targetAlias": "net5.0",
|
||||
"projectReferences": {}
|
||||
}
|
||||
},
|
||||
"warningProperties": {
|
||||
"warnAsError": [
|
||||
"NU1605"
|
||||
]
|
||||
}
|
||||
},
|
||||
"frameworks": {
|
||||
"net5.0": {
|
||||
"targetAlias": "net5.0",
|
||||
"imports": [
|
||||
"net461",
|
||||
"net462",
|
||||
"net47",
|
||||
"net471",
|
||||
"net472",
|
||||
"net48"
|
||||
],
|
||||
"assetTargetFallback": true,
|
||||
"warn": true,
|
||||
"frameworkReferences": {
|
||||
"Microsoft.NETCore.App": {
|
||||
"privateAssets": "all"
|
||||
}
|
||||
},
|
||||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\5.0.400\\RuntimeIdentifierGraph.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
8
back_end_code/RoadFlow.Pinyin/obj/project.nuget.cache
Normal file
8
back_end_code/RoadFlow.Pinyin/obj/project.nuget.cache
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"version": 2,
|
||||
"dgSpecHash": "IBXahxnPCV8hRG8xDDzfPanyiEA1fvpMwwDiq4ZFl9jEZQEHFjQN/eFs1WSlirNy6f5topzOjBpB0U3g5d4bew==",
|
||||
"success": true,
|
||||
"projectFilePath": "D:\\WORK\\g公司\\codes\\ewide_core_flow\\back_end_code\\RoadFlow.Pinyin\\RoadFlow.Pinyin.csproj",
|
||||
"expectedPackageFiles": [],
|
||||
"logs": []
|
||||
}
|
||||
Reference in New Issue
Block a user