PinyinM.NET 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package PinyinM.NET --version 1.0.1                
NuGet\Install-Package PinyinM.NET -Version 1.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PinyinM.NET" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PinyinM.NET --version 1.0.1                
#r "nuget: PinyinM.NET, 1.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install PinyinM.NET as a Cake Addin
#addin nuget:?package=PinyinM.NET&version=1.0.1

// Install PinyinM.NET as a Cake Tool
#tool nuget:?package=PinyinM.NET&version=1.0.1                

Pinyin.NET

Pinyin.NET 汉字转换为拼音 拼音模糊搜索

1. 汉字转换为拼音

将汉字转换为带音调或不带音调的拼音 返回值为IEnumerable<IEnumerable<string>>,每个IEnumerable<string>为一个汉字的拼音,每个string为一个发音 如果输入的字符不是汉字,则返回值其本身

例如"到底"返回值为[["dao"], ["di","de"]]

PinyinProcessor pinyinProcessor = new PinyinProcessor();//不带音调
//PinyinProcessor pinyinProcessor = new PinyinProcessor(PinyinFormat.WithToneMark); //带音调
pinyinProcessor.GetPinyin("到底");//[["dao"], ["di","de"]]

2. 拼音模糊搜索

在给的的数据源中的指定属性上进行拼音模糊搜索 支持拼音全拼 首字母 全拼和首字母混合搜索 (支持多音字)

PinyinProcessor pinyinProcessor = new PinyinProcessor(PinyinFormat.WithToneMark);
var enumerable = pinyinProcessor.GetPinyin("尝试111到底是");
list.Add(new MyClass
{
    Name = "尝试111到底是",
    Pinyin = enumerable});
list.Add(new MyClass
{
    Name = "但是等待",
    Pinyin = pinyinProcessor.GetPinyin("但是等待")});
PinyinSearcher pinyinSearcher = new PinyinSearcher(list, "Pinyin");
var search = pinyinSearcher.Search("ddi");
foreach (var searchResult in search)
{
    Console.WriteLine($" {searchResult.Weight}  {((MyClass)searchResult.Source).Name}");
}
//输出 6  尝试111到底是

更新日志

1.0.1

  1. 优化 包含英文的字母的拼音转换
  2. 新增 泛型搜索类型
  3. 优化 添加对字典以及KeyValuePair支持
  4. 优化 权重计算
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 82 10/26/2024
1.0.3 119 4/27/2024
1.0.2 103 4/17/2024
1.0.1 98 4/16/2024
1.0.0 102 4/15/2024

优化 包含英文的字母的拼音转换
           新增 泛型搜索类型
           优化 添加对字典以及KeyValuePair支持
           优化 权重计算