Skip to content

Commit

Permalink
Gboard support ShuangPin config
Browse files Browse the repository at this point in the history
  • Loading branch information
studyzy committed Jul 27, 2020
1 parent 77ed086 commit 3e03820
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 9 deletions.
13 changes: 7 additions & 6 deletions src/IME WL Converter Win/CoreWinFormMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,41 +22,42 @@ private void InitImportFormMapping()
imeFormMapping.Add(typeof (UserDefinePhrase), new PhraseFormatConfigForm());
imeFormMapping.Add(typeof (XiaoxiaoErbi), new ErbiTypeForm());
imeFormMapping.Add(typeof(Win10MsPinyin), new PinyinConfigForm());
imeFormMapping.Add(typeof(Gboard), new PinyinConfigForm());
}


private void InitImportPropertityMapping()
{
formPropertityMapping = new Dictionary<Type, IDictionary<string, string>>();
formPropertityMapping.Add(typeof (RimeConfigForm),
formPropertityMapping.Add(typeof(RimeConfigForm),
new Dictionary<string, string>
{
{"SelectedCodeType", "CodeType"},
{"SelectedOS", "OS"}
});
formPropertityMapping.Add(typeof (Ld2EncodingConfigForm),
formPropertityMapping.Add(typeof(Ld2EncodingConfigForm),
new Dictionary<string, string>
{
{"SelectedEncoding", "WordEncoding"}
});
formPropertityMapping.Add(typeof (XiaoxiaoConfigForm),
formPropertityMapping.Add(typeof(XiaoxiaoConfigForm),
new Dictionary<string, string>
{
{"SelectedCodeType", "CodeType"}
});
formPropertityMapping.Add(typeof (SelfDefiningConfigForm),
formPropertityMapping.Add(typeof(SelfDefiningConfigForm),
new Dictionary<string, string>
{
{"SelectedParsePattern", "UserDefiningPattern"}
});
formPropertityMapping.Add(typeof (PhraseFormatConfigForm),
formPropertityMapping.Add(typeof(PhraseFormatConfigForm),
new Dictionary<string, string>
{
{"PhraseFormat", "PhraseFormat"},
{"SelectedCodeType", "CodeType"},
{ "IsShortCode","IsShortCode"}
});
formPropertityMapping.Add(typeof (ErbiTypeForm),
formPropertityMapping.Add(typeof(ErbiTypeForm),
new Dictionary<string, string>
{
{"SelectedCodeType", "CodeType"}
Expand Down
4 changes: 2 additions & 2 deletions src/IME WL Converter Win/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("2.9.0.0")]
[assembly: AssemblyFileVersion("2.9.0.0")]
[assembly: AssemblyVersion("2.9.1.0")]
[assembly: AssemblyFileVersion("2.9.1.0")]
36 changes: 36 additions & 0 deletions src/ImeWlConverterCore/IME/Gboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.IO;
using System.Text;
using Studyzy.IMEWLConverter.Entities;
using Studyzy.IMEWLConverter.Filters;
using Studyzy.IMEWLConverter.Helpers;

namespace Studyzy.IMEWLConverter.IME
Expand All @@ -13,8 +14,41 @@ namespace Studyzy.IMEWLConverter.IME
[ComboBoxShow(ConstantString.GBOARD, ConstantString.GBOARD_C, 111)]
public class Gboard : BaseImport, IWordLibraryExport, IWordLibraryImport
{
public Gboard()
{
this.PinyinType = PinyinType.FullPinyin;
}
#region IWordLibraryExport 成员
public PinyinType PinyinType
{
get; set;
}
private WordLibraryList Filter(WordLibraryList wlList)
{
var result = new WordLibraryList();
IReplaceFilter replace = null;
if (PinyinType != PinyinType.FullPinyin)
{
replace = new ShuangpinReplacer(PinyinType);

}
foreach (var wl in wlList)
{
if (replace != null)
{
replace.Replace(wl);
}

//if (wl.GetPinYinLength() > 32)
// continue;
//if (wl.Word.Length > 64)
// continue;

result.Add(wl);

}
return result;
}
public string ExportLine(WordLibrary wl)
{
var sb = new StringBuilder();
Expand All @@ -28,6 +62,8 @@ public string ExportLine(WordLibrary wl)

public IList<string> Export(WordLibraryList wlList)
{
//对全拼方案进行编码转换
wlList = Filter(wlList);
string tempPath = Path.Combine(FileOperationHelper.GetCurrentFolderPath(), "dictionary.txt");
if (File.Exists(tempPath)) { File.Delete(tempPath); }
var sb = new StringBuilder();
Expand Down
1 change: 1 addition & 0 deletions src/ImeWlConverterCore/IME/Win10MsPinyin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ private WordLibrary ReadOnePhrase(FileStream fs, int nextStartPosition)
catch
{
wl.CodeType = CodeType.NoCode;
ImportLineErrorNotice?.Invoke(wl.Word+" 的编码缺失");
}

return wl;
Expand Down
2 changes: 1 addition & 1 deletion src/ImeWlConverterCore/ImeWlConverterCore-net46.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<TargetFramework>net46</TargetFramework>
<AssemblyName>ImeWlConverterCore</AssemblyName>
<RootNamespace>ImeWlConverterCore</RootNamespace>
<Version>2.9.0</Version>
<Version>2.9.1</Version>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 3e03820

Please sign in to comment.