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

namespace PinyinModel
{
    internal class PinyinSyllable
    {
        private HashSet<string> syllables;

        public PinyinSyllable(string filename)
        {
            using (StreamReader reader = File.OpenText(filename))
            {
                Console.Write("Loading pinyin syllable list from {0} ... ", filename);
                syllables = new HashSet<string>();
                string line = null;
                while ((line = reader.ReadLine()) != null)
                {
                    syllables.Add(line);
                }
                Console.WriteLine("Done.");
            }
        }

        public bool IsValidSyllable(string syllable)
        {
            return syllables.Contains(syllable);
        }
    }
}
