Quick actions

cmd+k|ctrl+k

Navigation

Languages

SpellChecker

Snippet info

Language

Csharp

Visibility

public

Author

sivan606

Created

2019-05-29T23:13:35Z

Updated

2019-05-29T23:59:01Z

using System;
using System.Collections.Generic;
using System.IO;

class SpellChecker {
    static void Main(string[] args) {
        FileStream fs_dict = new FileStream(args[0], FileMode.Open, FileAccess.Read),
            fs_in = new FileStream(args[1], FileMode.Open, FileAccess.Read),
            fs_out = new FileStream(args[2], FileMode.Create, FileAccess.Write);
        StreamReader sr_dict = new StreamReader(fs_dict);
        HashSet <string> dict = new HashSet <string>;
        while ((string word = sr_dict.ReadLine()) != null)
            dict.Add(word);
        sr_dict.Close();
        StreamReader sr_in = new StreamReader(fs_in);
        StreamWriter sw_out = new StreamReader(fs_out);
        bool flag = false;
        while ((string line = sr_dict.ReadLine()) != null)
        {
            string[] words = line.Split(new Char[] {' ', ',', '.', '-'});
            for (int i = 0; i < words.Length; ++i)
                if (words[i] != "" && !dict.Contains(words[i]))
				{
					sw_out.WriteLine(words[i]);
					flag = true;
				}
        }
		sr_in.Close();
		sw_out.Close()
        if (flag)
            Console.WriteLine("WARNING");
        else
            Console.WriteLine("OK");
    }
}
INFO