Skip to content

Commit

Permalink
添加姓氏拼音资源包生成
Browse files Browse the repository at this point in the history
  • Loading branch information
toolgood committed May 31, 2021
1 parent 2d46799 commit e79414e
Show file tree
Hide file tree
Showing 23 changed files with 203,309 additions and 23 deletions.
304 changes: 284 additions & 20 deletions csharp/ToolGood.Words.ReferenceHelper/Form1.Designer.cs

Large diffs are not rendered by default.

124 changes: 124 additions & 0 deletions csharp/ToolGood.Words.ReferenceHelper/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand Down Expand Up @@ -242,8 +243,131 @@ private void button9_Click(object sender, EventArgs e)

}


#endregion

#region 生产拼音
private void button20_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "文本文件(*.txt)|*.txt";
if (openFileDialog.ShowDialog() == DialogResult.OK) {
this.textBox1.Text = openFileDialog.FileName;
}
openFileDialog = null;
}

private void button21_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "文本文件(*.txt)|*.txt";
if (openFileDialog.ShowDialog() == DialogResult.OK) {
this.textBox2.Text = openFileDialog.FileName;
}
openFileDialog = null;
}
private void textBox1_DragDrop(object sender, DragEventArgs e)
{
List<string> list = new List<string>();
var files = (System.Array)e.Data.GetData(DataFormats.FileDrop);
foreach (var item in files) {
var file = item.ToString();
if (file.ToLower().EndsWith(".txt")
) {
this.textBox1.Text = file;
}
}
}

private void textBox2_DragDrop(object sender, DragEventArgs e)
{
List<string> list = new List<string>();
var files = (System.Array)e.Data.GetData(DataFormats.FileDrop);
foreach (var item in files) {
var file = item.ToString();
if (file.ToLower().EndsWith(".txt")
) {
this.textBox2.Text = file;
}
}
}


/// <summary>
/// 生成gzip资源包
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button15_Click(object sender, EventArgs e)
{
var pinyinIndex = this.textBox1.Text;
if (File.Exists(pinyinIndex) == false) { MessageBox.Show("拼音序列文件不存在!"); }
var pinyinName = this.textBox2.Text;
if (File.Exists(pinyinName) == false) { MessageBox.Show("姓氏拼音文件不存在!"); }

PinyinNameBuild build = new PinyinNameBuild();
build.CreateZip(pinyinIndex, pinyinName, "out/gzip/pyName.txt.z");
build = null;
MessageBox.Show("完成!已保存在 out/gzip/pyName.txt.z 文件内。");

}
/// <summary>
/// 生成br资源包
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button16_Click(object sender, EventArgs e)
{
var pinyinIndex = this.textBox1.Text;
if (File.Exists(pinyinIndex) == false) { MessageBox.Show("拼音序列文件不存在!"); }
var pinyinName = this.textBox2.Text;
if (File.Exists(pinyinName) == false) { MessageBox.Show("姓氏拼音文件不存在!"); }

PinyinNameBuild build = new PinyinNameBuild();
build.CreateBr(pinyinIndex, pinyinName, "out/br/pyName.txt.br");
build = null;
MessageBox.Show("完成!已保存在 out/gzip/pyName.txt.br 文件内。");
}
/// <summary>
/// 生成java资源包
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button17_Click(object sender, EventArgs e)
{
var pinyinIndex = this.textBox1.Text;
if (File.Exists(pinyinIndex) == false) { MessageBox.Show("拼音序列文件不存在!"); }
var pinyinName = this.textBox2.Text;
if (File.Exists(pinyinName) == false) { MessageBox.Show("姓氏拼音文件不存在!"); }

PinyinNameBuild build = new PinyinNameBuild();
build.CreateJava(pinyinIndex, pinyinName, "out/java/pyName.txt");
build = null;
MessageBox.Show("完成!已保存在 out/java/pyName.txt 文件内。");
}
/// <summary>
/// 生成js资源包
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button18_Click(object sender, EventArgs e)
{

}
/// <summary>
/// 生成python资源包
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button19_Click(object sender, EventArgs e)
{

}

#endregion




}
}
2 changes: 1 addition & 1 deletion csharp/ToolGood.Words.ReferenceHelper/PinyinBuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ private List<string> BuildMiniWords(List<string> pyShow, Dictionary<string, List
wordsSearch = new Words.WordsSearch();
wordsSearch.SetKeywords(keys2);
foreach (var item in tempClearKeys) {
if (item.Length >= 7) { continue; } //排除诗句 歇后语
//if (item.Length >= 7) { continue; } //排除诗句 歇后语
var all = wordsSearch.FindAll(item);
if (all.Any(q => q.End + 1 == item.Length)) {
AddKeys2.Add(item);
Expand Down
Loading

0 comments on commit e79414e

Please sign in to comment.