Example #1
0
        /// <summary>
        /// R1 is the region after the first non-vowel following a vowel, or is the null region at the end of the word if there is no such non-vowel.
        /// </summary>
        /// <returns></returns>
        internal static WordRegion CalculateR(string word, int offset)
        {
            if (offset >= word.Length)
            {
                return(new WordRegion(word.Length, word.Length));
            }

            int firstVowel    = word.IndexOfAny(Vowels, offset);
            int firstNonVowel = IndexOfNone(word, Vowels, firstVowel);
            int nextVowel     = firstNonVowel + 1;
            //int nextNonVowel = IndexOfNone(word, nextVowel, vowels);

            WordRegion result = new WordRegion();

            if (nextVowel > 0 &&
                nextVowel < word.Length)
            {
                result.Start = nextVowel;
            }
            else
            {
                result.Start = word.Length;
            }
            result.End = word.Length;
            return(result);
        }
Example #2
0
        internal void GenerateStem()
        {
            if (IsException1())
            {
                return;
            }
            //If the word has two letters or less, leave it as it is.
            if (Stem.Length < 3)
            {
                return;
            }

            //Remove initial ', if present. +
            StandardiseApostrophesAndStripLeading();

            //Set initial y, or y after a vowel, to Y
            MarkYs();

            //establish the regions R1 and R2. (See note on vowel marking.)
            if (Stem.StartsWith("gener") ||
                Stem.StartsWith("arsen"))
            {
                _r1 = CalculateR(Stem, 2);
            }
            else if (Stem.StartsWith("commun"))
            {
                _r1 = CalculateR(Stem, 3);
            }
            else
            {
                _r1 = CalculateR(Stem, 0);
            }
            _r2 = CalculateR(Stem, _r1.Start);

            //Step0
            StripTrailingApostrophe();
            //Step1a
            StripSuffixStep1a();

            if (IsException2())
            {
                return;
            }

            //Step1b
            StripSuffixStep1b();
            //Step 1c: *
            ReplaceSuffixStep1c();
            //Step2
            ReplaceEndingStep2();
            //Step3
            ReplaceEndingStep3();
            //Step4
            StripSuffixStep4();
            //Step5
            StripSuffixStep5();
            //Finally, turn any remaining Y letters in the word back into lower case.
            Finally();
        }
Example #3
0
        /// <summary>
        /// R1 is the region after the first non-vowel following a vowel, or is the null region at the end of the word if there is no such non-vowel. 
        /// </summary>
        /// <returns></returns>
        internal static WordRegion CalculateR(string word, int offset)
        {
            if (offset >= word.Length)
                return new WordRegion(word.Length, word.Length);

            int firstVowel = word.IndexOfAny(Vowels, offset);
            int firstNonVowel = IndexOfNone(word, Vowels, firstVowel);
            int nextVowel = firstNonVowel + 1;
            //int nextNonVowel = IndexOfNone(word, nextVowel, vowels);

            WordRegion result = new WordRegion();
            if (nextVowel > 0
                    && nextVowel < word.Length)
                result.Start = nextVowel;
            else
                result.Start = word.Length;
            result.End = word.Length;
            return result;
        }
Example #4
0
        internal void GenerateStem()
        {
            if (IsException1())
                return;
            //If the word has two letters or less, leave it as it is.
            if (Stem.Length < 3)
                return;

            //Remove initial ', if present. +
            StandardiseApostrophesAndStripLeading();

            //Set initial y, or y after a vowel, to Y
            MarkYs();

            //establish the regions R1 and R2. (See note on vowel marking.)
            if (Stem.StartsWith("gener")
                    || Stem.StartsWith("arsen"))
            {
                _r1 = CalculateR(Stem, 2);
            }
            else if (Stem.StartsWith("commun"))
            {
                _r1 = CalculateR(Stem, 3);
            }
            else
            {
                _r1 = CalculateR(Stem, 0);
            }
            _r2 = CalculateR(Stem, _r1.Start);

            //Step0
            StripTrailingApostrophe();
            //Step1a
            StripSuffixStep1a();

            if (IsException2())
                return;

            //Step1b
            StripSuffixStep1b();
            //Step 1c: *
            ReplaceSuffixStep1c();
            //Step2
            ReplaceEndingStep2();
            //Step3
            ReplaceEndingStep3();
            //Step4
            StripSuffixStep4();
            //Step5
            StripSuffixStep5();
            //Finally, turn any remaining Y letters in the word back into lower case.
            Finally();
        }