Example #1
0
 public SimpleContext(NaturalClass nc, IEnumerable<SymbolicFeatureValue> variables)
 {
     _nc = nc;
     _variables = new ReadOnlyCollection<SymbolicFeatureValue>(variables.ToArray());
     _fs = _nc.FeatureStruct.DeepClone();
     foreach (SymbolicFeatureValue var in _variables)
         _fs.AddValue(var.Feature, var);
     _fs.Freeze();
 }
Example #2
0
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="ctxt">The simple context.</param>
 public NaturalClassContext(NaturalClassContext ctxt)
     : base(ctxt)
 {
     m_natClass = ctxt.m_natClass;
     if (ctxt.m_variables != null)
     {
         m_variables     = new Dictionary <string, bool>(ctxt.m_variables);
         m_antiVariables = new Dictionary <string, bool>(ctxt.m_antiVariables);
         m_alphaVars     = ctxt.m_alphaVars;
     }
 }
Example #3
0
 public SimpleContext(NaturalClass nc, IEnumerable <SymbolicFeatureValue> variables)
 {
     _nc        = nc;
     _variables = new ReadOnlyCollection <SymbolicFeatureValue>(variables.ToArray());
     _fs        = _nc.FeatureStruct.DeepClone();
     foreach (SymbolicFeatureValue var in _variables)
     {
         _fs.AddValue(var.Feature, var);
     }
     _fs.Freeze();
 }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SimpleContext"/> class from a natural class.
 /// </summary>
 /// <param name="natClass">The natural class.</param>
 /// <param name="variables">The variables.</param>
 /// <param name="alphaVars">The alpha variables.</param>
 public NaturalClassContext(NaturalClass natClass, IDictionary <string, bool> variables, AlphaVariables alphaVars)
     : base(natClass.Features.Clone(), natClass.AntiFeatures.Clone())
 {
     m_natClass      = natClass;
     m_variables     = variables;
     m_alphaVars     = alphaVars;
     m_antiVariables = new Dictionary <string, bool>(variables.Count);
     foreach (KeyValuePair <string, bool> kvp in variables)
     {
         m_antiVariables[kvp.Key] = !kvp.Value;
     }
 }
Example #5
0
 /// <summary>
 /// Adds the natural class.
 /// </summary>
 /// <param name="nc">The natural class.</param>
 public void AddNaturalClass(NaturalClass nc)
 {
     m_natClasses.Add(nc);
 }
Example #6
0
		/// <summary>
		/// Adds the natural class.
		/// </summary>
		/// <param name="nc">The natural class.</param>
		public void AddNaturalClass(NaturalClass nc)
		{
			m_natClasses.Add(nc);
		}
Example #7
0
		/// <summary>
		/// Copy constructor.
		/// </summary>
		/// <param name="ctxt">The simple context.</param>
		public NaturalClassContext(NaturalClassContext ctxt)
			: base(ctxt)
		{
			m_natClass = ctxt.m_natClass;
			if (ctxt.m_variables != null)
			{
				m_variables = new Dictionary<string, bool>(ctxt.m_variables);
				m_antiVariables = new Dictionary<string, bool>(ctxt.m_antiVariables);
				m_alphaVars = ctxt.m_alphaVars;
			}
		}
Example #8
0
		/// <summary>
		/// Initializes a new instance of the <see cref="SimpleContext"/> class from a natural class.
		/// </summary>
		/// <param name="natClass">The natural class.</param>
		/// <param name="variables">The variables.</param>
		/// <param name="alphaVars">The alpha variables.</param>
		public NaturalClassContext(NaturalClass natClass, IDictionary<string, bool> variables, AlphaVariables alphaVars)
			: base(natClass.Features.Clone(), natClass.AntiFeatures.Clone())
		{
			m_natClass = natClass;
			m_variables = variables;
			m_alphaVars = alphaVars;
			m_antiVariables = new Dictionary<string, bool>(variables.Count);
			foreach (KeyValuePair<string, bool> kvp in variables)
				m_antiVariables[kvp.Key] = !kvp.Value;
		}
Example #9
0
		void LoadSegNatClass(XmlElement natClassNode)
		{
			string id = natClassNode.GetAttribute("id");
			string name = natClassNode.SelectSingleNode("Name").InnerText;
			NaturalClass natClass = new NaturalClass(id, name, m_curMorpher);
			XmlNodeList segList = natClassNode.SelectNodes("Segment");
			FeatureBundle fb = null;
			if (segList != null)
			{
				foreach (XmlNode segNode in segList)
				{
					XmlElement segElem = segNode as XmlElement;

					CharacterDefinitionTable charDefTable = GetCharDefTable(segElem.GetAttribute("characterTable"));
					string strRep = m_repIds[segElem.GetAttribute("representation")];
					SegmentDefinition segDef = charDefTable.GetSegmentDefinition(strRep);
					if (m_curMorpher.PhoneticFeatureSystem.HasFeatures)
					{
						if (fb == null)
							fb = segDef.SynthFeatures.Clone();
						else
							fb.Intersection(segDef.SynthFeatures);
					}
					else
					{
						natClass.AddSegmentDefinition(segDef);
					}
				}
			}
			if (fb == null)
				fb = new FeatureBundle(false, m_curMorpher.PhoneticFeatureSystem);
			natClass.Features = fb;

			m_curMorpher.AddNaturalClass(natClass);
		}
Example #10
0
		void LoadFeatNatClass(XmlElement natClassNode)
		{
			string id = natClassNode.GetAttribute("id");
			string name = natClassNode.SelectSingleNode("Name").InnerText;
			NaturalClass natClass = new NaturalClass(id, name, m_curMorpher);
			ICollection<FeatureValue> featVals = LoadFeatValues(natClassNode);
			natClass.Features = new FeatureBundle(featVals, m_curMorpher.PhoneticFeatureSystem);

			m_curMorpher.AddNaturalClass(natClass);
		}
Example #11
0
        private void LoadNaturalClass(XElement natClassElem)
        {
            NaturalClass nc = null;
            switch (natClassElem.Name.LocalName)
            {
                case "FeatureNaturalClass":
                    nc = new NaturalClass(LoadFeatureStruct(natClassElem, _language.PhonologicalFeatureSystem))
                    {
                        Name = (string) natClassElem.Element("Name")
                    };
                    break;

                case "SegmentNaturalClass":
                    nc = new SegmentNaturalClass(natClassElem.Elements("Segment").Select(se => _charDefs[(string) se.Attribute("segment")]))
                    {
                        Name = (string) natClassElem.Element("Name")
                    };
                    break;
            }

            _language.NaturalClasses.Add(nc);
            _natClasses[(string) natClassElem.Attribute("id")] = nc;
        }