取得汉字的首字母

C#按汉字拼音首字母排序 可参考以下博客。 C# 使用微软的Visual Studio International Pack 类库提取汉字拼音首字母 - 影子科技 - 博客园 http://www.cnblogs.com/yazdao/archive/2011/06/04/2072488.html C#汉字转换拼音技术详解(高性能) - 历史的驱动 - 博客园 http://www.cnblogs.com/lili 阅读详情
private static string[] character = 
    {"吖", "八", "嚓", "咑", "妸", "发", "旮", "铪", "讥", "咔", "垃", "嘸",
     "拏", "噢", "妑", "七", "亽", "仨", "他", "哇", "夕", "丫", "帀", "咗"};
private static string[] letters = 
    {"", "A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L",
     "M", "N", "O", "P", "Q", "R", "S", "T", "W", "X", "Y", "Z"};

internal static string GetPhonetic(string str)
{
    string retstr;
    int loop;

    loop = str.Length;
    retstr = "";

    for (int i = 0; i < loop; i++)
    {
        for (int j = 0; j < character.Length; j++)
        {
            // 按照汉字/拼音首字母对照表,逐个比较
            if (str.CompareTo(character[j]) < 0)
            {
                if (j == 0)
                {
                    retstr = retstr.Insert(retstr.Length, str.Substring(0, 1));
                }
                else
                {
                    // 得到首字母
                    retstr = retstr.Insert(retstr.Length, letters[j]);
                }

                str = str.Substring(1);
                break;
            }
        }
    }

    return retstr;
}

 

php获取汉字首字母方法 function getFirstCharter($str){ if(empty($str)){return ‘’;} fchar=ord(fchar=ord(fchar=ord(str{0}); if(KaTeX parse error: Expected 'EOF', got '&' at position 16: fchar>=ord('A')&̲&fchar<=ord(‘z’)) return strtoupper($str{0}); s1=iconv(′UTF− 阅读详情

相关推荐

Python解析骑行fit文件:从数据缺失到完整记录

本文详细介绍了如何利用Python解析和处理骑行FIT文件,解决数据缺失问题。通过使用fitparse库读取二进制FIT文件,并结合Garmin FitCSVTool进行格式转换,指导读者一步步诊断数据完整性、设计心率修补方案,并最终生成完整的骑行记录文件。该方法为骑行爱好者提供了灵活的数据修复与自定义分析能力。

weixin_29062255的博客 462

用C#写的将汉字转换为拼音首字母

 近日需要做一个医院的项目,要求用拼音来检索药品名称,就需要一个将汉字转换成拼音首字母序列的功能,网上现有的许多类似的功能只能是做对常用字进行检索,但对一些冷辟字就不行了,今天看了一个用SQL Server写的一个转换函数,我把它转换成C#的,下面是汉字转换成首字母列的类的代码:public class RealHanzi2Py    ...{        public RealHanz

飞翔猫 2009

第十六届蓝桥杯大赛软件赛(编程类)知识点大纲

难度:[1-3]难度:[1-5]难度:[1-3]难度:[2-5]难度:[1-5]

Future_yzx的博客 4119

汉字转拼音首字

CLOSE all Clear USE ptype * 商品名称 DO while .not.eof()  REPLACE fullname WITH strtran(ALLTRIM(fullname),"(","(")  REPLACE fullname WITH strtran(ALLTRIM(fullname),")",")")  REPLACE usercode with u

徐虎的专栏 1314

DeepSeek-OCR 本地部署使用教程(附完整环境配置与推理示例)

DeepSeek-OCR是由DeepSeek AI推出的开源OCR模型,支持高精度文档识别与结构化输出(如Markdown转换)。本文提供了详细的本地部署指南,包括系统要求(推荐Linux+A100 GPU)、环境配置(Python 3.12.9+PyTorch 2.6.0+CUDA 11.8)、模型下载及两种推理方式:高性能的vLLM(适合批量处理)和灵活的Transformers(适合调试)。支持多种分辨率模式和提示词模板,适用于合同识别、PDF转换等场景。常见问题包括显存优化和性能调优建议。

qq_58607032的博客 6737

华为L420X/L540X信创笔记本从麒麟系统安装Windows ARM版实操指南

在计算机系统生态中,指令集架构决定了软件运行的基础,其中ARM作为精简指令集(RISC)的代表,与x86的复杂指令集(CISC)存在根本差异,因此操作系统与驱动的兼容性成为软硬件协同的关键。ARM架构处理器凭借低功耗与高能效比,在移动计算和桌面领域持续扩展,微软也为此提供了专用的Windows ARM版本。对于信创笔记本用户而言,当专业软件、考试环境或内部工具仅支持Windows平台时,在ARM设备上完成系统切换便具有明确的工程实践价值。本文以华为L420X/L540X搭载麒麟9000C芯片的信创笔记本为实

weixin_30444111的博客 737

汉字转拼音

change by xuhu 2021.03.15 SET CENTURY ON SET DEFAULT TO CLOSE all Clear USE ptype 商品名称 DO while .not.eof() REPLACE fullname WITH strtran(ALLTRIM(fullname),"(","(") REPLACE fullname WITH strtran(ALLTRIM(fullname),")",")") REPLACE usercode with upper(MY..

徐虎的专栏 322

UE5网络模块实战:属性复制、RPC与联机开发踩坑指南

多人联机开发中,网络同步是核心难题。UE5网络模块以服务器权威为基础,通过Actor复制、RPC和所有权机制实现多端状态一致。理解属性复制与OnRep回调、区分Server/Client/Multicast RPC的适用场景,是构建稳定联机架构的关键。本文结合数字孪生与多端协作场景,探讨如何将渲染与逻辑分离,并针对打包后网络失效、端口防火墙、崩溃排查等工程实践问题给出解决方案。通过蓝图接口解耦表现层,利用C++创建StaticMesh组件实现服务器逻辑与客户端表现分离,同时注意专用服务器不加载渲染依赖(如D

weixin_29010003的博客 275

Qt汉字得到汉字拼音首字母

Qt汉字字符串得到拼音首字母,网上找了些资料,发现有错误,自己重新改,在 成了Qt4.8, MinGw编译器下编译运行成功.   包含一个字母表和一个函数.   输入:数字\字母\汉字组成的字符串  输出:数字\字母\汉字拼音首字母 借用了别人的汉字拼音库     ///汉字拼音首字母列表 本列表包含了20902个汉字的第一个字母 ///本表收录的汉字字符的Unicode编码范

cibiren2011的专栏 9172

Windows11搭建GPU版本PyTorch 开发环境教程

Windows11搭建GPU版本PyTorch环境详细过程

世界那么大,我想去看看~【随心更新,看世界去了😄】 3241

【100分】最长子字符串的长度

题目要求在一个环形字符串中找出字符 ‘o’ 出现了偶数次的最长子字符串长度。这里的字符串是一个环形的,即首尾相连。代码统计了字符串中字符 ‘o’ 的出现次数,并根据其奇偶性返回相应的最长子字符串长度。当 ‘o’ 的数量为偶数时,直接返回字符串长度;当 ‘o’ 的数量为奇数时,返回长度减去 1。给你一个字符串 s,字符串s首尾相连成一个环形 ,请你在环中找出 ‘o’ 字符出现了偶数次最长子字符串的长度。【最长子字符串的长度】

weixin_54707168的博客 904

js获取汉字拼音首字母

使用pinyin-pro这个npm包 github: https://github.com/zh-lx/pinyin-pro 特色功能 支持汉字、词语、句子多种格式输入获取 获取拼音 获取声母 获取韵母 获取拼音首字母 获取音调 获取多音字的多种拼音 支持字符串和数组两种输出形式 版本更新 当前版本: 3.0.7 -> 3.1.0 增加获取拼音首字母功能 修复 readme 中音调形式参数 toneType 错写成了 tone 的错误 点击查看 版本更新文档 安装 npm 安装 npm ins

m0_51479322的博客 7192

ADS1115 0-10V高精度ADC模块原理图设计,已量产

在水质监测、智能气象站、环境感知等领域,0-10V 电压输出的传感器占据了重要地位。这类传感器输出信号稳定、抗干扰能力强,但对数据采集模块的精度、线性度和易用性提出了严苛要求。本文将深度解析一款专为 0-10V 传感器设计的高精度 ADC 模块,从硬件架构、性能指标到工程化实践,全面呈现其设计思路与核心价值。

不脱发的程序猿 293

获取汉字拼音首字母

感觉不如直接用模块: import pinyin print(pinyin.get('汉字')) # 获取首字母,可将中文字符串转为中文列表 然后获取每一个汉字的拼音字符串取第一个然后拼接即可 print(pinyin.get('汉字')[0]) print(pinyin.get_initial('汉字').replace(' ', '')) 当然也可以不用模块,稍微复杂一点: # 读入文本文件 def read_txt(file): with open(file, 'r') as f

virtualxiaoman的博客 1983

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

Java 获取汉字首字母

本文属于http://java.chinaitlab.com/base/803353.html原创!!!public class PinYin2Abbreviation { // 简体中文的编码范围从B0A1(45217)一直到F7FE(63486) private static int BEGIN = 45217; private static int END = 63486; //

Pig 2万+

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

python 提取汉字首字母

使用拼音库xpinyin import xpinyin if __name__ == '__main__': p = xpinyin.Pinyin() result = [p.get_initials(a, '') for a in ['上海', '武汉', '深圳']] print(result) 其中a是传入的汉字字符串,而p.get_initials(a, ‘’)中的参数’'是输出...

留下的,留不下的 4050

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

IOS汉字转拼音首字母

项目中需要给UITableView建右侧索引,需要获取汉字的拼音首字母,而汉字转拼音一般都是使用CFStringTransform方法 - (NSString*)pinyin { if (self == nil || self.length == 0) { return @""; } NSMutableString *result = [NSMutab

海洋之心 8249

获取汉字的拼音首字母

利用汉字拼音首字母进行快速检索,效率比直接检索汉字高很多。在ASCII编码中,汉字是按拼音首字母的顺序进行编码的,也就是说拼音首字母相同的汉字的编译是连续的、相对集中的。那么就可以通过比较汉字ASCII码的大小来确定其拼音首字母了。例如:如果汉字的ASCII码 n 满足 n >= 0xB0A1 && n 0xB0C4,说明该汉字的拼音首字母是A。 首先,写一个判断数值范围的辅助函数。

唐俊鑫的专栏 2300

js 获取汉字首字母和汉字转拼音

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <style type="text/css"> ta...

haogemr的博客 1万+

php获取汉字的首字母,PHP获取汉字的首字母

获取汉字首字母使用情景:需要按照名称首字母排序,但是又没有填写首字母的输入框,所以就在后端获取输入的文字的首字母,将首字母也一起插入数据库,样例输入: 张三样例输出: Z亲测有效/*** 获取汉字的首字母*/public function getFirstCharters($str){if (empty($str)) {return '';}//取出参数字符串中的首个字符$temp_str = s...

weixin_36191781的博客 688

java 截取汉字首字母,java 取汉字首字母

有时候,可能会有一些类似这样的需求:对于这样的效果,我们可以有类似这样的解决方案:package bys.utils;import java.io.UnsupportedEncodingException;/*** Created by toutou on 2014/2/21*/public class ChineseCharacterHelper {static final int GB_SP_...

weixin_39560066的博客 407
上一篇: 根据类名取得类实例
下一篇: 屏幕截图,不用API
subMain
博客等级 码龄19年 15粉丝 42原创
评论 3
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址