/// <summary> /// Initializes a new instance of the <see cref="WordSynthesis"/> class. /// </summary> /// <param name="rootAllomorph">The root allomorph.</param> /// <param name="nonHead">The non-head synthesis.</param> /// <param name="rzFeatures">The realizational features.</param> /// <param name="mrules">The morphological rules to apply.</param> /// <param name="curTrace">The current trace record.</param> internal WordSynthesis(LexEntry.RootAllomorph rootAllomorph, WordSynthesis nonHead, FeatureValues rzFeatures, IEnumerable <MorphologicalRule> mrules, Trace curTrace) { m_root = (LexEntry)rootAllomorph.Morpheme; m_mprFeatures = m_root.MPRFeatures != null?m_root.MPRFeatures.Clone() : new MPRFeatureSet(); m_headFeatures = m_root.HeadFeatures != null?m_root.HeadFeatures.Clone() : new FeatureValues(); m_footFeatures = m_root.FootFeatures != null?m_root.FootFeatures.Clone() : new FeatureValues(); m_pos = m_root.POS; m_stratum = m_root.Stratum; m_nonHead = nonHead; m_morphs = new Morphs(); Morph morph = new Morph(rootAllomorph); morph.Shape.AddMany(rootAllomorph.Shape.Segments); m_morphs.Add(morph); m_shape = new PhoneticShape(); m_shape.Add(new Margin(Direction.LEFT)); m_shape.AddPartition(rootAllomorph.Shape.Segments, morph.Partition); m_shape.Add(new Margin(Direction.RIGHT)); m_obligHeadFeatures = new HCObjectSet <Feature>(); m_mrules = new List <MorphologicalRule>(mrules); m_rzFeatures = rzFeatures; m_curTrace = curTrace; m_mrulesApplied = new Dictionary <MorphologicalRule, int>(); }
/// <summary> /// Copy constructor. /// </summary> /// <param name="morphs">The morphs.</param> public Morphs(Morphs morphs) { m_nextPartition = morphs.m_nextPartition; foreach (Morph mi in morphs) { base.InsertItem(Count, mi); } }
public bool SameMorphemes(Morphs other) { if (Count != other.Count) { return(false); } IEnumerator <Morph> enum1 = GetEnumerator(); IEnumerator <Morph> enum2 = other.GetEnumerator(); while (enum1.MoveNext() && enum2.MoveNext()) { if (enum1.Current.Allomorph.Morpheme != enum2.Current.Allomorph.Morpheme) { return(false); } } return(true); }
/// <summary> /// Copy constructor. /// </summary> /// <param name="ws">The word synthesis.</param> public WordSynthesis(WordSynthesis ws) { m_root = ws.m_root; if (ws.m_nonHead != null) { m_nonHead = ws.m_nonHead.Clone(); } m_shape = ws.m_shape.Clone(); m_morphs = ws.m_morphs.Clone(); m_pos = ws.m_pos; m_mprFeatures = ws.m_mprFeatures.Clone(); m_headFeatures = ws.m_headFeatures.Clone(); m_footFeatures = ws.m_footFeatures.Clone(); m_obligHeadFeatures = new HCObjectSet <Feature>(ws.m_obligHeadFeatures); m_mrules = new List <MorphologicalRule>(ws.m_mrules); m_curRuleIndex = ws.m_curRuleIndex; m_rzFeatures = ws.m_rzFeatures.Clone(); m_curTrace = ws.m_curTrace; m_stratum = ws.m_stratum; m_mrulesApplied = new Dictionary <MorphologicalRule, int>(ws.m_mrulesApplied); }
public int CompareTo(WordSynthesis other) { IEnumerator <Morph> enum1 = Morphs.GetEnumerator(); IEnumerator <Morph> enum2 = other.Morphs.GetEnumerator(); while (enum1.MoveNext() && enum2.MoveNext()) { int compare = enum1.Current.Allomorph.Morpheme.ID.CompareTo(enum2.Current.Allomorph.Morpheme.ID); if (compare != 0) { return(compare); } compare = enum1.Current.Allomorph.CompareTo(enum2.Current.Allomorph); if (compare != 0) { return(compare); } } return(0); }
public bool Equals(Morphs other) { if (other == null) { return(false); } if (Count != other.Count) { return(false); } Collection <Morph> morphs = this; Collection <Morph> otherMorphs = other; for (int i = 0; i < Count; i++) { if (!morphs[i].Equals(otherMorphs[i])) { return(false); } } return(true); }
/// <summary> /// Determines if all of the specified morphemes co-occur with the key morpheme. /// </summary> /// <param name="morphs">The morphs.</param> /// <param name="key">The key morpheme.</param> /// <returns></returns> public bool CoOccurs(Morphs morphs, HCObject key) { Collection <Morph> morphList = morphs; HCObjectSet <HCObject> others = new HCObjectSet <HCObject>(m_others); switch (m_adjacency) { case AdjacencyType.ANYWHERE: foreach (Morph morph in morphList) { others.Remove(GetMorphObject(morph)); } break; case AdjacencyType.SOMEWHERE_TO_LEFT: case AdjacencyType.ADJACENT_TO_LEFT: for (int i = 0; i < morphList.Count; i++) { HCObject curMorphObj = GetMorphObject(morphList[i]); if (key == curMorphObj) { break; } else if (others.Count > 0 && others[0] == curMorphObj) { if (m_adjacency == AdjacencyType.ADJACENT_TO_LEFT) { if (i == morphList.Count - 1) { return(false); } HCObject nextMorphObj = GetMorphObject(morphList[i + 1]); if (others.Count > 1) { if (others[1] != nextMorphObj) { return(false); } } else if (key != nextMorphObj) { return(false); } } others.RemoveAt(0); } } break; case AdjacencyType.SOMEWHERE_TO_RIGHT: case AdjacencyType.ADJACENT_TO_RIGHT: for (int i = morphList.Count - 1; i >= 0; i--) { HCObject curMorphObj = GetMorphObject(morphList[i]); if (key == curMorphObj) { break; } else if (others.Count > 0 && others[others.Count - 1] == curMorphObj) { if (m_adjacency == AdjacencyType.ADJACENT_TO_RIGHT) { if (i == 0) { return(false); } HCObject prevMorphObj = GetMorphObject(morphList[i - 1]); if (others.Count > 1) { if (others[others.Count - 2] != prevMorphObj) { return(false); } } else if (key != prevMorphObj) { return(false); } } others.RemoveAt(others.Count - 1); } } break; } return(others.Count == 0); }