Exemplo n.º 1
0
        /// <summary>
        /// Generate a LexicalItem from a dictionary.
        /// </summary>
        /// <param name="prons">Pronunciation dictionary.</param>
        private void GenerateLexicalItem(Dictionary<string, Collection<string>> prons)
        {
            Helper.ThrowIfNull(prons);

            foreach (string key in prons.Keys)
            {
                LexiconPronunciation pron = new LexiconPronunciation(_language);
                pron.Symbolic = key;
                foreach (string pos in prons[key])
                {
                    PosItem posItem = new PosItem(pos);
                    LexiconItemProperty property = new LexiconItemProperty(posItem);
                    pron.Properties.Add(property);
                }

                _item.Pronunciations.Add(pron);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Load PosItem from XmlNode.
        /// </summary>
        /// <param name="propertyNode">XmlNode.</param>
        /// <param name="nsmgr">XmlNamespaceManager.</param>
        /// <returns>PosItem.</returns>
        internal static PosItem Load(XmlNode propertyNode, XmlNamespaceManager nsmgr)
        {
            Debug.Assert(propertyNode != null && nsmgr != null);

            PosItem posItem = null;
            if (propertyNode.SelectSingleNode("tts:pos", nsmgr) != null)
            {
                posItem = new PosItem(propertyNode.SelectSingleNode("tts:pos/@v", nsmgr).InnerText);
                XmlNode originalValueNode = propertyNode.SelectSingleNode("tts:pos/@vo", nsmgr);
                if (originalValueNode != null && !string.IsNullOrEmpty(originalValueNode.InnerText))
                {
                    posItem.OldValue = originalValueNode.InnerText;
                }
            }

            return posItem;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LexiconItemProperty"/> class.
        /// Construction from POS and Gender item.
        /// </summary>
        /// <param name="pos">POS value of this property.</param>
        /// <param name="gender">Gender value of this property.</param>
        public LexiconItemProperty(PosItem pos, GenderItem gender)
        {
            if (pos == null)
            {
                throw new ArgumentNullException("pos");
            }

            if (gender == null)
            {
                throw new ArgumentNullException("gender");
            }

            PartOfSpeech = pos;
            Gender = gender;
        }
Exemplo n.º 4
0
 /// <summary>
 /// Clone function.
 /// </summary>
 /// <returns>PosItem.</returns>
 public PosItem Clone()
 {
     PosItem clonedItem = new PosItem();
     this.CopyTo(clonedItem);
     clonedItem.Pos = _pos;
     return clonedItem;
 }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LexiconItemProperty"/> class.
        /// Construction from POS item.
        /// </summary>
        /// <param name="pos">POS value of this property.</param>
        public LexiconItemProperty(PosItem pos)
        {
            if (pos == null)
            {
                throw new ArgumentNullException("pos");
            }

            PartOfSpeech = pos;
        }