思路:
1.利用喜欢的字
2.按照平仄规律,三个字,第一个是姓,第二个字是三声或者四声的仄声调,第三个字是一声或者二声的平声调,给出所有的排列。使用的是pinyin4j的库
1.盛唐诗,宋诗、宋诗选注、辛弃疾,如女纳兰容若词传
2.名字响亮的处理:韵母a/e/i/o/u,如家、道、智等,放在最后会更响亮
若一
4.平仄悦耳,快读不连,多音不宜,字型有致,字无悬殊,偏旁异同,繁简适中,字无生僻,字无禁忌,谐音,名字倒读,一二组合,二三组合,一三组合,倒着组合
忌谐音作死
忌生僻
忌常见多音
忌笔画复杂
忌不雅联想
import net.sourceforge.pinyin4j.PinyinHelper;
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class CreatName {
private static String _names="睿,哲,悟,思,书,文,和,逸,怡,弘,奕,业,景,臻,极,仪,若,嘉,舒,成,怡,悦,煜,愉,豫,允,展,询,祎,烁,铄,琛,优,挚,斐,昱,沂,宜,翊,之,如";
static List<String>pingst=new ArrayList<>();
static List<String>zeste=new ArrayList<>();
public static void main(String[]args) {
Map<String,String>dicping=new HashMap<>();
Map<String,String>dicze=new HashMap<>();
String[]ones= _names.split(",");
for(String zi :ones) {
String tp;
tp=getFullSpell(zi);
if(tp.contains("1")||tp.contains("2")){
dicping.put(zi,tp);
}
else if(tp.contains("3")||tp.contains("4")){
dicze.put(zi,tp);
}
}
//用于存储html字符串
StringBuilder stringHtml = new StringBuilder();
try{
//打开文件
File newhtml=new File("C:\\222.html");
if(!newhtml.exists())
newhtml.createNewFile();
PrintStream printStream = new PrintStream(new FileOutputStream(newhtml));
//输入HTML文件内容
stringHtml.append("<html><head>");
stringHtml.append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">");
stringHtml.append("<title>测试报告文档</title>");
stringHtml.append("</head>");
stringHtml.append("<h1>待选名字</h1>");
stringHtml.append("<body text=\"black\">");
//stringHtml.append("<div>hello</div>");
stringHtml.append("<table style=\"font-family:'黑体'; font-size:16px; cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"#F0F0F0\" border=\"1\">");
for(String tm:dicze.keySet()){
stringHtml.append("<tr>");
for(String pin:dicping.keySet()){
//System.out.println("王"+diczi.get(tm)+diczi.get(pin));
String content="王"+tm+pin;
stringHtml.append("<td>");
stringHtml.append(content);
System.out.println(content);
stringHtml.append("</td>");
}
stringHtml.append("<tr>");
}
stringHtml.append("</table");
stringHtml.append("</body></html>");
//将HTML文件内容写入文件中
printStream.println(stringHtml.toString());
}catch (Exception e) {
e.printStackTrace();
}
}
/**
* 获取汉字串拼音,英文字符不变
* @param chinese 汉字串
* @return 汉语拼音
*/
public static String getFullSpell(String chinese) {
StringBuffer pybf = new StringBuffer();
char[] arr = chinese.toCharArray();
HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();
defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);
defaultFormat.setToneType(HanyuPinyinToneType.WITH_TONE_NUMBER);
for (int i = 0; i < arr.length; i++) {
if (arr[i] > 128) {
try {
pybf.append(PinyinHelper.toHanyuPinyinStringArray(arr[i], defaultFormat)[0]);
} catch (BadHanyuPinyinOutputFormatCombination e) {
e.printStackTrace();
}
} else {
pybf.append(arr[i]);
}
}
return pybf.toString();
}
}
-------------------------------------------------------------------------
增加:
<dependency> <groupId>com.belerweb</groupId> <artifactId>pinyin4j</artifactId> <version>2.5.0</version> </dependency>