/// <summary>
        /// Checks whether two UnitLatticePhoneCandidate are equal.
        /// </summary>
        /// <param name="refCandidate">Reference UnitLatticePhoneCandidate.</param>
        /// <param name="trgCandidate">Target UnitLatticePhoneCandidate.</param>
        /// <returns>Bool that represents equal or not.</returns>
        public static bool Equals(UnitLatticePhoneCandidate refCandidate, UnitLatticePhoneCandidate trgCandidate)
        {
            Debug.Assert(refCandidate != null, "refCandidate is null");
            Debug.Assert(trgCandidate != null, "trgCandidate is null");
            Debug.Assert(string.Equals(refCandidate.Text, trgCandidate.Text), "The phone text of refCandidate and trgCandidate are not equal");

            bool isEqual = false;

            // The two candidates are equal if they have the same recording sentence id and index of none silence phone
            if (string.Equals(refCandidate.SentenceId, trgCandidate.SentenceId) &&
                refCandidate.IndexNonSilence == trgCandidate.IndexNonSilence)
            {
                isEqual = true;
            }

            return isEqual;
        }
        /// <summary>
        /// Load one phone from the xmltextreader.
        /// </summary>
        /// <param name="reader">XmlTextReader to read XML file.</param>
        /// <param name="contentController">Content controller.</param>
        public void Load(XmlTextReader reader, object contentController)
        {
            Debug.Assert(reader != null, "XmlTextReader is null");

            // Get phone text, triphone, group, candidateGroupId
            this.Text = reader.GetAttribute("txt");
            this.Triphone = reader.GetAttribute("triphone");
            this.Log = reader.GetAttribute("log");

            if (!string.IsNullOrEmpty(reader.GetAttribute("candidateGroupId")))
            {
                this.CandidateGroupId = int.Parse(reader.GetAttribute("candidateGroupId"));
            }

            // get the phone candidates
            if (!reader.IsEmptyElement)
            {
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element && reader.Name == "cand")
                    {
                        UnitLatticePhoneCandidate candidate = new UnitLatticePhoneCandidate();
                        candidate.Load(reader, contentController);

                        this.Candidates.Add(candidate);
                    }
                    else if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "phone")
                    {
                        break;
                    }
                }
            }
        }