/// <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); } }
/// <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; }
/// <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; }
/// <summary> /// Clone function. /// </summary> /// <returns>PosItem.</returns> public PosItem Clone() { PosItem clonedItem = new PosItem(); this.CopyTo(clonedItem); clonedItem.Pos = _pos; return clonedItem; }
/// <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; }