private bool IterateSequence(Allomorph neighbour) { if (Position == Position.BeforeSource) { for (int i = _sequence.Length - 1; i >= 0; i--) { if (_sequence[i] != neighbour.Morpheme.Id) return false; if (neighbour.HasPrevious) { neighbour = neighbour.Previous; } } return true; } if (Position == Position.AfterTarget) { for (int i = 0; i < _sequence.Length; i++) { if (_sequence[i] != neighbour.Morpheme.Id) return false; if (neighbour.HasNext) { neighbour = neighbour.Next; } } return true; } throw new ArgumentException("Invalid Morpheme Position for MorphemeSequenceEquals: " + Position); }
private bool Exists(Allomorph operand) { if (Position == Position.BeforeSource) { while (operand.HasPrevious) { if (operand.Morpheme.Id == Operand) { return true; } operand = operand.Previous; } } if (Position == Position.AfterTarget) { if (operand.Morpheme.Id == Operand) { return true; } while (operand.HasNext) { operand = operand.Next; if (operand.Morpheme.Id == Operand) { return true; } } } throw new ArgumentException("Invalid position for MorphemeExists: " + Position); }
public void Do(Allomorph allomorph, Position position) { Allomorph operand; if (TryGetOperandMorpheme(allomorph, out operand, position)) { Do(operand); } }
public override void Do(Allomorph allomorph, Position position) { Allomorph operand; if (TryGetOperandMorpheme(allomorph, out operand, position)) { operand.Surface = _Replace(operand.Surface); } }
public bool IsTrue(Allomorph allomorph) { if (IsEmpty) { return true; } return _flag ? AreAllConditionsTrue(allomorph) : IsAnyConditionTrue(allomorph); }
public override bool IsTrueFor(Allomorph allomorph) { Allomorph operand; if (TryGetOperandMorpheme(allomorph, out operand)) { return !operand.HasNext; } return false; }
public override bool IsTrueFor(Allomorph allomorph) { Allomorph operand; if (TryGetOperandMorpheme(allomorph, out operand)) { return Operand == operand.Morpheme.Id; } return false; }
public override bool IsTrueFor(Allomorph allomorph) { Allomorph operand; if (TryGetOperandMorpheme(allomorph, out operand)) { return operand.Morpheme.HasLabel(_label); } return false; }
public override bool IsTrueFor(Allomorph allomorph) { Allomorph operand; if (TryGetOperandMorpheme(allomorph, out operand)) { return Exists(operand); } return false; }
public override bool IsTrueFor(Allomorph allomorph) { Allomorph neighbour; if (TryGetOperandMorpheme(allomorph, out neighbour)) { return IterateSequence(neighbour); } return false; }
private bool IsAnyConditionTrue(Allomorph allomorph) { foreach (ConditionBase condition in _conditions) { if (condition.IsTrueFor(allomorph)) { return true; } } return false; }
public void Process(Allomorph allomorph) { foreach (Transformation transformation in _transformations) { if (transformation.Condition.IsTrue(allomorph)) { transformation.Transform(allomorph); break; } } }
/// <summary> /// Allomorph'un solunda kalan yüzeyi döndürür. /// </summary> /// <returns>sol/önceki yüzey</returns> protected string GetPreviousSurface() { var sb = new StringBuilder(); Allomorph temp = this; while (temp.HasPrevious) { temp = temp.Previous; sb.Insert(0, temp.Surface); } return(sb.ToString()); }
/// <summary> /// Allomorph'un sonrasındaki yüzeyi döndürür. /// </summary> /// <returns>sağ/sonraki yüzey</returns> protected string GetNextSurface() { var sb = new StringBuilder(); Allomorph temp = this; while (temp.HasNext) { temp = temp.Next; sb.Append(temp.Surface); } return(sb.ToString()); }
internal void ProcessRules(int phase, Allomorph allomorph) { if (HasRule) { foreach (var rule in Rules) { if (rule.Phase == phase) { rule.Process(allomorph); } } } }
public override void Do(Allomorph allomorph, Position position) { Allomorph neighbour = allomorph; switch (position) { case Position.Next: neighbour = allomorph.Next; break; case Position.Previous: neighbour = allomorph.Previous; break; } neighbour.Surface = neighbour.Surface.DeleteLastChar(); }
// out parameter for result protected bool TryGetOperandMorpheme(Allomorph allomorph, out Allomorph operand, Position position) { switch (position) { case Position.This: operand = allomorph; return true; case Position.Next: operand = allomorph.Next; return allomorph.HasNext; case Position.Previous: operand = allomorph.Previous; return allomorph.HasPrevious; default: throw new ArgumentException("Invalid Position for Action : " + position); } }
// out parameter for result protected bool TryGetOperandMorpheme(Allomorph allomorph, out Allomorph operand) { switch (Position) { case Position.Next: case Position.Target: operand = allomorph.Next; return allomorph.HasNext; case Position.Previous: case Position.BeforeSource: operand = allomorph.Previous; return allomorph.HasPrevious; case Position.This: case Position.Source: operand = allomorph; return true; case Position.First: operand = allomorph.First; return true; case Position.AfterTarget: if (allomorph.HasNext) { operand = allomorph.Next.Next; return allomorph.Next.HasNext; } operand = null; return false; default: throw new ArgumentException($"Invalid Argument : {Position}"); } }
public bool IsConditionTrue(Allomorph previous, Allomorph next) { throw new NotImplementedException(); }
protected override void Do(Allomorph allomorph) { allomorph.Surface = _Replace(allomorph.Surface); }
public override bool IsTrueFor(Allomorph allomorph) { return !base.IsTrueFor(allomorph); }
protected override void Do(Allomorph allomorph) { allomorph.Surface = allomorph.Surface.DeleteLastOccurrenceOfAny(Alphabet.Vowels); }
public override bool IsTrueFor(Allomorph allomorph) { string neighbourSurface = allomorph.GetSurface(Position); return neighbourSurface.LastCharEqualsAny(Operand); }
public override void Do(Allomorph allomorph, Position position) { allomorph.Surface = allomorph.Surface.DeleteLastOccurrenceOfAny(Alphabet.Vowels); }
public abstract void Do(Allomorph allomorph, Position position);
public override bool IsTrueFor(Allomorph allomorph) { string neighbourSurface = allomorph.GetSurface(Position); char? penultVowel = neighbourSurface.PenultimateOccurrenceOfAny(Alphabet.Vowels); return penultVowel.HasValue && Operand.IndexOf((char) penultVowel) != -1; }
public override void Do(Allomorph allomorph, Position position) { char last = allomorph.Surface[allomorph.Surface.Length - 1]; allomorph.Surface += last; }
public override bool IsTrueFor(Allomorph allomorph) { string neighbourSurface = allomorph.GetSurface(Position); return neighbourSurface.FirstCharEqualsAny(Alphabet.Vowels); }
public override void Do(Allomorph allomorph, Position position) { allomorph.Surface = allomorph.Surface.DeleteFirstChar(); }
protected override void Do(Allomorph allomorph) { allomorph.Surface = ((Root) allomorph.Morpheme).Surfaces.First(); }
protected override void Do(Allomorph allomorph) { allomorph.Surface += OperandOne; }
protected override void Do(Allomorph allomorph) { allomorph.Surface = allomorph.Surface.DeleteLastChar(); }
protected override void Do(Allomorph allomorph) { var last = allomorph.Surface[allomorph.Surface.Length - 1]; allomorph.Surface += last; }