public static void Test(string[] args) { if (args.Length < 2) { Console.WriteLine("Usage: "); Console.WriteLine(" fixer.exe <trainingFile> <testingFile>"); Console.WriteLine(); Console.WriteLine(" Learn typos kinds on files pair: <trainingFile> and <trainingFile>.typos"); Console.WriteLine(" Try to fix typos in file <testingFile>.typos"); Console.WriteLine(" If <testingFile> exists, measure accuracy of the result"); return; } //!!! Do not change this code!!!! var correctWords = File.ReadAllLines(args[0]); var wordsWithTypos = File.ReadAllLines(args[0] + ".typos"); var words2ToFix = File.ReadAllLines(args[1] + ".typos"); var fixer = new TyposFixer(); fixer.Learn(correctWords.Zip(wordsWithTypos, (w, t) => new WordTypo(w, t)).ToArray()); var fixedWords2 = words2ToFix.Select(fixer.FixWord).ToArray(); File.WriteAllLines(args[1] + ".fixed", fixedWords2); if (File.Exists(args[1])) { var correctWords2 = File.ReadAllLines(args[1]); CheckAccuracy(correctWords2, words2ToFix, fixedWords2); } }
static void Main(string[] args) { if (args.Length < 2) { Console.WriteLine("Usage: "); Console.WriteLine(" fixer.exe <trainingFile> <testingFile>"); Console.WriteLine(); Console.WriteLine(" Learn typos kinds on files pair: <trainingFile> and <trainingFile>.typos"); Console.WriteLine(" Try to fix typos in file <testingFile>.typos"); Console.WriteLine(" If <testingFile> exists, measure accuracy of the result"); return; } //!!! Do not change this code!!!! var correctWords = File.ReadAllLines(args[0]); var wordsWithTypos = File.ReadAllLines(args[0] + ".typos"); var words2ToFix = File.ReadAllLines(args[1] + ".typos"); var fixer = new TyposFixer(); fixer.Learn(correctWords.Zip(wordsWithTypos, Tuple.Create).ToArray()); var fixedWords2 = words2ToFix.Select(fixer.FixWord).ToArray(); File.WriteAllLines(args[1] + ".fixed", fixedWords2); if (File.Exists(args[1])) { var correctWords2 = File.ReadAllLines(args[1]); CheckAccuracy(correctWords2, words2ToFix, fixedWords2); } }