private static void getKnownAnagrams(string[] args) { DictionaryFileReader reader = new DictionaryFileReader(GetConfiguration().Build()); if (args[1] == "" || args[1] == null) { Console.WriteLine("Please add a word the the query"); } var anagramCheckerDictionary = new AnagramCheckerDictionary(reader); var knownWords = anagramCheckerDictionary.getKnown(args[1]).Result.ToList(); if (knownWords.Count == 0) { Console.WriteLine(args[1] + " not Found"); } string words = ""; foreach (string kWord in knownWords) { if (kWord != args[1]) { words += kWord + ", "; } } Console.WriteLine("Known Anagrams: " + words); }
private async Task <ReplaceDictionaryUpdateInfo[]> CheckForDictionaryUpdateAsync() { var currentVersion = 0; var filePath = AppInfo.Current.DictionaryFilePath; if (File.Exists(filePath)) { var reader = new DictionaryFileReader(); try { currentVersion = reader.GetVersionNumber(filePath); } catch { } } var updater = new ReplaceDictionaryUpdater(); var latestVersion = updater.GetLatestVersionNumber(); if (latestVersion <= currentVersion) { return(Array.Empty <ReplaceDictionaryUpdateInfo>()); } var updates = await updater.GetUpdateInfoAsync().ConfigureAwait(false); return(updates .Where(x => x.Version > currentVersion) .ToArray()); }
static void Main(string[] args) { if (args.Length < 2 || !args[0].Equals("AnagramChecker")) { Console.WriteLine("Please enter valid arguments."); return; } if (args[1].Equals("check") && args.Length == 4) { AnagramChecker checker = new AnagramChecker(); if (checker.CheckTwoWords(args[2], args[3])) { Console.WriteLine(args[2] + " and " + args[3] + "are anagrams"); } else { Console.WriteLine(args[2] + " and " + args[3] + "are no anagrams"); } return; } if (args[1].Equals("getKnown") && args.Length == 3) { var config = new ConfigurationBuilder(); config.AddJsonFile("config.json"); config.AddEnvironmentVariables(); var dictionaryReader = new DictionaryFileReader(config.Build()); var dictionary = dictionaryReader.ReadDictionary(); var key = new AnagramChecker().SortAscending(args[2]); if (dictionary.ContainsKey(key)) { foreach (var word in dictionary[key]) { if (!word.Equals(args[2])) { Console.WriteLine(word); } } } else { Console.WriteLine("No known anagrams found"); } return; } Console.WriteLine("Please enter valid arguments."); }
public IActionResult Get([FromQuery] string w) { var dfr = new DictionaryFileReader(); Dictionary d = dfr.Read(); var result = dfr.GetKnown(d, w); if (result == null) { return(BadRequest()); } else { return(Ok(result.ToArray())); } }
public async Task <IEnumerable <string> > GetKnownWords([FromQuery] string w) { if (string.IsNullOrEmpty(w)) { return(null); } IConfiguration config = new ConfigurationBuilder().AddJsonFile("config.json").Build(); IDictionaryReader reader = new DictionaryFileReader(config); string dictionaryText = await reader.ReadDictionary(); Words word = new Words(); IEnumerable <string> words = word.getKnownWords(dictionaryText, w); return(words); }
public static void getKnownWords(String[] args, IConfiguration config) { IDictionaryReader reader = new DictionaryFileReader(config); Words w = new Words(); string dictionaryText = reader.ReadDictionary(); List <string> words = w.getKnownWords(dictionaryText, args[1]); if (words.Count != 0) { foreach (string s in words) { Console.WriteLine(s); } } else { Console.WriteLine("No known anagrams found"); } }
static void Main(string[] args) { if (args.Length != 3 && args.Length != 2) { Console.WriteLine("Please enter check or getKnown followed by the parameters"); return; } var awc = new AnagramWordsChecker(); var dfr = new DictionaryFileReader(); switch (args[0]) { case "check": if (awc.Check(args[1], args[2])) { Console.WriteLine("\"" + args[1] + "\" and " + "\"" + args[2] + "\" are anagrams"); } else { Console.WriteLine("\"" + args[1] + "\" and " + "\"" + args[2] + "\" are no anagrams"); } break; case "getKnown": Dictionary d = dfr.Read(); var result = dfr.GetKnown(d, args[1]); foreach (var s in result) { Console.WriteLine(s); } break; default: Console.WriteLine("Please enter a type (check or getKnown) and two strings!"); break; } }
private static LocalizableStrings LoadAreaNames() { lock (_glossaryNode) { if (_glossaryNode.Value != null) { XmlElement node = _glossaryNode.Value.GetChildElement("AreaNames"); return(LocalizableString.FromXml(node)); } ArchiveDirectoryEntry dir = Archives.GetEntry <ArchiveDirectoryEntry>(SourcePath); ArchiveFileEntry entry1 = dir.GetChildEntry <ArchiveFileEntry>(AreaNamesFileName); LocalizableStrings result = new LocalizableStrings(256); using (DictionaryFileReader dicReader = new DictionaryFileReader(entry1.OpenReadableContentStream())) foreach (string title in dicReader.Titles) { result.Add(new LocalizableString(title, title)); } return(result); } }