Example #1
0
        /// <summary>
        /// returns the pattern that makes numbers ordinal. i.e. adds "م" and "ام" in the end.
        /// </summary>
        /// <returns></returns>
        private string OrdinalityPattern()
        {
            string ordinalityPat = RegexPatternCreator.ClosureQuestionMark(
                RegexPatternCreator.CreateGroup("",
                                                RegexPatternCreator.InWordWSStar,
                                                RegexPatternCreator.CreateGroup("", RegexPatternCreator.CreateOR(true, "م", "ام"))
                                                )
                );

            return(ordinalityPat);
        }
Example #2
0
        /// <summary>
        /// Returns the regex pattern for the Week-day part in an English date.
        /// </summary>
        /// <returns></returns>
        public string WeekdayPattern()
        {
            string weekday =
                RegexPatternCreator.CreateGroup("Weekday",
                                                RegexPatternCreator.CreateOR(false,
                                                                             "saturday", "sunday", "monday", "tuesday", "wednesday", "thursday", "friday",
                                                                             "sat", "sun", "mon", "tue", "wed", "thu", "fri",
                                                                             "sat\\.", "sun\\.", "mon\\.", "tue\\.", "wed\\.", "thu\\.", "fri\\."));

            return(weekday);
        }
Example #3
0
        /// <summary>
        /// Returns the regex pattern for the Hundreds and Tens (not lower, and not between). e.g. 110, 920 (NOT 117).
        /// </summary>
        /// <returns></returns>
        private string AllUpToTens()
        {
            string hundsGroup = RegexPatternCreator.ClosureQuestionMark(
                RegexPatternCreator.CreateGroup("", HundsPattern(),
                                                RegexPatternCreator.BetWordWSPlus, "و", RegexPatternCreator.BetWordWSPlus
                                                )
                );

            string numberPattern = RegexPatternCreator.CreateGroup("", hundsGroup, TensPattern());

            return(@"\b" + numberPattern + OrdinalityPattern() + @"\b");
        }
Example #4
0
 /// <summary>
 /// Returns the pattern of 3-digit blocks plus the multipliers.
 /// Named As MULTIPLIER_GROUP_NAME
 /// </summary>
 private string BlockPlusMultiplier()
 {
     return
         (RegexPatternCreator.CreateGroup(MULTIPLIER_GROUP_NAME,
                                          RegexPatternCreator.CreateOR(true,
                                                                       RegexPatternCreator.CreateGroup("",
                                                                                                       ThreeDigitBlockPattern(), RegexPatternCreator.BetWordWSPlus, MultipliersPattern()
                                                                                                       ),
                                                                       "هزار"
                                                                       )
                                          ));
 }
 /// <summary>
 /// Returns the regex pattern for all possible month names in all the supported calendar types, ORed together.
 /// </summary>
 /// <returns></returns>
 private string MonthNamePattern()
 {
     return(RegexPatternCreator.CreateGroup("MonthName",
                                            RegexPatternCreator.CreateOR(false,
                                                                         "فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "امرداد", "شهریور",
                                                                         "مهر", "آبان", "ابان", "آذر", "دی", "بهمن", "اسفند", "اسپند",
                                                                         "ژانویه", "جنوری", "فوریه", "فبروری", "مارس",
                                                                         "مارچ", "آوریل", "آپریل", "مه", "می", "ژوئن", "جون", "ژوئیه", "ژوییه", "جولای", "ژولای"
                                                                         , "اوت", "اگوست", "آگوست", "سپتامبر", "سپتمبر", "اکتبر", "نوامبر", "نومبر", "دسامبر", "دسبمر"
                                                                         , "محرم", "محرم‌الحرام", "محرم الحرام", "صفر", "ربیع‌الاول", "ربیع الاول"
                                                                         , "ربیع‌الثانی", "ربیع الثانی", "جمادی‌الاولی", "جمادی‌الاول", "جمادی الاولی", "جمادی الاول"
                                                                         , "جمادی‌الثانی", "جمادی الثانی", "رجب", "شعبان", "رمضان", "شوال", "ذی‌القعده", "ذی القعده", "ذو‌القعده"
                                                                         , "ذو القعده", "ذی‌الحجه", "ذوالحجه", "ذی الحجه", "ذو الحجه")));
 }
        /// <summary>
        /// Returns the complete regex date pattern in Persian.
        /// </summary>
        /// <returns></returns>
        private string PersianDatePattern()
        {
            string monthYearOptionalLiteral = RegexPatternCreator.CreateGroup("",
                                                                              RegexPatternCreator.ClosureQuestionMark(RegexPatternCreator.CreateGroup("",
                                                                                                                                                      RegexPatternCreator.BetWordWSPlus, "ماه")),
                                                                              RegexPatternCreator.ClosureQuestionMark(RegexPatternCreator.CreateGroup("",
                                                                                                                                                      RegexPatternCreator.BetWordWSPlus, "سال"))
                                                                              );

            string optionalWeekday = RegexPatternCreator.ClosureQuestionMark(RegexPatternCreator.CreateGroup("", WeekdayPattern(), RegexPatternCreator.BetWordWSPlus));
            string optionalYear    = RegexPatternCreator.ClosureQuestionMark(RegexPatternCreator.CreateGroup("", RegexPatternCreator.BetWordWSPlus, YearPattern()));
            string datePattern     = RegexPatternCreator.CreateGroup("PersianDate", optionalWeekday, DayNumPattern(), RegexPatternCreator.BetWordWSPlus, MonthNamePattern(), monthYearOptionalLiteral, optionalYear);

            return(@"\b" + datePattern + @"\b");
        }
Example #7
0
        /// <summary>
        /// Returns regex patterns for the multipliers of 100. e.g. سیصد، دویست، نهصد، صد
        /// </summary>
        /// <returns></returns>
        private string HundsPattern()
        {
            string writtenNum =
                RegexPatternCreator.CreateGroup(HUNDSNUM_NAME,
                                                RegexPatternCreator.CreateOR(false, "یک", "دو", "سی", "چهار", "پان", "پون", "پنج", "شش", "شیش", "هفت", "هشت", "نه"));
            string hunds =
                RegexPatternCreator.CreateGroup(HUNDS_NAME,
                                                RegexPatternCreator.CreateOR(true,
                                                                             RegexPatternCreator.CreateGroup("",
                                                                                                             RegexPatternCreator.ClosureQuestionMark(
                                                                                                                 RegexPatternCreator.CreateGroup("", writtenNum, RegexPatternCreator.InWordWSStar)
                                                                                                                 ),
                                                                                                             "صد"),
                                                                             "دویست", "سیصد"));

            return(hunds);
        }
        /// <summary>
        /// Returns regex pattern for week-day part of the date pattern
        /// </summary>
        /// <returns></returns>
        public string WeekdayPattern()
        {
            string weekdayDigits = "[12345۱۲۳۴۵]";
            string writtenNum    = RegexPatternCreator.CreateGroup("WeekdayNum", RegexPatternCreator.CreateOR(false, "یک", "دو", "سه", "چهار", "پنج", weekdayDigits));

            string weekday =
                RegexPatternCreator.CreateGroup("Weekday",
                                                RegexPatternCreator.CreateOR(true,
                                                                             RegexPatternCreator.CreateGroup("",
                                                                                                             RegexPatternCreator.ClosureQuestionMark(
                                                                                                                 RegexPatternCreator.CreateGroup("", writtenNum, RegexPatternCreator.InWordWSStar)
                                                                                                                 ),
                                                                                                             "شنبه"),
                                                                             "جمعه"));

            return(weekday);
        }
Example #9
0
        /// <summary>
        /// Returns the regex pattern for all possible month-names in all possible calendar types in English language, ORed together.
        /// </summary>
        /// <returns></returns>
        private string MonthNamePattern()
        {
            return(RegexPatternCreator.CreateGroup("MonthName",
                                                   RegexPatternCreator.CreateOR(true,

                                                                                "january", "jan", "jan\\.", "february", "feb", "feb\\.", "march", "mar", "mar\\.", "april", "apr", "apr\\.", "may",
                                                                                "june", "jun", "jun\\.", "july", "jul", "jul\\.", "august", "aug", "aug\\.", "september", "sep", "sep\\.", "october", "oct", "oct\\.",
                                                                                "november", "nov", "nov\\.", "december", "dec", "dec\\.",

                                                                                "farvardin", "ordibehesht", "khordād", "khordad", "tir", "mordād", "amordād", "mordad",
                                                                                "amordad", "shahrivar", "mehr", "aban", "aban", "āzar", "azar", "dey", "bahman", "esfand", "espand",

                                                                                "muharram", "muḥarram ul ḥaram", "muharram ul haram", "safar", "ṣafar ul muzaffar", "safar ul muzaffar",
                                                                                "rabi' al-awwal", "rabi' al-thani", "jumada al-ula", "jumada al-thani", "rajab",
                                                                                "rajab al murajab", "sha'aban", "sha'abān ul moazam", "sha'aban ul moazam", "ramadan", "ramazān",
                                                                                "ramaḍān ul mubarak", "ramadan ul mubarak", "ramazan", "ramazan ul mubarak", "shawwal",
                                                                                "shawwal ul mukarram", "dhu al-qi'dah", "dhu al-hijjah")));
        }
Example #10
0
        /// <summary>
        /// Returns the complete regex pattern for an English date.
        /// </summary>
        /// <returns></returns>
        private string EnglishDatePattern()
        {
            string optionalWeekday =
                RegexPatternCreator.ClosureQuestionMark(RegexPatternCreator.CreateGroup("",
                                                                                        WeekdayPattern(),
                                                                                        RegexPatternCreator.ClosureQuestionMark(RegexPatternCreator.BetWordWSPlus),
                                                                                        RegexPatternCreator.ClosureQuestionMark(","),
                                                                                        RegexPatternCreator.BetWordWSPlus
                                                                                        ));
            string optionalYear =
                RegexPatternCreator.ClosureQuestionMark(RegexPatternCreator.CreateGroup("",
                                                                                        RegexPatternCreator.ClosureQuestionMark(RegexPatternCreator.BetWordWSPlus),
                                                                                        RegexPatternCreator.ClosureQuestionMark(","),
                                                                                        RegexPatternCreator.BetWordWSPlus,
                                                                                        YearPattern()));
            string datePattern = RegexPatternCreator.CreateGroup("EnglishDate", optionalWeekday, MonthNamePattern(), RegexPatternCreator.BetWordWSPlus, DayNumPattern(), optionalYear);


            return(@"\b" + datePattern + @"\b");
        }
Example #11
0
        /// <summary>
        /// Returns the whole pattern of a persian written number
        /// </summary>
        internal string PersianNumberPattern()
        {
            string ThreeDB      = ThreeDigitBlockPattern();
            string BlockAndMult = BlockPlusMultiplier();

            string MultPlus3DB =
                RegexPatternCreator.CreateGroup("",
                                                RegexPatternCreator.ClosurePlus(
                                                    RegexPatternCreator.CreateGroup("",
                                                                                    BlockAndMult, RegexPatternCreator.BetWordWSPlus, "و", RegexPatternCreator.BetWordWSPlus
                                                                                    )
                                                    ),
                                                RegexPatternCreator.ClosureQuestionMark(
                                                    ThreeDB
                                                    )
                                                );

            string MultPlus =
                RegexPatternCreator.CreateGroup("",
                                                BlockAndMult,
                                                RegexPatternCreator.ClosureStar(RegexPatternCreator.CreateGroup("",
                                                                                                                RegexPatternCreator.BetWordWSPlus, "و", RegexPatternCreator.BetWordWSPlus, BlockAndMult
                                                                                                                )),
                                                RegexPatternCreator.ClosureQuestionMark(RegexPatternCreator.CreateGroup("",
                                                                                                                        RegexPatternCreator.BetWordWSPlus, "و", RegexPatternCreator.BetWordWSPlus, ThreeDB
                                                                                                                        ))
                                                );

            string numberPattern = RegexPatternCreator.CreateGroup("",
                                                                   RegexPatternCreator.CreateOR(true, MultPlus, ThreeDB)
                                                                   );

            return(@"\b" + RegexPatternCreator.CreateOR(false, numberPattern, "(صفرم)", "(صفر)") + @"\b");
        }
Example #12
0
 /// <summary>
 /// Returns the regex pattern for the year part of an English date, which can only be digits.
 /// </summary>
 /// <returns></returns>
 private string YearPattern()
 {
     return(RegexPatternCreator.CreateGroup("Year",
                                            @"\d+"
                                            ));
 }
Example #13
0
 /// <summary>
 /// Returns the regex pattern for the day number (in month) in an English date, which can only be digits.
 /// </summary>
 /// <returns></returns>
 private string DayNumPattern()
 {
     return(RegexPatternCreator.CreateGroup("",
                                            RegexPatternCreator.CreateGroup("DayNum", @"\d\d?"),
                                            RegexPatternCreator.ClosureQuestionMark("th|st|rd|nd")));
 }
 /// <summary>
 /// Returns the regex pattern for the day-number (in month) part of the date description
 /// which can also be in persian written form.
 /// </summary>
 /// <returns></returns>
 private string DayNumPattern()
 {
     return(RegexPatternCreator.CreateGroup("DayNum", persianNumberParser.ThreeDigitBlockPattern()));
 }