Esempio n. 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);
 }
Esempio n. 2
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);
		}
Esempio n. 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FeatureBundle"/> class.
 /// </summary>
 /// <param name="featVals">The feature values.</param>
 /// <param name="set">if <c>true</c> the specified values will be set, otherwise they will be unset.</param>
 /// <param name="featSys">The feat system.</param>
 public FeatureBundle(IEnumerable <FeatureValue> featVals, FeatureSystem featSys)
     : this(false, featSys)
 {
     foreach (FeatureValue value in featVals)
     {
         Set(value, true);
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Language"/> class.
 /// </summary>
 public Language()
 {
     _strata = new ObservableCollection <Stratum>();
     _strata.CollectionChanged += StrataChanged;
     PhonologicalFeatureSystem  = new FeatureSystem();
     SyntacticFeatureSystem     = new SyntacticFeatureSystem();
     _naturalClasses            = new List <NaturalClass>();
     _stemNames             = new List <StemName>();
     _mprFeatures           = new List <MprFeature>();
     _mprFeatureGroups      = new List <MprFeatureGroup>();
     _tables                = new List <CharacterDefinitionTable>();
     _families              = new List <LexFamily>();
     _prules                = new List <IPhonologicalRule>();
     _morphemeCoOccurRules  = new List <MorphemeCoOccurrenceRule>();
     _allomorphCoOccurRules = new List <AllomorphCoOccurrenceRule>();
 }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Language"/> class.
 /// </summary>
 public Language()
 {
     _strata = new ObservableCollection<Stratum>();
     _strata.CollectionChanged += StrataChanged;
     PhonologicalFeatureSystem = new FeatureSystem();
     SyntacticFeatureSystem = new SyntacticFeatureSystem();
     _naturalClasses = new List<NaturalClass>();
     _stemNames = new List<StemName>();
     _mprFeatures = new List<MprFeature>();
     _mprFeatureGroups = new List<MprFeatureGroup>();
     _tables = new List<CharacterDefinitionTable>();
     _families = new List<LexFamily>();
     _prules = new List<IPhonologicalRule>();
     _morphemeCoOccurRules = new List<MorphemeCoOccurrenceRule>();
     _allomorphCoOccurRules = new List<AllomorphCoOccurrenceRule>();
 }
Esempio n. 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Morpher"/> class.
 /// </summary>
 /// <param name="id">The id.</param>
 /// <param name="language">The language.</param>
 public Morpher(string id, string language)
     : base(id, language, null)
 {
     m_strata          = new HCObjectSet <Stratum>();
     m_phoneticFeatSys = new FeatureSystem();
     m_headFeatSys     = new FeatureSystem();
     m_footFeatSys     = new FeatureSystem();
     m_charDefTables   = new HCObjectSet <CharacterDefinitionTable>();
     m_natClasses      = new HCObjectSet <NaturalClass>();
     m_prules          = new HCObjectSet <PhonologicalRule>();
     m_mrules          = new HCObjectSet <MorphologicalRule>();
     m_lexicon         = new Lexicon();
     m_templates       = new HCObjectSet <AffixTemplate>();
     m_mprFeatGroups   = new HCObjectSet <MPRFeatureGroup>();
     m_mprFeatures     = new HCObjectSet <MPRFeature>();
     m_pos             = new HCObjectSet <PartOfSpeech>();
     m_allomorphs      = new HCObjectSet <Allomorph>();
 }
Esempio n. 7
0
		/// <summary>
		/// Initializes a new instance of the <see cref="Morpher"/> class.
		/// </summary>
		/// <param name="id">The id.</param>
		/// <param name="language">The language.</param>
		public Morpher(string id, string language)
			: base(id, language, null)
		{
			m_strata = new HCObjectSet<Stratum>();
			m_phoneticFeatSys = new FeatureSystem();
			m_headFeatSys = new FeatureSystem();
			m_footFeatSys = new FeatureSystem();
			m_charDefTables = new HCObjectSet<CharacterDefinitionTable>();
			m_natClasses = new HCObjectSet<NaturalClass>();
			m_prules = new HCObjectSet<PhonologicalRule>();
			m_mrules = new HCObjectSet<MorphologicalRule>();
			m_lexicon = new Lexicon();
			m_templates = new HCObjectSet<AffixTemplate>();
			m_mprFeatGroups = new HCObjectSet<MPRFeatureGroup>();
			m_mprFeatures = new HCObjectSet<MPRFeature>();
			m_pos = new HCObjectSet<PartOfSpeech>();
			m_allomorphs = new HCObjectSet<Allomorph>();
		}
Esempio n. 8
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;
		}
Esempio n. 9
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;
 }
Esempio n. 10
0
		/// <summary>
		/// Initializes a new instance of the <see cref="FeatureBundle"/> class.
		/// </summary>
		/// <param name="initialVal">The initial value for all values in the feature bundle.</param>
		/// <param name="featSys">The feature system.</param>
		public FeatureBundle(bool initialVal, FeatureSystem featSys)
		{
			SetAll(initialVal);
			m_featSys = featSys;
		}
Esempio n. 11
0
		void LoadFeatureSystem(XmlElement featSysNode, FeatureSystem featSys)
		{
			XmlNodeList features = featSysNode.SelectNodes("FeatureDefinition[@isActive='yes']");
			foreach (XmlNode featDefNode in features)
				LoadFeature(featDefNode as XmlElement, featSysNode, featSys);
		}
Esempio n. 12
0
		FeatureValues LoadSynFeats(XmlNode node, FeatureSystem featSys)
		{
			FeatureValues fvs = new FeatureValues();
			if (node != null)
			{
				XmlNodeList featValList = node.SelectNodes("FeatureValueList[@isActive='yes']");
				foreach (XmlNode featValNode in featValList)
				{
					XmlElement featValElem = featValNode as XmlElement;
					string featId = featValElem.GetAttribute("feature");
					Feature feature = featSys.GetFeature(featId);
					if (feature == null)
						throw CreateUndefinedObjectException(string.Format(HCStrings.kstidUnknownFeat, featId), featId);
					string valueIdsStr = featValElem.GetAttribute("values");
					if (!string.IsNullOrEmpty(valueIdsStr))
					{
						string[] valueIds = valueIdsStr.Split(' ');
						foreach (string valueId in valueIds)
						{
							FeatureValue value = feature.GetPossibleValue(valueId);
							if (value == null)
								throw CreateUndefinedObjectException(string.Format(HCStrings.kstidUnknownFeatValue, valueId, featId), valueId);
							fvs.Add(feature, new ClosedValueInstance(value));
						}
					}
					else
					{
						fvs.Add(feature, LoadSynFeats(featValNode, featSys));
					}
				}
			}

			return fvs;
		}
Esempio n. 13
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;
 }
Esempio n. 14
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;
		}
Esempio n. 15
0
		/// <summary>
		/// Initializes a new instance of the <see cref="FeatureBundle"/> class.
		/// </summary>
		/// <param name="featVals">The feature values.</param>
		/// <param name="set">if <c>true</c> the specified values will be set, otherwise they will be unset.</param>
		/// <param name="featSys">The feat system.</param>
		public FeatureBundle(IEnumerable<FeatureValue> featVals, FeatureSystem featSys)
			: this(false, featSys)
		{
			foreach (FeatureValue value in featVals)
				Set(value, true);
		}
Esempio n. 16
0
 public SegmentDefinition(string strRep, CharacterDefinitionTable charDefTable, IEnumerable <FeatureValue> featVals,
                          FeatureSystem featSys) : this(strRep, charDefTable, new FeatureBundle(featVals, featSys))
 {
 }
		public SegmentDefinition(string strRep, CharacterDefinitionTable charDefTable, IEnumerable<FeatureValue> featVals,
			FeatureSystem featSys) : this(strRep, charDefTable, new FeatureBundle(featVals, featSys))
		{
		}
Esempio n. 18
0
		Feature LoadFeature(XmlElement featDefNode, XmlElement featSysNode, FeatureSystem featSys)
		{
			XmlElement featElem = featDefNode.SelectSingleNode("Feature") as XmlElement;
			string featId = featElem.GetAttribute("id");
			Feature feature = featSys.GetFeature(featId);
			if (feature != null)
				return feature;

			string featureName = featElem.InnerText;
			string defValId = featElem.GetAttribute("defaultValue");
			feature = new Feature(featId, featureName, m_curMorpher);
			XmlNode valueListNode = featDefNode.SelectSingleNode("ValueList");
			if (valueListNode != null)
			{
				XmlNodeList valueList = valueListNode.SelectNodes("Value");
				foreach (XmlNode valueNode in valueList)
				{
					XmlElement valueElem = valueNode as XmlElement;
					string valueId = valueElem.GetAttribute("id");
					FeatureValue value = new FeatureValue(valueId, valueElem.InnerText, m_curMorpher);
					try
					{
						featSys.AddValue(value);
						feature.AddPossibleValue(value);
					}
					catch (InvalidOperationException ioe)
					{
						throw new LoadException(LoadException.LoadErrorType.TOO_MANY_FEATURE_VALUES, this,
							HCStrings.kstidTooManyFeatValues, ioe);
					}
				}
				if (!string.IsNullOrEmpty(defValId))
					feature.DefaultValue = new ClosedValueInstance(feature.GetPossibleValue(defValId));
			}
			else
			{
				XmlElement featListElem = featDefNode.SelectSingleNode("FeatureList") as XmlElement;
				string featDefIdsStr = featListElem.GetAttribute("features");
				string[] featDefIds = featDefIdsStr.Split(' ');
				foreach (string featDefId in featDefIds)
				{
					XmlNode subFeatDefNode = featSysNode.SelectSingleNode(string.Format("FeatureDefinition[@id = '{0}']", featDefId));
					Feature subFeature = LoadFeature(subFeatDefNode as XmlElement, featSysNode, featSys);
					feature.AddSubFeature(subFeature);
				}
			}
			featSys.AddFeature(feature);
			return feature;
		}
Esempio n. 19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FeatureBundle"/> class.
 /// </summary>
 /// <param name="initialVal">The initial value for all values in the feature bundle.</param>
 /// <param name="featSys">The feature system.</param>
 public FeatureBundle(bool initialVal, FeatureSystem featSys)
 {
     SetAll(initialVal);
     m_featSys = featSys;
 }
Esempio n. 20
0
 private FeatureStruct LoadFeatureStruct(XElement elem, FeatureSystem featSys)
 {
     var fs = new FeatureStruct();
     foreach (XElement featValElem in elem.Elements("FeatureValue").Where(IsActive))
     {
         Feature feature = featSys.GetFeature((string) featValElem.Attribute("feature"));
         var valueIDsStr = (string) featValElem.Attribute("symbolValues");
         if (!string.IsNullOrEmpty(valueIDsStr))
         {
             var sf = (SymbolicFeature) feature;
             fs.AddValue(sf, valueIDsStr.Split(' ').Select(id => sf.PossibleSymbols[id]));
         }
         else
         {
             var cf = (ComplexFeature) feature;
             fs.AddValue(cf, LoadFeatureStruct(featValElem, featSys));
         }
     }
     return fs;
 }