Skip to content

Commit

Permalink
Fix #86, allow both Ch and En code in Emoji.
Browse files Browse the repository at this point in the history
  • Loading branch information
studyzy committed Jun 8, 2019
1 parent 08fa93f commit 711673a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/ImeWlConverterCore/Filters/XiaoheShuangpinReplacer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public XiaoheShuangpinReplacer()

public void Replace(WordLibrary wl)
{
if(wl.CodeType!=CodeType.Pinyin)//必须是拼音才能被双拼替换
{
return;
}
foreach(var code in wl.Codes)
{
for(var i=0;i<code.Count;i++)
Expand Down
11 changes: 11 additions & 0 deletions src/ImeWlConverterCore/IME/Emoji.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace Studyzy.IMEWLConverter.IME
Expand Down Expand Up @@ -33,10 +34,20 @@ public WordLibraryList ImportLine(string line)
var wl = new WordLibrary();
wl.Word = line.Split('\t')[1];
wl.CodeType = CodeType;
wl.IsEnglish = IsEnglish(wl.Word);
if (wl.IsEnglish)
{
wl.SetCode(CodeType.English, wl.Word);
}
var wll = new WordLibraryList();
wll.Add(wl);
return wll;
}
private static Regex regex = new Regex("^[a-zA-Z]+$");
private bool IsEnglish(string word)
{
return regex.IsMatch(word);
}

public WordLibraryList ImportText(string text)
{
Expand Down
5 changes: 5 additions & 0 deletions src/ImeWlConverterCore/MainBody.cs
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,11 @@ private void GenerateDestinationCode(WordLibraryList wordLibraryList, CodeType c
{
continue;
}
if (wordLibrary.CodeType == CodeType.English)
{
wordLibrary.SetCode(CodeType.English, wordLibrary.Word.ToLower());
continue;
}
try
{
generater.GetCodeOfWordLibrary(wordLibrary);
Expand Down

0 comments on commit 711673a

Please sign in to comment.