コード例 #1
0
        public void Init(PluginInitContext context)
        {
            string CurrentPath = context.CurrentPluginMetadata.PluginDirectory;

            if (!Directory.Exists(Path.Combine(CurrentPath, "config")))
            {
                Directory.CreateDirectory(Path.Combine(CurrentPath, "config"));
            }

            string ConfigFile = CurrentPath + "/config/config.json";

            if (File.Exists(ConfigFile))
            {
                settings = JsonConvert.DeserializeObject <Settings>(File.ReadAllText(ConfigFile));
            }
            else
            {
                settings = new Settings();
            }
            settings.ConfigFile = ConfigFile;

            ecdict         = new ECDict(CurrentPath + "/dicts/ecdict.db");
            wordCorrection = new WordCorrection(CurrentPath + "/dicts/frequency_dictionary_en_82_765.txt", settings.MaxEditDistance);
            synonyms       = new Synonyms(settings.BighugelabsToken);
            iciba          = new Iciba(settings.ICIBAToken);
            this.context   = context;
        }
コード例 #2
0
        public async Task InitAsync(PluginInitContext context)
        {
            string CurrentPath = context.CurrentPluginMetadata.PluginDirectory;

            Directory.CreateDirectory(Path.GetDirectoryName(configLocation));

            if (File.Exists(configLocation))
            {
                settings = await JsonSerializer.DeserializeAsync <Settings>(File.OpenRead(configLocation)).ConfigureAwait(false);
            }
            else
            {
                settings = new Settings();
            }
            settings.ConfigFile = configLocation;

            dictDownloadManager = new DictDownloadManager(ecdictLocation);
            wordCorrection      = new WordCorrection(CurrentPath + "/dicts/frequency_dictionary_en_82_765.txt", settings.MaxEditDistance);
            synonyms            = new Synonyms(settings.BighugelabsToken);
            iciba   = new Iciba(settings.ICIBAToken);
            Context = context;
        }