Chinese 0.8.1-alpha

This is a prerelease version of Chinese.
dotnet add package Chinese --version 0.8.1-alpha
NuGet\Install-Package Chinese -Version 0.8.1-alpha
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="Chinese" Version="0.8.1-alpha" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Chinese --version 0.8.1-alpha
#r "nuget: Chinese, 0.8.1-alpha"
#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 Chinese as a Cake Addin
#addin nuget:?package=Chinese&version=0.8.1-alpha&prerelease

// Install Chinese as a Cake Tool
#tool nuget:?package=Chinese&version=0.8.1-alpha&prerelease

Chinese

中文解析通用工具。包括拼音,简繁转换,数字读法,货币读法。

<br/>

安装

通过 Nuget 使用 .NET CLI 安装:

dotnet add package Chinese

词库安装:

dotnet add package Chinese.Words

<br/>

版本更新

版本计划:0.8.1-alpha

欢迎仅使用 数字转换 / 货币转换 功能的项目升级试用。

  • 大量逻辑优化,优化内存使用。

  • 提高 数字转换 / 货币转换 性能,修复一些 BUG(Issues: #10)。

    Lexicon.Currency.GetString(0.1m);  // 零元一角整
    
  • 修复 中文掺杂字母或拼音 转换时缺少 空格 的问题(Issues: #12)。

  • 数值读法增加 小数 读法。

  • 提供外部词库支持,现可使用 数据库 作为外部词库源。(结构需优化)

  • 词库编译生成器(解析 文本结构Sqlite 数据库文件,用户可以通过文本结构提交 PR 贡献)。

版本:0.5.0

  • 简繁转换性能优化(NETStandard2.0+NET5.0+,通常情况耗时减少约 90%)。

  • 计量读法性能优化(耗时减少约 85%)。

  • 修复计量读法尾零转换错误问题:

    var wrong = ChineseCurrency.GetString(10_0000);  // 错误:一十万零元整
    var right = ChineseCurrency.GetString(10_0000);  // 正确:一十万元整
    

版本:4.5.0

  • 更新部分字默认拼音。
  • 发布测试词库 Chinese.Words(v0.0.1)。

版本:4.1.0

  • 按词频为单字提供默认拼音。

<br/>

拼音

// "mian3 fei4,kua4 ping2 tai2,kai1 yuan2!"
Pinyin.GetString("免费,跨平台,开源!", PinyinFormat.Default);
// "mian fei,kua ping tai,kai yuan!"
Pinyin.GetString("免费,跨平台,开源!", PinyinFormat.WithoutTone);
// "miǎn fèi,kuà píng tái,kāi yuán!"
Pinyin.GetString("免费,跨平台,开源!", PinyinFormat.Phonetic);
// "mf,kpt,ky!"
Pinyin.GetString("免费,跨平台,开源!", PinyinFormat.InitialConsonant);

<br/>

简繁转换

ChineseConverter.ToTraditional("免费,跨平台,开源!");    // "免費,跨平臺,開源!"
ChineseConverter.ToSimplified("免費,跨平臺,開源!");     // "免费,跨平台,开源!"

<br/>

数字读法

NumberMode 选项 描述 示例
Default 流行读法,亿级以上使用 千亿 万亿 等单位;<br />不省略第一个 前的 ;<br/>小写读法。 -
Classical 经典读法,亿级以上使用 等单位 -
Concise 简洁读法,省略第一个 前的 10_0001 读作 十万零一
Upper 大写读法 1 读作

计量读法

var lexicon = Lexicon.Number;
lexicon.GetString(10_0001);  // "一十万零一"
lexicon.GetString(10_0101);  // "一十万零一百零一"
lexicon.GetString(10_1001);  // "一十万一千零一"
lexicon.GetString(10_1010);  // "一十万一千零一十"

lexicon.GetNumber("一十万零一");        // 10_0001
lexicon.GetNumber("一十万零一百零一");  // 10_0101
lexicon.GetNumber("一十万一千零一");    // 10_1001
lexicon.GetNumber("一十万一千零一十");  // 10_1010
大数读法
流行读法

亿级以上使用(万亿、亿亿、万亿亿、亿亿亿、万亿亿亿):

var lexicon = Lexicon.Number;

// "一万亿亿亿二千三百四十五亿亿亿六千七百八十九万亿亿零一百二十三亿亿四千五百六十七万亿八千九百零一亿二千三百四十五万六千七百八十九"
lexicon.GetString(1_2345_6789_0123_4567_8901_2345_6789m);

// 12345678901234567890123456789
lexicon.GetNumber("一万亿亿亿二千三百四十五亿亿亿六千七百八十九万亿亿零一百二十三亿亿四千五百六十七万亿八千九百零一亿二千三百四十五万六千七百八十九");
经典读法

亿级以上使用(兆、京、垓、秭、穰):

var lexicon = Lexicon.NumberWith(NumberMode.Classical);

// "一穰二千三百四十五秭六千七百八十九垓零一百二十三京四千五百六十七兆八千九百零一亿二千三百四十五万六千七百八十九"
lexicon.GetString(1_2345_6789_0123_4567_8901_2345_6789m);

// 12345678901234567890123456789
lexicon.GetNumber("一穰二千三百四十五秭六千七百八十九垓零一百二十三京四千五百六十七兆八千九百零一亿二千三百四十五万六千七百八十九");

<br/>

编号读法

var lexicon = Lexicon.NumberWith(NumberMode.Code);
lexicon.GetString(10_0001);  // "一〇〇〇〇一"
lexicon.GetString(10_0101);  // "一〇〇一〇一"
lexicon.GetString(10_1001);  // "一〇一〇〇一"
lexicon.GetString(10_1010);  // "一〇一〇一〇"

lexicon.GetNumber("一〇〇〇〇一");  // 10_0001
lexicon.GetNumber("一〇〇一〇一");  // 10_0101
lexicon.GetNumber("一〇一〇〇一");  // 10_1001
lexicon.GetNumber("一〇一〇一〇");  // 10_1010

<br/>

货币读法

var lexicon = Lexicon.Currency;

lexicon.GetString(1);        // "一元整"
lexicon.GetString(10_0001);  // "一十万零一元整"
lexicon.GetString(10_0101);  // "一十万零一百零一元整"
lexicon.GetString(10_1001);  // "一十万一千零一元整"
lexicon.GetString(10_1010);  // "一十万一千零一十元整"
lexicon.GetString(10_0001.2m);   // "一十万零一元二角整"
lexicon.GetString(10_0001.23m);  // "一十万零一元二角三分"
lexicon.GetString(10_0001.03m);  // "一十万零一元零三分"

lexicon.GetNumber("一元整");                // 1
lexicon.GetNumber("一十万零一元整");        // 10_0001
lexicon.GetNumber("一十万零一百零一元整");  // 10_0101
lexicon.GetNumber("一十万一千零一元整");    // 10_1001
lexicon.GetNumber("一十万一千零一十元整");  // 10_1010
lexicon.GetNumber("一十万零一元二角整");    // 10_0001.2m
lexicon.GetNumber("一十万零一元二角三分");  // 10_0001.23m
lexicon.GetNumber("一十万零一元零三分");    // 10_0001.03m

<br/>

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 is compatible.  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 is compatible.  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.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Chinese:

Package Downloads
XExten.Advance

XExten包的优化升级版本,后期只会更新这个包,不在维护XExten包

Traceless.Utils

OPQ Sdk For Netcore,Part Of Util

Chinese.Words

中文词库。

GitHub repositories (3)

Showing the top 3 popular GitHub repositories that depend on Chinese:

Repository Stars
stevencohn/OneMore
A OneNote add-in with simple, yet powerful and useful features
CrazyZhang666/GTA5OnlineTools
GTA5线上小助手
oncemi/OnceMi.Framework
基于.NET 7和Vue 2开发的企业级前后端分离权限管理开发框架(后台管理系统),具有组织管理、角色管理、用户管理、菜单管理、授权管理、计划任务、文件管理等功能。支持国内外多种流行数据库,支持IdentityServer4认证中心。
Version Downloads Last updated
0.8.1-alpha 76 5/6/2024
0.5.0 10,974 5/8/2022
0.4.6 37,550 5/25/2021
0.4.5 535 5/25/2021
0.4.2 340 5/21/2021
0.4.1 379 5/20/2021
0.4.0 358 5/20/2021
0.3.6 3,001 10/30/2020
0.3.5 588 10/20/2020
0.3.0 419 10/20/2020
0.2.5 6,612 6/28/2020
0.2.0 436 6/17/2020
0.1.5 440 6/17/2020
0.1.3 431 6/17/2020
0.1.2 468 6/17/2020
0.1.1 531 6/16/2020
0.0.9 503 6/16/2020
0.0.8 506 6/16/2020
0.0.7 442 6/16/2020
0.0.6 448 6/16/2020
0.0.5 519 6/15/2020
0.0.1 497 6/15/2020