Example #1
0
		/// <summary>
		/// Copy constructor.
		/// </summary>
		/// <param name="ctxt">The simple context.</param>
		public SimpleContext(SimpleContext ctxt)
			: base(ctxt)
		{
			m_featSys = ctxt.m_featSys;
			m_featureValues = new FeatureBundle(ctxt.m_featureValues);
			m_antiFeatureValues = new FeatureBundle(ctxt.m_antiFeatureValues);
		}
Example #2
0
		/// <summary>
		/// Initializes a new instance of the <see cref="Segment"/> class.
		/// </summary>
		/// <param name="segDef">The segment definition.</param>
		/// <param name="features">The features.</param>
		public Segment(SegmentDefinition segDef, FeatureBundle featureValues)
		{
			m_segDef = segDef;
			m_desc = segDef.StrRep;
			m_featureValues = featureValues;
			m_instantiatedSegs = new Set<SegmentDefinition>();
		}
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Segment"/> class.
 /// </summary>
 /// <param name="segDef">The segment definition.</param>
 /// <param name="features">The features.</param>
 public Segment(SegmentDefinition segDef, FeatureBundle featureValues)
 {
     m_segDef           = segDef;
     m_desc             = segDef.StrRep;
     m_featureValues    = featureValues;
     m_instantiatedSegs = new Set <SegmentDefinition>();
 }
Example #4
0
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="ctxt">The simple context.</param>
 public SimpleContext(SimpleContext ctxt)
     : base(ctxt)
 {
     m_featSys           = ctxt.m_featSys;
     m_featureValues     = new FeatureBundle(ctxt.m_featureValues);
     m_antiFeatureValues = new FeatureBundle(ctxt.m_antiFeatureValues);
 }
Example #5
0
        protected override Segment UnapplyDeletionFeatures(VariableValues instantiatedVars)
        {
            FeatureBundle feats = new FeatureBundle(false, m_featSys);

            feats.AddAntiValues(m_antiFeatureValues);
            return(new Segment(m_segDef, feats));
        }
 public bool Equals(FeatureBundle other)
 {
     if (other == null)
     {
         return(false);
     }
     return(m_flags1 == other.m_flags1 && m_flags2 == other.m_flags2);
 }
        SegmentDefinition ComposeModifier(SegmentDefinition baseChar, SegmentDefinition diacritic)
        {
            FeatureBundle fb = baseChar.SynthFeatures.Clone();

            fb.Apply(diacritic.SynthFeatures, true);
            fb.Apply(diacritic.AntiFeatures, false);
            return(new SegmentDefinition(baseChar.StrRep + diacritic.StrRep, fb));
        }
Example #8
0
 public SegmentDefinition(string strRep, CharacterDefinitionTable charDefTable, FeatureBundle fb)
 {
     m_strRep           = strRep;
     m_charDefTable     = charDefTable;
     m_synthFeatures    = fb;
     m_antiFeatures     = new FeatureBundle(m_synthFeatures, true);
     m_analysisFeatures = new FeatureBundle(m_synthFeatures, false);
 }
		public SegmentDefinition(string strRep, CharacterDefinitionTable charDefTable, FeatureBundle fb)
		{
			m_strRep = strRep;
			m_charDefTable = charDefTable;
			m_synthFeatures = fb;
			m_antiFeatures = new FeatureBundle(m_synthFeatures, true);
			m_analysisFeatures = new FeatureBundle(m_synthFeatures, false);
		}
Example #10
0
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="seg">The segment.</param>
 public Segment(Segment seg)
     : base(seg)
 {
     m_desc             = seg.m_desc;
     m_segDef           = seg.m_segDef;
     m_instantiatedSegs = new Set <SegmentDefinition>(seg.m_instantiatedSegs);
     m_featureValues    = seg.m_featureValues.Clone();
     m_isClean          = seg.m_isClean;
 }
Example #11
0
        protected override Segment ApplyInsertionFeatures(VariableValues instantiatedVars)
        {
            // copy over the context's features
            FeatureBundle feats = new FeatureBundle(m_featureValues);

            // apply the context's variable features to the segment's features
            m_alphaVars.Apply(feats, m_variables, instantiatedVars, true);
            return(new Segment(ToString(), feats));
        }
Example #12
0
		/// <summary>
		/// Copy constructor.
		/// </summary>
		/// <param name="seg">The segment.</param>
		public Segment(Segment seg)
			: base(seg)
		{
			m_desc = seg.m_desc;
			m_segDef = seg.m_segDef;
			m_instantiatedSegs = new Set<SegmentDefinition>(seg.m_instantiatedSegs);
			m_featureValues = seg.m_featureValues.Clone();
			m_isClean = seg.m_isClean;
		}
Example #13
0
        protected override Segment UnapplyDeletionFeatures(VariableValues instantiatedVars)
        {
            // in analysis mode, we set all of the feature values
            FeatureBundle feats = new FeatureBundle(true, m_featSys);

            // then unset each anti feature
            feats.Apply(m_antiFeatureValues, false);
            m_alphaVars.ApplyCurrent(feats, m_antiVariables, instantiatedVars);
            return(new Segment(ToString(), feats));
        }
 /// <summary>
 /// Applies the specified variables to the specified feature bundle.
 /// </summary>
 /// <param name="fb">The feature bundle.</param>
 /// <param name="variables">The variables.</param>
 /// <param name="instantiatedVars">The instantiated variables.</param>
 /// <param name="val">if <c>true</c> the feature bundle values will be set, otherwise they will be unset.</param>
 public void Apply(FeatureBundle fb, IDictionary <string, bool> variables, VariableValues instantiatedVars, bool val)
 {
     foreach (KeyValuePair <string, bool> varPolarity in variables)
     {
         foreach (FeatureValue value in GetVarFeatValue(varPolarity.Key, varPolarity.Value, instantiatedVars))
         {
             fb.Set(value, val);
         }
     }
 }
 /// <summary>
 /// Applies the specified feature bundle to this feature bundle.
 /// </summary>
 /// <param name="fb">The feature bundle.</param>
 /// <param name="polarity">The polarity.</param>
 public void Apply(FeatureBundle fb, bool polarity)
 {
     if (polarity)
     {
         AddValues(fb);
     }
     else
     {
         RemoveValues(fb);
     }
 }
        SegmentDefinition ComposeAffricate(SegmentDefinition stop, SegmentDefinition tiebar, SegmentDefinition fricative)
        {
            FeatureBundle fb = stop.SynthFeatures.Clone();

            fb.Apply(fricative.SynthFeatures, true);
            fb.Apply(fricative.AntiFeatures, false);
            // the tie bar will probably set [+delayed-release], so do this last
            fb.Apply(tiebar.SynthFeatures, true);
            fb.Apply(tiebar.AntiFeatures, false);
            return(new SegmentDefinition(stop.StrRep + tiebar.StrRep + fricative.StrRep, fb));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="FeatureBundle"/> class. This constructor
 /// creates an anti feature bundle from the specified feature bundle.
 /// </summary>
 /// <param name="fb">The feature bundle.</param>
 /// <param name="set">if <c>true</c> the specified values will be set, otherwise they will be unset.</param>
 public FeatureBundle(FeatureBundle fb, bool set)
     : this(!set, fb.m_featSys)
 {
     foreach (Feature feature in fb.Features)
     {
         foreach (FeatureValue value in feature.PossibleValues)
         {
             if (!fb.Get(value))
             {
                 Set(value, set);
             }
         }
     }
 }
 /// <summary>
 /// Applies the specified variables that occur in the instantiated variables to the specified feature bundle.
 /// </summary>
 /// <param name="fb">The feature bundle.</param>
 /// <param name="variables">The variables.</param>
 /// <param name="instantiatedVars">The instantiated variables.</param>
 public void ApplyCurrent(FeatureBundle fb, IDictionary <string, bool> variables, VariableValues instantiatedVars)
 {
     foreach (KeyValuePair <string, bool> varPolarity in variables)
     {
         Feature feature = m_varFeatures[varPolarity.Key];
         ICollection <FeatureValue> varValues = instantiatedVars.GetValues(varPolarity.Key);
         if (varValues.Count > 0)
         {
             foreach (FeatureValue value in GetCurVarFeatValue(feature, varValues, varPolarity.Value))
             {
                 fb.Set(value, true);
             }
         }
     }
 }
Example #19
0
        protected virtual SimpleContext CombineFeatures(SimpleContext ctxt)
        {
            SimpleContext result = Clone() as SimpleContext;

            // collect all of the possible values of the features
            List <FeatureValue> featVals = new List <FeatureValue>();

            foreach (Feature feature in Owner.Features)
            {
                featVals.AddRange(feature.PossibleValues);
            }
            // create a mask feature bundle from all possible values
            FeatureBundle mask = new FeatureBundle(featVals, m_featSys);

            FeatureBundle temp = ctxt.FeatureValues.Clone();

            // remove features referenced in the this pattern's context
            temp.RemoveValues(mask);
            // add remaining features from the specified pattern's context to this pattern's context
            result.FeatureValues.AddValues(temp);
            // remove anti features referenced in the specified pattern's context from this pattern's context
            result.AntiFeatureValues.RemoveValues(ctxt.AntiFeatureValues);
            return(result);
        }
Example #20
0
		/// <summary>
		/// Applies the specified feature bundle to this feature bundle.
		/// </summary>
		/// <param name="fb">The feature bundle.</param>
		/// <param name="polarity">The polarity.</param>
		public void Apply(FeatureBundle fb, bool polarity)
		{
			if (polarity)
			{
				AddValues(fb);
			}
			else
			{
				RemoveValues(fb);
			}
		}
Example #21
0
		protected override Segment UnapplyDeletionFeatures(VariableValues instantiatedVars)
		{
			// in analysis mode, we set all of the feature values
			FeatureBundle feats = new FeatureBundle(true, m_featSys);
			// then unset each anti feature
			feats.Apply(m_antiFeatureValues, false);
			m_alphaVars.ApplyCurrent(feats, m_antiVariables, instantiatedVars);
			return new Segment(ToString(), feats);
		}
Example #22
0
		/// <summary>
		/// Adds all of the anti feature values set in the specified feature bundle by performing
		/// a bitwise-nor operation.
		/// </summary>
		/// <param name="fb">The feature bundle.</param>
		public void AddAntiValues(FeatureBundle fb)
		{
			m_flags1 |= ~fb.m_flags1;
			m_flags2 |= ~fb.m_flags2;
		}
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="fb">The feature bundle.</param>
 public FeatureBundle(FeatureBundle fb)
 {
     m_flags1  = fb.m_flags1;
     m_flags2  = fb.m_flags2;
     m_featSys = fb.m_featSys;
 }
Example #24
0
		protected override Segment ApplyInsertionFeatures(VariableValues instantiatedVars)
		{
			// copy over the context's features
			FeatureBundle feats = new FeatureBundle(m_featureValues);
			// apply the context's variable features to the segment's features
			m_alphaVars.Apply(feats, m_variables, instantiatedVars, true);
			return new Segment(ToString(), feats);
		}
Example #25
0
		public void Intersection(FeatureBundle fb)
		{
			m_flags1 &= fb.m_flags1;
			m_flags2 &= fb.m_flags2;
		}
Example #26
0
		/// <summary>
		/// Removes all of the feature values set in the specified feature bundle by performing
		/// a bitwise-nand operation.
		/// </summary>
		/// <param name="fb">The feature bundle.</param>
		public void RemoveValues(FeatureBundle fb)
		{
			m_flags1 &= ~fb.m_flags1;
			m_flags2 &= ~fb.m_flags2;
		}
Example #27
0
		/// <summary>
		/// Determines whether this feature bundle is unifiable with the specified feature bundle.
		/// </summary>
		/// <param name="fb">The feature bundle.</param>
		/// <returns>
		/// 	<c>true</c> if the feature bundles are unifiable, otherwise <c>false</c>.
		/// </returns>
		public bool IsUnifiable(FeatureBundle fb)
		{
			return ((fb.m_flags1 & ~m_flags1) == 0) && ((fb.m_flags2 & ~m_flags2) == 0);
		}
 /// <summary>
 /// Determines whether this feature bundle is unifiable with the specified feature bundle.
 /// </summary>
 /// <param name="fb">The feature bundle.</param>
 /// <returns>
 ///     <c>true</c> if the feature bundles are unifiable, otherwise <c>false</c>.
 /// </returns>
 public bool IsUnifiable(FeatureBundle fb)
 {
     return(((fb.m_flags1 & ~m_flags1) == 0) && ((fb.m_flags2 & ~m_flags2) == 0));
 }
Example #29
0
		/// <summary>
		/// Determines whether this feature bundle and the specified feature bundle are disjoint sets.
		/// </summary>
		/// <param name="fb">The feature bundle.</param>
		/// <returns>
		/// 	<c>true</c> if the feature bundles are disjoint, otherwise <c>false</c>.
		/// </returns>
		public bool IsDisjoint(FeatureBundle fb)
		{
			return ((m_flags1 & fb.m_flags1) == 0) && ((m_flags2 & fb.m_flags2) == 0);
		}
Example #30
0
		/// <summary>
		/// Initializes a new instance of the <see cref="Segment"/> class.
		/// </summary>
		/// <param name="desc">The segment description.</param>
		/// <param name="featureValues">The feature values.</param>
		public Segment(string desc, FeatureBundle featureValues)
		{
			m_desc = desc;
			m_featureValues = featureValues;
			m_instantiatedSegs = new Set<SegmentDefinition>();
		}
Example #31
0
		public bool Equals(FeatureBundle other)
		{
			if (other == null)
				return false;
			return m_flags1 == other.m_flags1 && m_flags2 == other.m_flags2;
		}
Example #32
0
		/// <summary>
		/// Copy constructor.
		/// </summary>
		/// <param name="fb">The feature bundle.</param>
		public FeatureBundle(FeatureBundle fb)
		{
			m_flags1 = fb.m_flags1;
			m_flags2 = fb.m_flags2;
			m_featSys = fb.m_featSys;
		}
Example #33
0
		/// <summary>
		/// Applies the specified variables that occur in the instantiated variables to the specified feature bundle.
		/// </summary>
		/// <param name="fb">The feature bundle.</param>
		/// <param name="variables">The variables.</param>
		/// <param name="instantiatedVars">The instantiated variables.</param>
		public void ApplyCurrent(FeatureBundle fb, IDictionary<string, bool> variables, VariableValues instantiatedVars)
		{
			foreach (KeyValuePair<string, bool> varPolarity in variables)
			{
				Feature feature = m_varFeatures[varPolarity.Key];
				ICollection<FeatureValue> varValues = instantiatedVars.GetValues(varPolarity.Key);
				if (varValues.Count > 0)
				{
					foreach (FeatureValue value in GetCurVarFeatValue(feature, varValues, varPolarity.Value))
						fb.Set(value, true);
				}
			}
		}
Example #34
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Segment"/> class.
 /// </summary>
 /// <param name="desc">The segment description.</param>
 /// <param name="featureValues">The feature values.</param>
 public Segment(string desc, FeatureBundle featureValues)
 {
     m_desc             = desc;
     m_featureValues    = featureValues;
     m_instantiatedSegs = new Set <SegmentDefinition>();
 }
 /// <summary>
 /// Determines whether this feature bundle and the specified feature bundle are disjoint sets.
 /// </summary>
 /// <param name="fb">The feature bundle.</param>
 /// <returns>
 ///     <c>true</c> if the feature bundles are disjoint, otherwise <c>false</c>.
 /// </returns>
 public bool IsDisjoint(FeatureBundle fb)
 {
     return(((m_flags1 & fb.m_flags1) == 0) && ((m_flags2 & fb.m_flags2) == 0));
 }
Example #36
0
		protected override Segment UnapplyDeletionFeatures(VariableValues instantiatedVars)
		{
			FeatureBundle feats = new FeatureBundle(false, m_featSys);
			feats.AddAntiValues(m_antiFeatureValues);
			return new Segment(m_segDef, feats);
		}
Example #37
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SimpleContext"/> class.
 /// </summary>
 public SimpleContext(FeatureBundle featureValues, FeatureBundle antiFeatureValues)
 {
     m_featureValues     = featureValues;
     m_antiFeatureValues = antiFeatureValues;
     m_featSys           = m_featureValues.FeatureSystem;
 }
Example #38
0
		/// <summary>
		/// Initializes a new instance of the <see cref="SimpleContext"/> class.
		/// </summary>
		public SimpleContext(FeatureBundle featureValues, FeatureBundle antiFeatureValues)
		{
			m_featureValues = featureValues;
			m_antiFeatureValues = antiFeatureValues;
			m_featSys = m_featureValues.FeatureSystem;
		}
Example #39
0
		protected virtual SimpleContext CombineFeatures(SimpleContext ctxt)
		{
			SimpleContext result = Clone() as SimpleContext;

			// collect all of the possible values of the features
			List<FeatureValue> featVals = new List<FeatureValue>();
			foreach (Feature feature in Owner.Features)
				featVals.AddRange(feature.PossibleValues);
			// create a mask feature bundle from all possible values
			FeatureBundle mask = new FeatureBundle(featVals, m_featSys);

			FeatureBundle temp = ctxt.FeatureValues.Clone();
			// remove features referenced in the this pattern's context
			temp.RemoveValues(mask);
			// add remaining features from the specified pattern's context to this pattern's context
			result.FeatureValues.AddValues(temp);
			// remove anti features referenced in the specified pattern's context from this pattern's context
			result.AntiFeatureValues.RemoveValues(ctxt.AntiFeatureValues);
			return result;
		}
 /// <summary>
 /// Adds all of the anti feature values set in the specified feature bundle by performing
 /// a bitwise-nor operation.
 /// </summary>
 /// <param name="fb">The feature bundle.</param>
 public void AddAntiValues(FeatureBundle fb)
 {
     m_flags1 |= ~fb.m_flags1;
     m_flags2 |= ~fb.m_flags2;
 }
Example #41
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);
		}
 /// <summary>
 /// Removes all of the feature values set in the specified feature bundle by performing
 /// a bitwise-nand operation.
 /// </summary>
 /// <param name="fb">The feature bundle.</param>
 public void RemoveValues(FeatureBundle fb)
 {
     m_flags1 &= ~fb.m_flags1;
     m_flags2 &= ~fb.m_flags2;
 }
 public void Intersection(FeatureBundle fb)
 {
     m_flags1 &= fb.m_flags1;
     m_flags2 &= fb.m_flags2;
 }
Example #44
0
		/// <summary>
		/// Applies the specified variables to the specified feature bundle.
		/// </summary>
		/// <param name="fb">The feature bundle.</param>
		/// <param name="variables">The variables.</param>
		/// <param name="instantiatedVars">The instantiated variables.</param>
		/// <param name="val">if <c>true</c> the feature bundle values will be set, otherwise they will be unset.</param>
		public void Apply(FeatureBundle fb, IDictionary<string, bool> variables, VariableValues instantiatedVars, bool val)
		{
			foreach (KeyValuePair<string, bool> varPolarity in variables)
			{
				foreach (FeatureValue value in GetVarFeatValue(varPolarity.Key, varPolarity.Value, instantiatedVars))
					fb.Set(value, val);
			}
		}
Example #45
0
		/// <summary>
		/// Initializes a new instance of the <see cref="FeatureBundle"/> class. This constructor
		/// creates an anti feature bundle from the specified feature bundle.
		/// </summary>
		/// <param name="fb">The feature bundle.</param>
		/// <param name="set">if <c>true</c> the specified values will be set, otherwise they will be unset.</param>
		public FeatureBundle(FeatureBundle fb, bool set)
			: this(!set, fb.m_featSys)
		{
			foreach (Feature feature in fb.Features)
			{
				foreach (FeatureValue value in feature.PossibleValues)
				{
					if (!fb.Get(value))
					{
						Set(value, set);
					}
				}
			}
		}