Coder Social home page Coder Social logo

hstarorg / tinypinyin.net Goto Github PK

View Code? Open in Web Editor NEW
203.0 11.0 47.0 66 KB

适用于.Net平台的快速、低内存占用的汉字转拼音库。核心算法来自TinyPinyin(https://github.com/promeG/TinyPinyin)

Home Page: https://www.nuget.org/packages/TinyPinyin/

License: MIT License

C# 100.00%

tinypinyin.net's Introduction

TinyPinyin.Net

适用于.Net平台的快速、低内存占用的汉字转拼音库。核心算法来自TinyPinyin(https://github.com/promeG/TinyPinyin)

特性

  1. 生成的拼音不包含声调,均为大写
  2. 执行效率高
  3. 低内存占用
  4. 支持获取简码(拼音首字母)

如何使用

只提供足够简洁的API,简单易用。

安装

使用 NuGet 搜索 TinyPinyin 进行安装,也可直接执行命令: Install-Package TinyPinyin

使用

/// <summary>
/// 获取单个字符的拼音
/// </summary>
/// <param name="c"></param>
/// <returns></returns>
string PinyinHelper.GetPinyin(char c)

/// <summary>
/// 获取文本字符串的拼音,允许设定拼音分割符
/// </summary>
/// <param name="text">要获取拼音的文本</param>
/// <param name="separator">拼音分割符,默认空格</param>
/// <returns></returns>
string PinyinHelper.GetPinyin(string text, string separator = " ")

/// <summary>
/// 获取拼音首字母
/// </summary>
/// <param name="str"></param>
/// <param name="separator">拼音分割符,默认空字符串(不分割)</param>
/// <returns></returns>
string GetPinyinInitials(string str, string separator = "")

/// <summary>
/// 判断单个字符是否是中文
/// </summary>
/// <param name="c"></param>
/// <returns></returns>
bool IsChinese(char c)

感谢

感谢 @promeG 提供的 Java版本

tinypinyin.net's People

Contributors

hstarorg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tinypinyin.net's Issues

Add support for .NET Standard

考虑到这个库没有任何依赖项,是否可以考虑把Framework依赖版本改为.NET Standard 1.0?这样一来目前所有仍被微软支持的.NET平台都可以使用本库,而无需担心兼容性问题。
.NET Standard 1.0所支持的全部平台:根据[1]

  • .NET Core 1.0
  • .NET Framework 4.5
  • Mono
  • Xamarin.iOS
  • Xamarin.Android
  • Universal Windows Platform 10
  • Windows 8.0
  • Windows Phone 8.1
  • Windows Phone Silverlight 8.0

具体修改流程请参考本文:https://docs.microsoft.com/en-us/dotnet/core/packages

无法通过nuget添加TinyPinyin.Core

Attempting to gather dependency information for package 'TinyPinyin.Core.0.1.0' with respect to project 'SuiHanIME', targeting '.NETPortable,Version=v4.5,Profile=Profile7'
GET https://www.nuget.org/api/v2/Packages(Id='TinyPinyin.Core',Version='0.1.0')
OK https://www.nuget.org/api/v2/Packages(Id='TinyPinyin.Core',Version='0.1.0') 761ms
Total number of results gathered : 2
Gathering dependency information took 806.73 ms
Summary of time taken to gather dependencies per source :
https://www.nuget.org/api/v2/ - 776.36 ms
Attempting to resolve dependencies for package 'TinyPinyin.Core.0.1.0' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'TinyPinyin.Core.0.1.0'
Resolved actions to install package 'TinyPinyin.Core.0.1.0'
Retrieving package 'TinyPinyin.Core 0.1.0' from 'Official NuGet Gallery'.
GET https://www.nuget.org/api/v2/package/TinyPinyin.Core/0.1.0
OK https://www.nuget.org/api/v2/package/TinyPinyin.Core/0.1.0 3139ms
Acquiring lock for the installation of TinyPinyin.Core 0.1.0
Acquired lock for the installation of TinyPinyin.Core 0.1.0
Installing TinyPinyin.Core 0.1.0.
Completed installation of TinyPinyin.Core 0.1.0
For adding package 'TinyPinyin.Core.0.1.0' to project 'SuiHanIME' that targets 'portable45-net45+win8'.
Install failed. Rolling back...
Package 'TinyPinyin.Core.0.1.0' does not exist in project 'SuiHanIME'
Package 'TinyPinyin.Core.0.1.0' does not exist in folder '/Volumes/secondDisk/xamarin_workspace/SuiHanIME/packages'
Executing nuget actions took 3.91 sec
Could not install package 'TinyPinyin.Core 0.1.0'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile7', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.