mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Cache for pinyin https://github.com/Wox-launcher/Wox/issues/1189
This commit is contained in:
parent
00ea4f8701
commit
86b2391543
4 changed files with 21 additions and 29 deletions
|
|
@ -35,20 +35,6 @@ namespace Wox.Plugin.ControlPanel
|
|||
item.Icon.ToBitmap().Save(iconFolder + item.GUID + fileType);
|
||||
}
|
||||
}
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
var characters = controlPanelItems.Select(i => i.LocalizedString)
|
||||
.Concat(controlPanelItems.Select(i => i.InfoTip));
|
||||
|
||||
Parallel.ForEach(characters, c =>
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(c) && Alphabet.ContainsChinese(c))
|
||||
{
|
||||
Alphabet.PinyinComination(c);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public List<Result> Query(Query query)
|
||||
|
|
|
|||
|
|
@ -83,19 +83,6 @@ namespace Wox.Plugin.Program
|
|||
});
|
||||
Task.WaitAll(t1, t2);
|
||||
|
||||
var characters = w.Select(p => p.Name)
|
||||
.Concat(w.Select(p => p.Description))
|
||||
.Concat(u.Select(p => p.DisplayName))
|
||||
.Concat(u.Select(p => p.Description));
|
||||
|
||||
Parallel.ForEach(characters, c =>
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(c) && Alphabet.ContainsChinese(c))
|
||||
{
|
||||
Alphabet.PinyinComination(c);
|
||||
}
|
||||
});
|
||||
|
||||
lock (IndexLock)
|
||||
{
|
||||
_win32s = w;
|
||||
|
|
|
|||
|
|
@ -4,17 +4,32 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using hyjiacan.util.p4n;
|
||||
using hyjiacan.util.p4n.format;
|
||||
using Wox.Infrastructure.Logger;
|
||||
using Wox.Infrastructure.Storage;
|
||||
|
||||
namespace Wox.Infrastructure
|
||||
{
|
||||
public static class Alphabet
|
||||
{
|
||||
private static readonly HanyuPinyinOutputFormat Format = new HanyuPinyinOutputFormat();
|
||||
private static readonly ConcurrentDictionary<string, string[][]> PinyinCache = new ConcurrentDictionary<string, string[][]>();
|
||||
private static ConcurrentDictionary<string, string[][]> PinyinCache;
|
||||
private static BinaryStorage<ConcurrentDictionary<string, string[][]>> _pinyinStorage;
|
||||
|
||||
static Alphabet()
|
||||
public static void Initialize()
|
||||
{
|
||||
Format.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
|
||||
|
||||
Stopwatch.Normal("|Wox.Infrastructure.Alphabet.Initialize|Preload pinyin cache", () =>
|
||||
{
|
||||
_pinyinStorage = new BinaryStorage<ConcurrentDictionary<string, string[][]>>("Pinyin");
|
||||
PinyinCache = _pinyinStorage.TryLoad(new ConcurrentDictionary<string, string[][]>());
|
||||
});
|
||||
Log.Info($"|Wox.Infrastructure.Alphabet.Initialize|Number of preload pinyin combination<{PinyinCache.Count}>");
|
||||
}
|
||||
|
||||
public static void Save()
|
||||
{
|
||||
_pinyinStorage.Save(PinyinCache);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -98,5 +113,7 @@ namespace Wox.Infrastructure
|
|||
).ToArray();
|
||||
return combination;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ namespace Wox
|
|||
PluginManager.InitializePlugins(API);
|
||||
|
||||
ImageLoader.Initialize();
|
||||
Alphabet.Initialize();
|
||||
|
||||
Current.MainWindow = window;
|
||||
Current.MainWindow.Title = Infrastructure.Constant.Wox;
|
||||
|
|
@ -136,6 +137,7 @@ namespace Wox
|
|||
|
||||
PluginManager.Save();
|
||||
ImageLoader.Save();
|
||||
Alphabet.Save();
|
||||
|
||||
_disposed = true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue