/// <summary>
        /// Loads full-context label or mono align label from master label file.
        /// </summary>
        /// <param name="masterLabelFile">The file name of the master label file.</param>
        public void Load(string masterLabelFile)
        {
            using (StreamReader reader = new StreamReader(masterLabelFile))
            {
                // This is the header of master label file.
                string line = reader.ReadLine();
                if (line != MasterLabelFileHeader)
                {
                    throw new InvalidDataException(Helper.NeutralFormat("Master label file header expected, but input \"{0}\"", line));
                }

                while (!reader.EndOfStream)
                {
                    // Read the line for sentence id.
                    line = reader.ReadLine();
                    Match match = RegexOfSentId.Match(line);
                    if (match.Success)
                    {
                        bool endOfSentenceExist;
                        string sentId = match.Groups[1].Value;
                        if (_idKeyedSentences.ContainsKey(sentId))
                        {
                            // Not the first time to load the sentence.
                            endOfSentenceExist = _idKeyedSentences[sentId].Load(reader);
                        }
                        else
                        {
                            // Load the sentence in first time.
                            Sentence sentence = new Sentence { Id = sentId, TrainingSet = this };
                            endOfSentenceExist = sentence.Load(reader);
                            _idKeyedSentences[sentId] = sentence;
                        }

                        if (!endOfSentenceExist)
                        {
                            throw new InvalidDataException("Sentence end is expected");
                        }
                    }
                    else
                    {
                        throw new InvalidDataException(Helper.NeutralFormat("Sentence id expected, but input \"{0}\"", line));
                    }
                }
            }
        }
        /// <summary>
        /// Converts label files to master label file.
        /// </summary>
        /// <param name="alignmentDir">The directory of alignment files.</param>
        /// <param name="mlfFileName">The name of target master label file.</param>
        public static void ConvertLabelFilesToMlf(string alignmentDir, string mlfFileName)
        {
            TrainingSentenceSet set = new TrainingSentenceSet();
            foreach (string labelFile in Directory.GetFiles(alignmentDir, Helper.NeutralFormat("*.{0}", FileExtensions.LabelFile)))
            {
                Sentence sentence = new Sentence();
                using (StreamReader sr = new StreamReader(labelFile))
                {
                    if (sentence.Load(sr))
                    {
                        throw new InvalidDataException("Sentence end is not expected");
                    }
                }

                string id = Path.GetFileNameWithoutExtension(labelFile);
                set.Sentences.Add(id, sentence);
            }

            set.Save(mlfFileName, LabelTypeOptions.FullContext, LabelAlignOptions.StateAlign, true);
        }