Skip to content

Commit

Permalink
增加了强制使用新词频的功能,以满足某些词库的词频导致Win10微软拼音的位置有问题。
Browse files Browse the repository at this point in the history
  • Loading branch information
studyzy committed Oct 14, 2018
1 parent 20d19be commit 6960a8a
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 20 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ private void btnOK_Click(object sender, EventArgs e)
{
wordRankGenerater = new CalcWordRankGenerater();
}
wordRankGenerater.ForceUse = cbxForceUseNewRank.Checked;
DialogResult = DialogResult.OK;
}

Expand All @@ -53,6 +54,7 @@ private void WordRankGenerateForm_Load(object sender, EventArgs e)
{
rbtnBaidu.Checked = true;
}
cbxForceUseNewRank.Checked = wordRankGenerater.ForceUse;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class BaiduWordRankGenerater : IWordRankGenerater
{
private static string API = "http://www.baidu.com/s?wd={0}";
private static readonly Regex regex = new Regex("百度为您找到相关结果约([0-9\\,]+)个");

public bool ForceUse { get; set; }
public int GetRank(string word)
{
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace Studyzy.IMEWLConverter.Generaters
{
public class CalcWordRankGenerater : IWordRankGenerater
{
public bool ForceUse { get; set; }
public int GetRank(string word)
{
double x = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public DefaultWordRankGenerater()
{
Rank = 1;
}

public bool ForceUse { get; set; }
public int Rank { get; set; }

public int GetRank(string word)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class GoogleWordRankGenerater : IWordRankGenerater
{
private static string API = "https://www.google.com/search?q={0}";
private static readonly Regex regex = new Regex("estimatedResultCount: \"(\\d+)\"");

public bool ForceUse { get; set; }
public int GetRank(string word)
{
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@
public interface IWordRankGenerater
{
int GetRank(string word);
/// <summary>
/// 是否忽略源词库的词频,强制使用新词频?
/// </summary>
bool ForceUse { get; set; }
}
}
2 changes: 1 addition & 1 deletion IME WL Converter/IME WL Converter/MainBody.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ private void GenerateWordRank(WordLibraryList wordLibraryList)
currentStatus = 0;
foreach (WordLibrary wordLibrary in wordLibraryList)
{
if (wordLibrary.Rank == 0)
if (wordLibrary.Rank == 0|| wordRankGenerater.ForceUse )
{
wordLibrary.Rank = wordRankGenerater.GetRank(wordLibrary.Word);
}
Expand Down

0 comments on commit 6960a8a

Please sign in to comment.