示例#1
0
        public Task <List <LiteTag> > FindTagsAsync(ulong guildId, string name, int stop)
        {
            int tolerance = LiteConfiguration.Load().RelatedTagsLimit;
            var tags      = Tags.Where(x => x.GuildId == guildId && x.Aliases.Any(y => LevenshteinDistance.Compute(name, y) <= tolerance));
            var selected  = tags.OrderBy(x => x.Aliases.Sum(y => LevenshteinDistance.Compute(name, y))).Take(stop);

            return(Task.FromResult(selected.ToList()));
        }
示例#2
0
        public static void EnsureExists()
        {
            string file = Path.Combine(AppContext.BaseDirectory, FileName);

            if (!File.Exists(file))
            {
                string path = Path.GetDirectoryName(file);
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                var config = new LiteConfiguration();
                config.SaveJson();
            }
        }