Java汉字转换为拼音


/**
* Java 汉字转换为拼音
*
* @author 我自是年少,韶华倾负。
* @since 0.1_2012-12-27
*/
public class CharacterParser {
private static int[] pyvalue = new int[] {-20319, -20317, -20304, -20295, -20292, -20283, -20265, -20257, -20242, -20230, -20051, -20036, -20032,
-20026, -20002, -19990, -19986, -19982, -19976, -19805, -19784, -19775, -19774, -19763, -19756, -19751, -19746, -19741, -19739, -19728,
-19725, -19715, -19540, -19531, -19525, -19515, -19500, -19484, -19479, -19467, -19289, -19288, -19281, -19275, -19270, -19263, -19261,
-19249, -19243, -19242, -19238, -19235, -19227, -19224, -19218, -19212, -19038, -19023, -19018, -19006, -19003, -18996, -18977, -18961,
-18952, -18783, -18774, -18773, -18763, -18756, -18741, -18735, -18731, -18722, -18710, -18697, -18696, -18526, -18518, -18501, -18490,
-18478, -18463, -18448, -18447, -18446, -18239, -18237, -18231, -18220, -18211, -18201, -18184, -18183, -18181, -18012, -17997, -17988,
-17970, -17964, -17961, -17950, -17947, -17931, -17928, -17922, -17759, -17752, -17733, -17730, -17721, -17703, -17701, -17697, -17692,
-17683, -17676, -17496, -17487, -17482, -17468, -17454, -17433, -17427, -17417, -17202, -17185, -16983, -16970, -16942, -16915, -16733,
-16708, -16706, -16689, -16664, -16657, -16647, -16474, -16470, -16465, -16459, -16452, -16448, -16433, -16429, -16427, -16423, -16419,
-16412, -16407, -16403, -16401, -16393, -16220, -16216, -16212, -16205, -16202, -16187, -16180, -16171, -16169, -16158, -16155, -15959,
-15958, -15944, -15933, -15920, -15915, -15903, -15889, -15878, -15707, -15701, -15681, -15667, -15661, -15659, -15652, -15640, -15631,
-15625, -15454, -15448, -15436, -15435, -15419, -15416, -15408, -15394, -15385, -15377, -15375, -15369, -15363, -15362, -15183, -15180,
-15165, -15158, -15153, -15150, -15149, -15144, -15143, -15141, -15140, -15139, -15128, -15121, -15119, -15117, -15110, -15109, -14941,
-14937, -14933, -14930, -14929, -14928, -14926, -14922, -14921, -14914, -14908, -14902, -14894, -14889, -14882, -14873, -14871, -14857,
-14678, -14674, -14670, -14668, -14663, -14654, -14645, -14630, -14594, -14429, -14407, -14399, -14384, -14379, -14368, -14355, -14353,
-14345, -14170, -14159, -14151, -14149, -14145, -14140, -14137, -14135, -14125, -14123, -14122, -14112, -14109, -14099, -14097, -14094,
-14092, -14090, -14087, -14083, -13917, -13914, -13910, -13907, -13906, -13905, -13896, -13894, -13878, -13870, -13859, -13847, -13831,
-13658, -13611, -13601, -13406, -13404, -13400, -13398, -13395, -13391, -13387, -13383, -13367, -13359, -13356, -13343, -13340, -13329,
-13326, -13318, -13147, -13138, -13120, -13107, -13096, -13095, -13091, -13076, -13068, -13063, -13060, -12888, -12875, -12871, -12860,
-12858, -12852, -12849, -12838, -12831, -12829, -12812, -12802, -12607, -12597, -12594, -12585, -12556, -12359, -12346, -12320, -12300,
-12120, -12099, -12089, -12074, -12067, -12058, -12039, -11867, -11861, -11847, -11831, -11798, -11781, -11604, -11589, -11536, -11358,
-11340, -11339, -11324, -11303, -11097, -11077, -11067, -11055, -11052, -11045, -11041, -11038, -11024, -11020, -11019, -11018, -11014,
-10838, -10832, -10815, -10800, -10790, -10780, -10764, -10587, -10544, -10533, -10519, -10331, -10329, -10328, -10322, -10315, -10309,
-10307, -10296, -10281, -10274, -10270, -10262, -10260, -10256, -10254};
public static String[] pystr = new String[] {"a", "ai", "an", "ang", "ao", "ba", "bai", "ban", "bang", "bao", "bei", "ben", "beng", "bi", "bian",
"biao", "bie", "bin", "bing", "bo", "bu", "ca", "cai", "can", "cang", "cao", "ce", "ceng", "cha", "chai", "chan", "chang", "chao", "che",
"chen", "cheng", "chi", "chong", "chou", "chu", "chuai", "chuan", "chuang", "chui", "chun", "chuo", "ci", "cong", "cou", "cu", "cuan",
"cui", "cun", "cuo", "da", "dai", "dan", "dang", "dao", "de", "deng", "di", "dian", "diao", "die", "ding", "diu", "dong", "dou", "du",
"duan", "dui", "dun", "duo", "e", "en", "er", "fa", "fan", "fang", "fei", "fen", "feng", "fo", "fou", "fu", "ga", "gai", "gan", "gang",
"gao", "ge", "gei", "gen", "geng", "gong", "gou", "gu", "gua", "guai", "guan", "guang", "gui", "gun", "guo", "ha", "hai", "han", "hang",
"hao", "he", "hei", "hen", "heng", "hong", "hou", "hu", "hua", "huai", "huan", "huang", "hui", "hun", "huo", "ji", "jia", "jian",
"jiang", "jiao", "jie", "jin", "jing", "jiong", "jiu", "ju", "juan", "jue", "jun", "ka", "kai", "kan", "kang", "kao", "ke", "ken",
"keng", "kong", "kou", "ku", "kua", "kuai", "kuan", "kuang", "kui", "kun", "kuo", "la", "lai", "lan", "lang", "lao", "le", "lei", "leng",
"li", "lia", "lian", "liang", "liao", "lie", "lin", "ling", "liu", "long", "lou", "lu", "lv", "luan", "lue", "lun", "luo", "ma", "mai",
"man", "mang", "mao", "me", "mei", "men", "meng", "mi", "mian", "miao", "mie", "min", "ming", "miu", "mo", "mou", "mu", "na", "nai",
"nan", "nang", "nao", "ne", "nei", "nen", "neng", "ni", "nian", "niang", "niao", "nie", "nin", "ning", "niu", "nong", "nu", "nv", "nuan",
"nue", "nuo", "o", "ou", "pa", "pai", "pan", "pang", "pao", "pei", "pen", "peng", "pi", "pian", "piao", "pie", "pin", "ping", "po", "pu",
"qi", "qia", "qian", "qiang", "qiao", "qie", "qin", "qing", "qiong", "qiu", "qu", "quan", "que", "qun", "ran", "rang", "rao", "re",
"ren", "reng", "ri", "rong", "rou", "ru", "ruan", "rui", "run", "ruo", "sa", "sai", "san", "sang", "sao", "se", "sen", "seng", "sha",
"shai", "shan", "shang", "shao", "she", "shen", "sheng", "shi", "shou", "shu", "shua", "shuai", "shuan", "shuang", "shui", "shun",
"shuo", "si", "song", "sou", "su", "suan", "sui", "sun", "suo", "ta", "tai", "tan", "tang", "tao", "te", "teng", "ti", "tian", "tiao",
"tie", "ting", "tong", "tou", "tu", "tuan", "tui", "tun", "tuo", "wa", "wai", "wan", "wang", "wei", "wen", "weng", "wo", "wu", "xi",
"xia", "xian", "xiang", "xiao", "xie", "xin", "xing", "xiong", "xiu", "xu", "xuan", "xue", "xun", "ya", "yan", "yang", "yao", "ye", "yi",
"yin", "ying", "yo", "yong", "you", "yu", "yuan", "yue", "yun", "za", "zai", "zan", "zang", "zao", "ze", "zei", "zen", "zeng", "zha",
"zhai", "zhan", "zhang", "zhao", "zhe", "zhen", "zheng", "zhi", "zhong", "zhou", "zhu", "zhua", "zhuai", "zhuan", "zhuang", "zhui",
"zhun", "zhuo", "zi", "zong", "zou", "zu", "zuan", "zui", "zun", "zuo"};
private StringBuilder buffer;
private String resource;
private static CharacterParser characterParser = new CharacterParser();

public static CharacterParser getInstance() {
return characterParser;
}

public String getResource() {
return resource;
}

public void setResource(String resource) {
this.resource = resource;
}

/** * 汉字转成ASCII码 * * @param chs * @return */
private int getChsAscii(String chs) {
int asc = 0;
try {
byte[] bytes = chs.getBytes("gb2312");
if (bytes == null || bytes.length > 2 || bytes.length <= 0) {
throw new RuntimeException("illegal resource string");
}
if (bytes.length == 1) {
asc = bytes[0];
}
if (bytes.length == 2) {
int hightByte = 256 + bytes[0];
int lowByte = 256 + bytes[1];
asc = (256 * hightByte + lowByte) - 256 * 256;
}
} catch (Exception e) {
System.out.println("ERROR:ChineseSpelling.class-getChsAscii(String chs)" + e);
}
return asc;
}

/** * 单字解析 * * @param str * @return */
public String convert(String str) {
String result = null;
int ascii = getChsAscii(str);
if (ascii > 0 && ascii < 160) {
result = String.valueOf((char) ascii);
} else {
for (int i = (pyvalue.length - 1); i >= 0; i--) {
if (pyvalue[i] <= ascii) {
result = pystr[i];
break;
}
}
}
return result;
}

/** * 词组解析 * * @param chs * @return */
public String getSelling(String chs) {
String key, value;
buffer = new StringBuilder();
for (int i = 0; i < chs.length(); i++) {
key = chs.substring(i, i + 1);
if (key.getBytes().length >= 2) {
value = (String) convert(key);
if (value == null) {
value = "unknown";
}
} else {
value = key;
}
buffer.append(value+" ");
}
return buffer.toString();
}

public String getSpelling() {
return this.getSelling(this.getResource());
}

public static void main(String[] args) {
CharacterParser parser = CharacterParser.getInstance();
System.out.println(parser.getSelling("不错"));
}
}
国内城市的拼音转汉字 将国内城市的拼音和汉字进行对照 ... “Beijing”: “北京”, “Shanghai”: “上海”, “Guangzhou”: “广州”, ... 立即下载

相关推荐

Android例子源码通讯录联系人字母排序索引A-Z

 主要实现功能: 1、获取手机通讯录内容已列表的形式展示。 2、屏幕右边有26字母的标杆,触摸标杆的任一字母,该字母颜色、字体改变,同时屏幕上显示该字母,屏幕中展示首字母为该字母的通讯录名单。 3、点击通讯录列表的某一项,字母标杆上该字母的颜色、字体改变,频幕显示该字母3秒。4、滑动该listview,当活动结束时,屏幕最上面的联系人的首字母对应的字母标杆颜色、字体改变。 

搜索引擎之纠错功能:“您要找的是不是XXX”

还记得搜索引擎里当你输入错了关键字或者记不太清楚的时候,搜索引擎会帮助你提示“您要找的是不是XXX”。   如百度“wangking”,提示"你要找的是不是 网名 wangming"   URL: http://www.baidu.com/s?bs=sb&amp;f=8&amp;wd=wangking     在群里看到有人在问这个如何实现,有人提到相似度查询,其实就是这个道理。 ...

wangking:开源世界,人人都用上了正版啦。。。 1957

GNSS差分码偏差(DCB)从原理到实战:如何避免数据处理中的常见错误

本文深入解析GNSS差分码偏差(DCB)的原理及其对高精度定位的关键影响。针对数据处理中因忽略DCB校正导致的常见错误,如单系统PPP高程偏差、多系统融合精度下降及电离层研究失真等,提供了实战解决方案与主流DCB产品获取、集成方法,帮助用户有效规避陷阱,提升数据处理精度。

k5l6m的博客 228

android studio拼音转汉字,汉字转拼音,TinyPinyin、Pinyin4j与JPinyin哪个库更快

1. 介绍本文对TinyPinyin、Pinyin4j与JPinyin三个汉字转拼音库的用法、测试代码及转换的结果做一个简单的总结。适用于Java和Android的快速、低内存占用的汉字转拼音库。在Android项目中使用时,需要在module app下的build.gradle文件中添加依赖(下同):1 compile 'com.github.promeg:tinypinyin:2.0.3'2 ...

weixin_30495789的博客 1181

YOLOv5+Astra Pro Plus深度相机:手把手教你实现实时目标检测(附ROS配置技巧)

本文详细介绍了如何将YOLOv5目标检测算法与Astra Pro Plus深度相机结合,构建实时目标检测系统。内容涵盖从硬件选型、环境搭建、ROS配置到YOLOv5部署与深度信息融合的完整流程,并分享了性能优化、避障算法等实战技巧,帮助开发者在机器人视觉等场景中快速实现智能感知应用。

weixin_28292761的博客 401

Spyglass实战指南:跨时钟域同步方案深度解析

本文深度解析了Spyglass在跨时钟域同步方案验证中的实战应用。通过真实案例阐述了亚稳态的危害,并详细介绍了从基础的两级同步器到复杂的异步FIFO与握手协议等八大同步方案,以及如何利用Spyglass进行有效配置、检查与问题排查,为提升芯片设计可靠性提供系统性的避坑指南。

weixin_29219189的博客 844

【详解】Java汉字转换拼音(大小写)

在Java中,使用​​类可以很容易地将汉字转换为拼音。如果需要大小写混合的拼音,可以使用正则表达式来替换小写字母为大写。希望本文的示例能帮助你在实际项目中实现汉字与拼音的转换。在实际应用中,你可能需要根据不同的场景来处理汉字转换拼音的问题。

牛肉胡辣汤 3936

Python之ae-toolbox包语法、参数和实际应用案例

ae-toolbox(全称 after-effects-toolbox)是 Python 生态中专门用于 Adobe After Effects(AE)自动化操作 的工具包,基于 AE 的 ExtendScript(JSX)桥接技术,实现 Python 与 AE 的跨语言通信。

王国平的博客 1180

java使用PinYin4j将汉字转换为拼音

java汉字转拼音,主要是利用pinyin4j工具实现,很多情况下可能会用到汉字转换成拼音的功能,具体的实现代码如下: import net.sourceforge.pinyin4j.PinyinHelper; import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType; import net.sourceforge.pinyin4j

面向太阳、骄傲的活着 2514

YOLOv11改进 | 注意力篇 | YOLOv11引入24年ECCV的自调制特征聚合注意力模块(SMFA),并构建C2PSA_SMFA

1.SMFA介绍1.1 摘要:基于Transformer的图像复原方法由于Transformer的自注意(self-attention,SA)特性能够更好地挖掘非局部信息,从而获得更好的高分辨率图像重建效果,因此具有重要的应用价值。然而,关键点积SA需要大量的计算资源,这限制了其在低功耗器件中的应用。此外,模拟退火机制的低通特性限制了其捕获局部细节的能力,从而导致平滑的重建结果。

tsg6698的博客 961

KingSCADA|如何查看授权信息?授权到期如何升级?

哈喽,你好,我是雷工!在使用KingSCADA软件的过程中,经常会涉及到授权信息的查看,以及到期后该如何升级。

做有价值的事,积累有价值的笔记! 3297

java 汉字转换拼音

java 汉字转换拼音 maven依赖 <dependency> <groupId>com.belerweb</groupId> <artifactId>pinyin4j</artifactId> <version>2.5.0</version> </dependency> ...

1万+

为什么一个“时间片”能折腾 Linux 十年?

时间片扩展不是抢占调度器的控制权,也不是提升优先级。在“非常短暂、非常确定”的用户态临界区内,避免线程被不必要地抢占。用户态自旋锁(user-space spinlock)无系统调用的极短临界区高并发、低延迟的数据结构操作RSEQ(Restartable Sequences)保护区间一旦线程在临界区被抢占,系统整体性能反而下降。线程 A 拿着一个用户态锁线程 B 被调度上来,开始自旋等这个锁但 A 因为时间片用完,被调度器切走CPU 白白空转,所有线程都在浪费时间。

网络技术联盟站 262

Java 汉字转换为拼音字符串

本文本着学习分享的目的,介绍一种基于java.text.Collator的比较挫的方法,实现汉字转换为拼音字符串。当然我得暂时不考虑汉字多音字的问题。最终结果是这样:     吃 -> CHI    睡 -> SHUI     做 -> ZUO     需要直接拷贝代码的请拉至贴末尾。   1,Unicode编码     古代秦国统一六国汉字,而Unicode编码则统一了全世界文字。它整

yarkey09 2617

[Dify实战] 品牌舆情速览:多渠道抓取、聚类情绪、生成日报-带绑定资源

摘要: 品牌舆情监测面临多渠道信息分散、手工处理效率低的痛点。Dify舆情速览助手通过自动化流程(数据抓取→情绪聚类→日报生成)帮助快速识别热点与风险。方案核心包括: 结构化处理:按情绪(正/中/负)聚类,分级标注风险事件; 日报输出:含热点摘要、趋势分析及处置建议(动作+团队+时间窗口); 质量控制:数据去噪、黑名单过滤,结合人工复核确保合规性。 落地需明确数据源分级(如权威媒体优先)、设置情绪阈值,并建立"发现-响应-复盘"闭环机制,提升舆情应对效率。 (字数:150)

技术小甜甜:传播可落地技术,帮助个人和企业降低解决真实场景问题的成本 305

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

java 汉字转换为拼音

实现java 汉字转换为拼音,用于项目账号自动创建

mr_lili_1986的博客 1万+

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

java把汉字转换成拼音_Java实现汉字转换为拼音

本文的核心代码取自easydozer的blog:http://blog.csdn.net/easydozer/代码说明:Java实现汉字转换为拼音的GUI版本。GUI代码部分:/*** @(#)CnToSpellGUI.java* */import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing....

weixin_39865440的博客 159

深度学习工具包 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")

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

java下将汉字转换为拼音

1、代码如下,不过有些汉字不支持,如:茜   import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Set; public class CnToSpell { private static LinkedHashMap spellMap = null; static { ...

liuxi1024的专栏 175

java把汉字转换成拼音的2种方式

java程序将汉字转成拼音的两种方法 1.使用pinyin4j将汉字转成拼音,附件为pinyin4j的jar包  Java代码   import net.sourceforge.pinyin4j.PinyinHelper;   import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;   import...

IT人生 1878

java 汉字转换成拼音

Java代码 1. /** 2. * 3. * @author MoXie SysTem128(at)GMail.Com 4. */ 5. public class SpellCnHelper { 6. 7. private static int size = 7550; // (20319 - 1025...

哈里路亚 2105

Java实现汉字转换拼音功能

今天做程序用到了输入汉字,自动生成拼音首字母。上网一查,正好看到下面的文章,很好用。特转载保存一下 版权声明:本文为CSDN博主「杨鑫newlfe」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/u012965373/article/details/82625950 导入jar包 <dependency> <groupId>com.belerweb</groupId>

wszhlzjl的博客 578

java 实现汉字转换拼音_Java实现汉字转换为拼音

#re: Java实现汉字转换为拼音2006-11-24 15:06芦苇JAVA将汉字转化成拼音的方法/** *//**############################################################################## DESCRIBE 将汉字转化成拼音# DATE 2006-7-12# COMPANY FLX# PORJECT JAVA...

weixin_31193137的博客 350

java 汉字的ascii码_汉字、拼音、ASCII码的转换

package com;import java.util.Iterator;import java.util.LinkedHashMap;import java.util.Set;public class Chang {private static LinkedHashMap spellMap = null;static {if (spellMap == null) {spellMap = new...

weixin_30094815的博客 1246

java 实现汉字转换拼音_JAVA实现汉字转拼音功能代码实例

JAVA中汉字转拼音的方法并不复杂,可以使用pinyin4j包来实现。一、下载pinyin4j的架包,并导入项目中,如下:如果是maven项目,maven依赖如下:com.belerwebpinyin4j2.5.0二、汉字转拼音方法,附上代码例子,如下:public class PinyinUtil {public static void main(String[] args) throws Ex...

weixin_30111277的博客 3533
上一篇: JS获取当前月的天数
下一篇: Java解析JSON获取某个值
neneno
博客等级 码龄14年 0粉丝 13原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值