/// <summary>
        /// Build unit candidate list from phone segment list.
        /// </summary>
        /// <param name="type">Unit candidate type.</param>
        public void BuildUnitCandidateList(UnitCandidateType type)
        {
            foreach (Sentence sentence in Sentences.Values)
            {
                sentence.BuildUnitCandidates(type);
            }

            // create unit candidate Id
            UnitCandidateNameIds = new Dictionary<string, int>();
            int id = 0;
            foreach (string candidateName in
                Sentences.Values.SelectMany(sent => sent.Candidates).Select(cand => cand.Name).Distinct().OrderBy(s => s))
            {
                UnitCandidateNameIds[candidateName] = id++;
            }

            TagIds();
        }
 /// <summary>
 /// Build Unit Candidate List according to the unit candidate type.
 /// </summary>
 /// <param name="type">Unit type.</param>
 public void BuildUnitCandidates(UnitCandidateType type)
 {
     if (type == UnitCandidateType.Phone)
     {
         foreach (PhoneSegment phoneSegment in PhoneSegments)
         {
             _unitCandidates.Add(new PhoneCandidate(phoneSegment));
         }
     }
     else if (type == UnitCandidateType.Halfphone)
     {
         foreach (PhoneSegment phoneSegment in PhoneSegments)
         {
             _unitCandidates.Add(new HalfPhoneCandidate(phoneSegment, true));
             _unitCandidates.Add(new HalfPhoneCandidate(phoneSegment, false));
         }
     }
     else
     {
         throw new Exception(Helper.NeutralFormat("Unsupported Unit Candidate Type: {0}", type.ToString()));
     }
 }