private bool IsAbbreviation(string text, int index, IFixCallbacks callbacks)
        {
            if (text[index] != '.')
                return false;

            if (index - 3 > 0 && Utilities.AllLettersAndNumbers.Contains(text[index - 1]) && text[index - 2] == '.') // e.g: O.R.
                return true;

            var word = string.Empty;
            int i = index - 1;
            while (i >= 0 && Utilities.AllLetters.Contains(text[i]))
            {
                word = text[i] + word;
                i--;
            }

            return callbacks.GetAbbreviations().Contains(word + ".");
        }
Example #2
0
        private bool IsSpanishAbbreviation(string text, int index, IFixCallbacks callbacks)
        {
            if (text[index] != '.')
            {
                return(false);
            }

            if (index + 3 < text.Length && text[index + 2] == '.') //  X
            {
                return(true);                                      // O.R.
            }

            if (index - 3 > 0 && text[index - 1] != '.' && text[index - 2] == '.') //    X
            {
                return(true);                                                      // O.R.
            }

            string word = string.Empty;
            int    i    = index - 1;

            while (i >= 0 && char.IsLetter(text[i]))
            {
                word = text[i--] + word;
            }

            //Common Spanish abbreviations
            //Dr. (same as English)
            //Sr. (same as Mr.)
            //Sra. (same as Mrs.)
            //Ud.
            //Uds.
            if (word.Equals("dr", StringComparison.OrdinalIgnoreCase) ||
                word.Equals("sr", StringComparison.OrdinalIgnoreCase) ||
                word.Equals("sra", StringComparison.OrdinalIgnoreCase) ||
                word.Equals("ud", StringComparison.OrdinalIgnoreCase) ||
                word.Equals("uds", StringComparison.OrdinalIgnoreCase))
            {
                return(true);
            }

            HashSet <string> abbreviations = callbacks.GetAbbreviations();

            return(abbreviations.Contains(word + "."));
        }
        private bool IsAbbreviation(string text, int index, IFixCallbacks callbacks)
        {
            if (text[index] != '.')
            {
                return(false);
            }

            if (index - 3 > 0 && char.IsLetterOrDigit(text[index - 1]) && text[index - 2] == '.') // e.g: O.R.
            {
                return(true);
            }

            var word = string.Empty;
            int i    = index - 1;

            while (i >= 0 && char.IsLetter(text[i]))
            {
                word = text[i--] + word;
            }

            return(callbacks.GetAbbreviations().Contains(word + "."));
        }
Example #4
0
        private bool IsAbbreviation(string text, int index, IFixCallbacks callbacks)
        {
            if (text[index] != '.')
            {
                return(false);
            }

            if (index - 3 > 0 && Utilities.AllLettersAndNumbers.Contains(text[index - 1]) && text[index - 2] == '.') // e.g: O.R.
            {
                return(true);
            }

            var word = string.Empty;
            int i    = index - 1;

            while (i >= 0 && Utilities.AllLetters.Contains(text[i]))
            {
                word = text[i] + word;
                i--;
            }

            return(callbacks.GetAbbreviations().Contains(word + "."));
        }
        private bool IsAbbreviation(string text, int index, IFixCallbacks callbacks)
        {
            if (text[index] != '.')
                return false;

            if (index - 3 > 0 && char.IsLetterOrDigit(text[index - 1]) && text[index - 2] == '.') // e.g: O.R.
                return true;

            var word = string.Empty;
            int i = index - 1;
            while (i >= 0 && char.IsLetter(text[i]))
            {
                word = text[i--] + word;
            }

            return callbacks.GetAbbreviations().Contains(word + ".");
        }
        private bool IsSpanishAbbreviation(string text, int index, IFixCallbacks callbacks)
        {
            if (text[index] != '.')
                return false;

            if (index + 3 < text.Length && text[index + 2] == '.') //  X
                return true;                                    // O.R.

            if (index - 3 > 0 && text[index - 1] != '.' && text[index - 2] == '.') //    X
                return true;                          // O.R.

            string word = string.Empty;
            int i = index - 1;
            while (i >= 0 && char.IsLetter(text[i]))
            {
                word = text[i--] + word;
            }

            //Common Spanish abbreviations
            //Dr. (same as English)
            //Sr. (same as Mr.)
            //Sra. (same as Mrs.)
            //Ud.
            //Uds.
            if (word.Equals("dr", StringComparison.OrdinalIgnoreCase) ||
                word.Equals("sr", StringComparison.OrdinalIgnoreCase) ||
                word.Equals("sra", StringComparison.OrdinalIgnoreCase) ||
                word.Equals("ud", StringComparison.OrdinalIgnoreCase) ||
                word.Equals("uds", StringComparison.OrdinalIgnoreCase))
                return true;

            HashSet<string> abbreviations = callbacks.GetAbbreviations();
            return abbreviations.Contains(word + ".");
        }