public static Migemo Create() { var migemo = new Migemo("./dict/cp932/migemo-dict"); migemo.OperatorNewLine = @"\s*"; return(migemo); }
public void MigemoAllCharTest() { if (!Migemo.IsEnable()) { var solutionDir = Directory.GetParent(Directory.GetParent(Directory.GetParent(Directory.GetParent(System.Reflection.Assembly.GetExecutingAssembly().Location).FullName).FullName).FullName).FullName; var migemoDllPath = Path.Combine(solutionDir, "assemblies", "Migemo"); var migemoDictionaryPath = Path.Combine(solutionDir, "assemblies", "Migemo", "dict", "migemo-dict"); //Console.WriteLine(settings.MigemoDllPath); //Console.WriteLine(settings.MigemoDictionaryPath); Migemo.Initialize(migemoDllPath, migemoDictionaryPath); } if (!Migemo.IsEnable()) { // Fail: Migemo initialize Assert.Fail(); } for (var test = Convert.ToChar(0); test <= 255; test++) { try { var ret = Migemo.GetRegex(test.ToString()); //Console.WriteLine("{0}, {1}", test, ret.ToString()); } catch { Assert.Fail(); } } }
public static void refreshUserDict() { if (File.Exists(Application.StartupPath + LinearConst.MIGEMO_USERDICTIONARY_NAME)) { usermigemo = new Migemo(Application.StartupPath + LinearConst.MIGEMO_USERDICTIONARY_NAME); } }
private bool CanUseMigemo(string input) { if (input.Length > 1 && Migemo.IsEnable() && UIAssistantAPI.Instance.UIAssistantSettings.UseMigemo) { return(_ascii.IsMatch(input)); } return(false); }
public static int Main(string[] args) { Migemo m = new Migemo("../dict/migemo-dict"); string res = m.Query("kaki"); Console.WriteLine("kaki->" + res); return(0); }
public IsMatchMigemoSQLiteFunction() { migemo = new Migemo(Application.StartupPath + LinearConst.MIGEMO_DICTIONARY_NAME); if (File.Exists(Application.StartupPath + LinearConst.MIGEMO_USERDICTIONARY_NAME)) { usermigemo = new Migemo(Application.StartupPath + LinearConst.MIGEMO_USERDICTIONARY_NAME); } }
//// インスタンス //private static RegexModel regexModel; /// <summary> /// コンストラクタ /// </summary> public RegexModel() { // Migemo使用時はMigemoオブジェクト生成 if (File.Exists("migemo.dll") && File.Exists("dict/migemo-dict")) { migemo = new Migemo("dict/migemo-dict"); } }
public void OnUseMigemoChecked() { Settings.UseMigemo = true; try { Migemo.Initialize(Settings.MigemoDllPath, Settings.MigemoDictionaryPath); } catch (Exception ex) { UIAssistantAPI.Instance.NotificationAPI.NotifyWarnMessage("Load Migemo Error", $"{ex.Message}"); } }
public DefaultFilter() { var api = UIAssistantAPI.Instance; try { if (!Migemo.IsEnable() && api.UIAssistantSettings.UseMigemo) { Migemo.Initialize(api.UIAssistantSettings.MigemoDllPath, api.UIAssistantSettings.MigemoDictionaryPath); } } catch (Exception ex) { api.NotificationAPI.NotifyWarnMessage("Load Migemo Error", $"{ex.Message}"); api.LogAPI.WriteErrorMessage(ex); } }
/// <summary> /// アプリケーション全体の初期化 /// </summary> /// <returns>メインウィンドウ</returns> internal static System.Windows.Forms.Form Init() { System.Windows.Forms.Form componentAsMainForm = null; SetDllDirectoryW(""); // migemoのロード try { MyMigemo = new Migemo(@"dict\migemo-dict"); } catch (Exception e) { Logger.Error(e); } // ライブラリ準備 Library = MyUserDirectory.OpenLibrary(); // プレイリスト管理の開始 MyPlaylistManager = new PlaylistManager(); // コンポーネントの読み込み MyComponentManager.Add(MyCoreComponent); componentAsMainForm = MyComponentManager.BuildAllInstance(System.IO.Directory.GetFiles(MyUserDirectory.ComponentDir, "*.dll")); MyComponentManager.LoadSettings(); MyPlaylistManager.CreatePlaylist(MyCoreComponent.LatestPlaylistQuery); if (BASS.IsAvailable) { BASS.BASS_Init(0, buffer_len: 500); if (System.IO.Directory.Exists(MyUserDirectory.PluginDir)) { foreach (String dllFilename in System.IO.Directory.GetFiles(MyUserDirectory.PluginDir, "*.dll")) { bool success = BASSPlugin.Load(dllFilename, 0); Logger.Log("Loading " + dllFilename + (success ? " OK" : " Failed")); } } } Controller.Startup(); return(componentAsMainForm); }
public void Init(PluginInitContext context) { Log.Info($"|Wox.Plugin.MigemoSearch|Init started."); _context = context; _storage = new PluginJsonStorage <Settings>(); _settings = _storage.Load(); var pluginDirectory = context.CurrentPluginMetadata.PluginDirectory; const string sdk = "EverythingSDK"; var bundledSDKDirectory = Path.Combine(pluginDirectory, sdk, CpuType()); var sdkDirectory = Path.Combine(_storage.DirectoryPath, sdk, CpuType()); Helper.ValidateDataDirectory(bundledSDKDirectory, sdkDirectory); var sdkPath = Path.Combine(sdkDirectory, EVERYTHING_DLL); Constant.EverythingSDKPath = sdkPath; LoadLibrary(sdkPath); // Migemo pluginDirectory = context.CurrentPluginMetadata.PluginDirectory; const string migemoSdk = "MigemoSDK"; bundledSDKDirectory = Path.Combine(pluginDirectory, migemoSdk, CpuType()); sdkDirectory = Path.Combine(_storage.DirectoryPath, migemoSdk, CpuType()); Helper.ValidateDataDirectory(bundledSDKDirectory, sdkDirectory); sdkPath = Path.Combine(sdkDirectory, "migemo.dll"); Log.Info($"|Wox.Plugin.MigemoSearch|pluginDirectory=<{pluginDirectory}>, bundledSDKDirectory=<{bundledSDKDirectory}>, sdkDirectory=<{sdkDirectory}>, sdkPath=<{sdkPath}>"); LoadLibrary(sdkPath); bundledSDKDirectory = Path.Combine(pluginDirectory, migemoSdk, "dict/cp932"); sdkDirectory = Path.Combine(_storage.DirectoryPath, migemoSdk, "dict/cp932"); Helper.ValidateDataDirectory(bundledSDKDirectory, sdkDirectory); Log.Info($"|Wox.Plugin.MigemoSearch|dict=<{Path.Combine(_storage.DirectoryPath, migemoSdk, "dict/cp932/migemo-dict")}>"); _migemo_api = new Migemo(Path.Combine(_storage.DirectoryPath, migemoSdk, "dict/cp932/migemo-dict")); //_migemo_api.OperatorNewLine = @"\s*"; Log.Info($"|Wox.Plugin.MigemoSearch|Init complated."); }
private IEnumerable <IHUDItem> Filter(IEnumerable <IHUDItem> list, params string[] inputs) { Regex regex; if (CanUseMigemo(inputs[0])) { regex = Migemo.GetRegex(inputs[0]); } else { var input = Regex.Escape(inputs[0]); regex = new Regex(input, RegexOptions.IgnoreCase); } var select = list.Where(hudItem => { var match = regex.Match(hudItem.DisplayText); if (match.Success) { if (hudItem == null) { return(false); } hudItem.ColoredStart = match.Index; hudItem.ColoredLength = match.Length; } return(match.Success); }); if (inputs.Length > 1) { return(Filter(select, inputs.Skip(1).ToArray())); } else { return(select); } }
public void MigemoTest() { if (!Migemo.IsEnable()) { var solutionDir = Directory.GetParent(Directory.GetParent(Directory.GetParent(Directory.GetParent(System.Reflection.Assembly.GetExecutingAssembly().Location).FullName).FullName).FullName).FullName; var settings = UIAssistantAPI.Instance.UIAssistantSettings; settings.UseMigemo = true; settings.MigemoDllPath = Path.Combine(solutionDir, "assemblies", "Migemo"); settings.MigemoDictionaryPath = Path.Combine(solutionDir, "assemblies", "Migemo", "dict", "migemo-dict"); } var migemoFilter = new DefaultFilter(); if (!Migemo.IsEnable()) { // Fail: Migemo initialize Assert.Fail(); } var results = migemoFilter.Filter(_collection, "gamen"); Assert.AreEqual(9, results.Count()); results = migemoFilter.Filter(_collection, "здравствуйте"); Assert.AreEqual(1, results.Count()); }
public static void ClassCleanup() { Migemo.Dispose(); }
public void OnUseMigemoUnchecked() { Settings.UseMigemo = false; Migemo.Dispose(); }