Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 public void Do(Allomorph allomorph, Position position)
 {
     Allomorph operand;
     if (TryGetOperandMorpheme(allomorph, out operand, position))
     {
         Do(operand);
     }
 }
Exemplo n.º 4
0
 public override void Do(Allomorph allomorph, Position position)
 {
     Allomorph operand;
     if (TryGetOperandMorpheme(allomorph, out operand, position))
     {
         operand.Surface = _Replace(operand.Surface);
     }
 }
Exemplo n.º 5
0
        public bool IsTrue(Allomorph allomorph)
        {
            if (IsEmpty)
            {
                return true;
            }

            return _flag ? AreAllConditionsTrue(allomorph) : IsAnyConditionTrue(allomorph);
        }
Exemplo n.º 6
0
        public override bool IsTrueFor(Allomorph allomorph)
        {
            Allomorph operand;
            if (TryGetOperandMorpheme(allomorph, out operand))
            {
                return !operand.HasNext;
            }

            return false;
        }
Exemplo n.º 7
0
        public override bool IsTrueFor(Allomorph allomorph)
        {
            Allomorph operand;
            if (TryGetOperandMorpheme(allomorph, out operand))
            {
                return Operand == operand.Morpheme.Id;
            }

            return false;
        }
Exemplo n.º 8
0
        public override bool IsTrueFor(Allomorph allomorph)
        {
            Allomorph operand;
            if (TryGetOperandMorpheme(allomorph, out operand))
            {
                return operand.Morpheme.HasLabel(_label);
            }

            return false;
        }
Exemplo n.º 9
0
        public override bool IsTrueFor(Allomorph allomorph)
        {
            Allomorph operand;
            if (TryGetOperandMorpheme(allomorph, out operand))
            {
                return Exists(operand);
            }

            return false;
        }
Exemplo n.º 10
0
        public override bool IsTrueFor(Allomorph allomorph)
        {
            Allomorph neighbour;
            if (TryGetOperandMorpheme(allomorph, out neighbour))
            {
                return IterateSequence(neighbour);
            }

            return false;
        }
Exemplo n.º 11
0
 private bool IsAnyConditionTrue(Allomorph allomorph)
 {
     foreach (ConditionBase condition in _conditions)
     {
         if (condition.IsTrueFor(allomorph))
         {
             return true;
         }
     }
     return false;
 }
Exemplo n.º 12
0
 public void Process(Allomorph allomorph)
 {
     foreach (Transformation transformation in _transformations)
     {
         if (transformation.Condition.IsTrue(allomorph))
         {
             transformation.Transform(allomorph);
             break;
         }
     }
 }
Exemplo n.º 13
0
        /// <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());
        }
Exemplo n.º 14
0
        /// <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());
        }
Exemplo n.º 15
0
 internal void ProcessRules(int phase, Allomorph allomorph)
 {
     if (HasRule)
     {
         foreach (var rule in Rules)
         {
             if (rule.Phase == phase)
             {
                 rule.Process(allomorph);
             }
         }
     }
 }
Exemplo n.º 16
0
        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();
        }
Exemplo n.º 17
0
        // 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);
            }
        }
Exemplo n.º 18
0
        // 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}");
            }
        }
Exemplo n.º 19
0
 public bool IsConditionTrue(Allomorph previous, Allomorph next)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 20
0
 protected override void Do(Allomorph allomorph)
 {
     allomorph.Surface = _Replace(allomorph.Surface);
 }
Exemplo n.º 21
0
 public override bool IsTrueFor(Allomorph allomorph)
 {
     return !base.IsTrueFor(allomorph);
 }
Exemplo n.º 22
0
 protected override void Do(Allomorph allomorph)
 {
     allomorph.Surface = allomorph.Surface.DeleteLastOccurrenceOfAny(Alphabet.Vowels);
 }
Exemplo n.º 23
0
 public override bool IsTrueFor(Allomorph allomorph)
 {
     string neighbourSurface = allomorph.GetSurface(Position);
     return neighbourSurface.LastCharEqualsAny(Operand);
 }
Exemplo n.º 24
0
 public override void Do(Allomorph allomorph, Position position)
 {
     allomorph.Surface = allomorph.Surface.DeleteLastOccurrenceOfAny(Alphabet.Vowels);
 }
Exemplo n.º 25
0
 public abstract void Do(Allomorph allomorph, Position position);
Exemplo n.º 26
0
 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;
 }
Exemplo n.º 27
0
 public override void Do(Allomorph allomorph, Position position)
 {
     char last = allomorph.Surface[allomorph.Surface.Length - 1];
     allomorph.Surface += last;
 }
Exemplo n.º 28
0
 public override bool IsTrueFor(Allomorph allomorph)
 {
     string neighbourSurface = allomorph.GetSurface(Position);
     return neighbourSurface.FirstCharEqualsAny(Alphabet.Vowels);
 }
Exemplo n.º 29
0
 public override void Do(Allomorph allomorph, Position position)
 {
     allomorph.Surface = allomorph.Surface.DeleteFirstChar();
 }
Exemplo n.º 30
0
 protected override void Do(Allomorph allomorph)
 {
     allomorph.Surface = ((Root) allomorph.Morpheme).Surfaces.First();
 }
Exemplo n.º 31
0
 protected override void Do(Allomorph allomorph)
 {
     allomorph.Surface += OperandOne;
 }
Exemplo n.º 32
0
 protected override void Do(Allomorph allomorph)
 {
     allomorph.Surface = allomorph.Surface.DeleteLastChar();
 }
Exemplo n.º 33
0
 protected override void Do(Allomorph allomorph)
 {
     var last = allomorph.Surface[allomorph.Surface.Length - 1];
     allomorph.Surface += last;
 }