コード例 #1
0
        private static string GetPattern(EnumLanguage language = EnumLanguage.NONE)
        {
            string pattern = "";

            switch (language)
            {
            default:
            {
                // circa late eighth to early ninth century AD
                pattern = String.Concat(
                    START,
                    maybe(DateCirca.Pattern(language) + SPACE),
                    maybe(oneof(Lookup <EnumDatePrefix> .Patterns(language), "prefix1") + SPACE),
                    oneof(Lookup <EnumOrdinal> .Patterns(language), "centuryMin"),
                    maybe(SPACE + "century"),
                    @"\s*(?:[e\;\-\/]|to|or)\s*",
                    maybe(oneof(Lookup <EnumDatePrefix> .Patterns(language), "prefix2") + SPACE),
                    oneof(Lookup <EnumOrdinal> .Patterns(language), "centuryMax"),
                    maybe(SPACE + "century"),
                    maybe(SPACE + oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix")),
                    END
                    );
                break;
            }
            }

            return(pattern);
        }
コード例 #2
0
ファイル: RxSeasonYear.cs プロジェクト: cbinding/timespans
        private static string Pattern(EnumLanguage language = EnumLanguage.NONE, string groupname = "")
        {
            // ^(?<season>Spring|Summer|Autumn|(?:Winter|Fall))\s(?<year>\d+)$
            string pattern = String.Concat(
                START,                                                    // ^
                oneof(Lookup <EnumSeason> .Patterns(language), "season"), // builds: (?<season>Spring|Summer|Autumn|(?:Winter|Fall))
                SPACE,                                                    // \s
                group(@"\d+", "year"),                                    // (?<year>\d+)
                END                                                       // $
                );

            return(group(pattern, groupname));
        }
コード例 #3
0
ファイル: RxSingleYear.cs プロジェクト: cbinding/timespans
        private static string GetPattern(EnumLanguage language = EnumLanguage.NONE)
        {
            string pattern = "";

            switch (language)
            {
            case EnumLanguage.IT:
            {
                // ^(?:(?:dal?|in|nel)\s)?(?:(?:C(?:\.|irca)|Intorno al)\s)?(?<year>\d+)(?:(?<suffix>a\.?C\.?|d\.?C\.?|B\.?P\.?|C\.?E\.?))?$
                pattern = String.Concat(
                    START,                                                               // ^
                    maybe(oneof(new string[] { @"dal?", "in", "nel" }) + SPACE),         // (?:(?:dal?|in|nel)\s)?
                    maybe(DateCirca.Pattern(language) + SPACE),                          // (?:(?:C(?:\.|irca)|Intorno al)\s)?
                    group(@"\d+", "year"),                                               // (?<year>\d+)
                    maybe(SPACE),                                                        // (?:\s)?
                    maybe(oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix")), // (?:(?<suffix>a\.?C\.?|d\.?C\.?|B\.?P\.?|C\.?E\.?))?
                    END                                                                  // $
                    );
                break;
            }

            default:
            {
                // ^(?:(?:C(?:\.|irca)|around|approx(?:\.|imately)?)\s)?(?<year>\d+)(?:(?<suffix>B\.?C\.?|A\.?D\.?|B\.?P\.?|C\.?E\.?)\s)?$
                pattern = String.Concat(
                    START,                                                          // ^
                    maybe(DateCirca.Pattern(language)),                             // (?:C(?:\.|irca)|around|approx(?:\.|imately)?)?
                    maybe(SPACE),                                                   // (?:\s)?
                    oneof(new string[] {
                        group(@"[+-]?\d+", "year"),
                        String.Concat(
                            group(@"\d+", "year"),                                              // (?<year>\d+)
                            maybe(oneof(new string[] { @"\+", @"\?" })),                        // approximation indicator
                            maybe(SPACE),                                                       // (?:\s)?
                            maybe(oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix")) // (?<suffix>B\.?C\.?|A\.?D\.?|B\.?P\.?|C\.?E\.?)?
                            ),
                        String.Concat(
                            maybe(oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix")), // (?<suffix>B\.?C\.?|A\.?D\.?|B\.?P\.?|C\.?E\.?)?
                            maybe(SPACE),                                                        // (?:\s)?
                            group(@"\d+", "year"),                                               // (?<year>\d+)
                            maybe(oneof(new string[] { @"\+", @"\?" }))
                            )
                    }),
                    END                                                             // $
                    );
                break;
            }
            }
            return(pattern);
        }
コード例 #4
0
ファイル: RxMonthYear.cs プロジェクト: cbinding/timespans
        private static string GetPattern(EnumLanguage language = EnumLanguage.NONE)
        {
            string pattern = String.Concat(
                START,
                maybe(DateCirca.Pattern(language) + SPACE),
                oneof(Lookup <EnumMonth> .Patterns(language), "month"),
                //Month.Pattern(language, "month"),
                SPACE,
                group(@"\d+", "year"),
                maybe(SPACE),
                maybe(oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix")),
                END
                );

            return(pattern);
        }
コード例 #5
0
        private static string GetPattern(EnumLanguage language = EnumLanguage.NONE)
        {
            string pattern = "";

            switch (language)
            {
            case EnumLanguage.IT:
            {
                // ^(?:(?:Intorno\sal|circa)\s)?(?<yearMin>\d{3,})(?:\s*[;\-\/]\s*)(?<yearMax>\d{2,})\s*(?<suffix>a\.?C\.?|d\.?C\.?)?$
                pattern = String.Concat(
                    START,                                                      // ^
                    maybe(oneof(new string[] { "tra lo", "in" }) + SPACE),      // (?:(?:tra lo|in)\s)?
                    maybe(DateCirca.Pattern(language) + SPACE),                 // (?:(?:Intorno\sal|circa)\s)?

                    oneof(new string[] {
                        String.Concat(
                            maybe(oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix1")),
                            maybe(SPACE),
                            group(@"\d+", "yearMin")
                            ),
                        String.Concat(
                            group(@"\d+", "yearMin"),
                            maybe(SPACE),
                            maybe(oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix1"))
                            )
                    }),
                    oneof(new string[] { @"\s*[\;\-\/]\s*", @"\sed?\slo\s" }),       // separator

                    oneof(new string[] {
                        String.Concat(
                            maybe(oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix2")),
                            maybe(SPACE),
                            group(@"\d+", "yearMax")
                            ),
                        String.Concat(
                            group(@"\d+", "yearMax"),
                            maybe(SPACE),
                            maybe(oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix2"))
                            )
                    }),
                    END                                                        // $
                    );
                break;
            }

            case EnumLanguage.NL:
            {
                pattern = String.Concat(
                    START,
                    maybe(@"tussen" + SPACE),     // "between"
                    maybe(DateCirca.Pattern(language) + maybe(SPACE)),
                    group(@"\d+", "yearMin"),
                    maybe(SPACE),
                    maybe(oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix1")),
                    @"\s*(?:[\;\-\/]|en)\s*",     // separators
                    maybe(DateCirca.Pattern(language) + maybe(SPACE)),
                    group(@"\d+", "yearMax"),
                    maybe(SPACE),
                    maybe(oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix2")),
                    END
                    );
                break;
            }

            default:
            {
                // ^(?:c(?:\.|irca)?)?\s*(?<yearMin>\d+)(?:\s*(?:[;\-\/]|to)\s*)(?<yearMax>\d+)\s*(?<suffix>AD|BC|CE|BP)?\s*\??$
                pattern = String.Concat(
                    START,
                    maybe(DateCirca.Pattern(language) + maybe(SPACE)),
                    oneof(new string[] {
                        group(@"[+-]?\d+", "yearMin"),
                        String.Concat(
                            maybe(oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix1")),
                            maybe(SPACE),
                            group(@"\d+", "yearMin")
                            ),
                        String.Concat(
                            group(@"\d+", "yearMin"),
                            maybe(SPACE),
                            maybe(oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix1"))
                            )
                    }),
                    @"\s*(?:[\;\-\/]|to)\s*",    // separators
                    oneof(new string[] {
                        group(@"[+-]?\d+", "yearMax"),
                        String.Concat(
                            maybe(oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix2")),
                            maybe(SPACE),
                            group(@"\d+", "yearMax")
                            ),
                        String.Concat(
                            group(@"\d+", "yearMax"),
                            maybe(SPACE),
                            maybe(oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix2"))
                            )
                    }),
                    END
                    );
                break;
            }
            }
            return(pattern);
        }
コード例 #6
0
        // done like this so they are only read once

        /* private static Lazy<IList<Ordinal>> _ordinals = new Lazy<IList<Ordinal>>(() => getOrdinals(), true);
         * private static IList<Ordinal> ordinals
         * {
         *   get
         *   {
         *       return _ordinals.Value;
         *   }
         * }
         * private static IList<Ordinal> getOrdinals()
         * {
         *   IList<Ordinal> ordinals = null;
         *   string path = "";
         *   if (System.Web.HttpContext.Current != null)
         *       path = System.Web.HttpContext.Current.Request.MapPath("~\\ordinals.json");
         *   else
         *       path = "ordinals.json"; // tests don't have HttpContext, so were failing
         *   ordinals = Newtonsoft.Json.JsonConvert.DeserializeObject<IList<Ordinal>>(System.IO.File.ReadAllText(path));
         *   return ordinals;
         * }
         */
        // attempt to get a match on ordinal

        /*protected int getOrdinalNoFromName(string name, EnumLanguage language)
         * {
         *  IOrdinal match = null;
         *  match = ordinals.FirstOrDefault(o => o.label == name.Trim().ToLower() && (language != EnumLanguage.NONE ? o.language == language : true));
         *  return (match == null ? 0 : match.value);
         * }      */

        private static string GetPattern(EnumLanguage language = EnumLanguage.NONE)
        {
            string pattern = "";

            switch (language)
            {
            case EnumLanguage.CY:
                pattern = String.Concat(
                    START,
                    maybe(DateCirca.Pattern(language) + SPACE),
                    maybe(oneof(Lookup <EnumDatePrefix> .Patterns(language), "prefix") + SPACE),
                    oneof(Lookup <EnumOrdinal> .Patterns(language), "ordinal"),
                    SPACE,
                    @"[cg]anrif",
                    maybe(SPACE + oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix")),
                    END
                    );
                break;

            case EnumLanguage.FR:
                pattern = String.Concat(
                    START,
                    maybe(DateCirca.Pattern(language) + SPACE),
                    maybe(oneof(Lookup <EnumDatePrefix> .Patterns(language), "prefix") + SPACE),
                    oneof(Lookup <EnumOrdinal> .Patterns(language), "ordinal"),
                    SPACE,
                    @"s(?:\.|iècle)",
                    maybe(SPACE + oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix")),
                    END
                    );
                break;

            case EnumLanguage.IT:
                pattern = String.Concat(
                    START,                                         // ^
                    maybe(DateCirca.Pattern(language) + SPACE),    // (?:(?:C(?:\.|irca)|Intorno al)\s)?
                    maybe(oneof(Lookup <EnumDatePrefix> .Patterns(language), "prefix") + SPACE),
                    oneof(new string[] {
                    @"sec(?:\.|olo)" + SPACE + oneof(Lookup <EnumOrdinal> .Patterns(language), "ordinal"),
                    oneof(Lookup <EnumOrdinal> .Patterns(language), "ordinal") + SPACE + @"sec(?:\.|olo)"
                }),
                    maybe(SPACE + oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix")), // (?:\s(?<suffix>a\.?C\.?|d\.?C\.?))?
                    END                                                                          // $
                    );
                break;

            case EnumLanguage.NL:
                pattern = String.Concat(
                    START,
                    maybe(DateCirca.Pattern(language) + SPACE),
                    maybe(oneof(Lookup <EnumDatePrefix> .Patterns(language), "prefix") + SPACE),
                    oneof(Lookup <EnumOrdinal> .Patterns(language), "ordinal"),
                    SPACE,
                    @"eeuw",
                    maybe(SPACE + oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix")),
                    END
                    );
                break;

            case EnumLanguage.SV:
                pattern = String.Concat(
                    START,
                    maybe(DateCirca.Pattern(language) + SPACE),
                    maybe(oneof(Lookup <EnumDatePrefix> .Patterns(language), "prefix") + SPACE),
                    oneof(Lookup <EnumOrdinal> .Patterns(language), "ordinal"),
                    SPACE,
                    @"århundrade",
                    maybe(SPACE + oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix")),
                    END
                    );
                break;

            default:
                pattern = String.Concat(
                    START,                                                                       // ^
                    maybe(DateCirca.Pattern(language) + SPACE),
                    maybe(oneof(Lookup <EnumDatePrefix> .Patterns(language), "prefix") + SPACE), // (?:
                    oneof(Lookup <EnumOrdinal> .Patterns(language), "ordinal"),
                    SPACE,
                    @"centur(?:y|ies)",
                    maybe(SPACE + oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix")),
                    END
                    );
                break;
            }
            return(pattern);
        }
コード例 #7
0
        private static string GetPattern(EnumLanguage language = EnumLanguage.NONE)
        {
            string pattern = "";

            switch (language)
            {
            case EnumLanguage.CY:
            {
                pattern = String.Concat(
                    START,
                    maybe(DateCirca.Pattern(language) + SPACE),
                    maybe(oneof(Lookup <EnumDatePrefix> .Patterns(language), "prefix1") + SPACE),
                    group(@"\d+", "centuryMin"),
                    oneof(new string[] { "af", "a?il", "ydd", "f?ed", "eg", "ain" }),
                    maybe(SPACE + "ganrif"),
                    @"\s*[\s\;\-\/]\s*",
                    maybe(oneof(Lookup <EnumDatePrefix> .Patterns(language), "prefix2") + SPACE),
                    group(@"\d+", "centuryMax"),
                    oneof(new string[] { "af", "a?il", "ydd", "f?ed", "eg", "ain" }),
                    SPACE,
                    "ganrif",
                    maybe(SPACE + oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix")),
                    END
                    );
                break;
            }

            case EnumLanguage.FR:
            {
                pattern = String.Concat(
                    START,
                    maybe(DateCirca.Pattern(language) + SPACE),
                    maybe(oneof(Lookup <EnumDatePrefix> .Patterns(language), "prefix1") + SPACE),
                    group(ROMAN, "centuryMin"),                          // (?<centuryMin>[MCDLXVI]+)
                    oneof(new string[] { "è?[mr]e", "er", "re", "[eè]", "n?de?", "o" }),
                    maybe(SPACE + @"s(?:\.|iècle)"),
                    @"\s*[\;\-\/]\s*",          // separators
                    maybe(oneof(Lookup <EnumDatePrefix> .Patterns(language), "prefix2") + SPACE),
                    group(ROMAN, "centuryMax"), // (?<centuryMax>[MCDLXVI]+)
                    oneof(new string[] { "è?[mr]e", "er", "re", "[eè]", "n?de?", "o" }),
                    maybe(SPACE + @"s(?:\.|iècle)"),
                    maybe(SPACE + oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix")),    // (?:\s(?<suffix>a\.?C\.?|d\.?C\.?))?
                    END
                    );
                break;
            }

            case EnumLanguage.IT:
            {
                pattern = String.Concat(
                    START,
                    maybe(@"tra(?:\slo)?" + SPACE),
                    maybe(DateCirca.Pattern(language) + SPACE),                                  // (?:(?:Intorno\sal|circa)\s)?
                    maybe(oneof(Lookup <EnumDatePrefix> .Patterns(language), "prefix1") + SPACE),
                    group(ROMAN, "centuryMin"),                                                  // (?<centuryMin>[MCDLXVI]+)
                    oneof(new string[] { @"\s*[e\;\-\/]\s*", @"\sed?\slo\s" }),                  // separator
                    maybe(oneof(Lookup <EnumDatePrefix> .Patterns(language), "prefix2") + SPACE),
                    group(ROMAN, "centuryMax"),                                                  // (?<centuryMax>[MCDLXVI]+)
                    maybe(SPACE + @"sec(?:\.|olo)"),
                    maybe(SPACE + oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix")), // (?:\s(?<suffix>a\.?C\.?|d\.?C\.?))?
                    END
                    );
                break;
            }

            case EnumLanguage.NL:
            {
                pattern = String.Concat(
                    START,
                    maybe(@"tussen" + SPACE),
                    maybe(DateCirca.Pattern(language) + SPACE),
                    maybe(oneof(Lookup <EnumDatePrefix> .Patterns(language), "prefix1") + SPACE),     //
                    group(@"\d+", "centuryMin"),
                    oneof(new string[] { "e", "ste", "de" }),
                    maybe(SPACE + "eeuw"),
                    @"\s*(?:[e\;\-\/]|en)\s*",     //separators
                    maybe(oneof(Lookup <EnumDatePrefix> .Patterns(language), "prefix2") + SPACE),
                    group(@"\d+", "centuryMax"),
                    oneof(new string[] { "e", "ste", "de" }),
                    SPACE,
                    "eeuw",
                    maybe(SPACE + oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix")),
                    END
                    );
                break;
            }

            default:
            {
                pattern = String.Concat(
                    START,                                                                        // ^
                    maybe(DateCirca.Pattern(language) + SPACE),
                    maybe(oneof(Lookup <EnumDatePrefix> .Patterns(language), "prefix1") + SPACE), //
                    group(@"\d+", "centuryMin"),                                                  // (?<centuryMin>\d+)
                    oneof(new string[] { "st", "nd", "rd", "th" }),
                    @"\s*(?:[e\;\-\/]|to)\s*",                                                    // separator
                    maybe(oneof(Lookup <EnumDatePrefix> .Patterns(language), "prefix2") + SPACE),
                    group(@"\d+", "centuryMax"),                                                  // (?<centuryMax>\d+)
                    oneof(new string[] { "st", "nd", "rd", "th" }),
                    SPACE,
                    "century",                                                                   // century
                    maybe(SPACE + oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix")), // (?:\s(?<suffix>A\.?D\.?|B\.?C\.?))?
                    END                                                                          // $
                    );
                break;
            }
            }

            return(pattern);
        }
コード例 #8
0
        private static string GetPattern(EnumLanguage language = EnumLanguage.NONE)
        {
            string pattern = "";

            switch (language)
            {
            case EnumLanguage.CY:
            {
                pattern = String.Concat(
                    START,
                    maybe(DateCirca.Pattern(language) + SPACE),
                    maybe(oneof(Lookup <EnumDatePrefix> .Patterns(language), "prefix") + SPACE),
                    group(@"\d+", "century"),
                    oneof(new string[] { "af", @"a?il", "ain", "ydd", @"f?ed", "eg" }),
                    SPACE,
                    "[cg]anrif",
                    maybe(SPACE + oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix")),
                    END
                    );
                break;
            }

            case EnumLanguage.DE:
            {
                pattern = String.Concat(
                    START,
                    maybe(DateCirca.Pattern(language) + SPACE),
                    maybe(oneof(Lookup <EnumDatePrefix> .Patterns(language), "prefix") + SPACE),
                    group(@"\d+", "century"),
                    @"\.",
                    SPACE,
                    "Jahrhundert",
                    END
                    );
                break;
            }

            case EnumLanguage.IT:
            {
                // ^(?:(?:C(?:\.|irca)|Intorno al)\s)?(?<millennium>[MCDLXVI]+)\s?(?:esimo|mo|°|º)?\smillennio(?:\s(?<suffix>a\.?C\.?|d\.?C\.?))?$
                // eg XI secolo | secolo XI | XIesimo secolo | XImo secolo | 11 ° secolo
                pattern = String.Concat(
                    START,                                              // ^
                    maybe(DateCirca.Pattern(language) + SPACE),         // (?:(?:C(?:\.|irca)|Intorno al)\s)?
                    maybe(oneof(Lookup <EnumDatePrefix> .Patterns(language), "prefix") + SPACE),
                    oneof(new string[] {
                        String.Concat(
                            @"sec(?:\.|olo)",
                            SPACE,
                            group(ROMAN, "century")
                            ),
                        String.Concat(
                            group(ROMAN, "century"),
                            SPACE,
                            @"sec(?:\.|olo)"
                            ),
                        String.Concat(
                            group(@"\d+", "century"),
                            maybe(SPACE),
                            maybe(oneof(new string[] { "esimo", "mo", "°", "º" })),          // (?:esimo|mo|°|º)?
                            SPACE,
                            @"sec(?:\.|olo)"
                            ),
                        group(ROMAN, "century")
                    }),
                    maybe(SPACE + oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix")), // (?:\s(?<suffix>a\.?C\.?|d\.?C\.?))?
                    END                                                                          // $
                    );
                break;
            }

            case EnumLanguage.FR:
            {
                // 11e siècle | XIe siècle av. J-C. | apr. J-C.
                // pattern = @"^(?<century>[MCDLXVI]+|\d+)e\s+siècle(?:\s+(?<suffix>av\.\sJ\-C\.|apr\.\sJ\-C\.))?$";
                pattern = String.Concat(
                    START,
                    maybe(DateCirca.Pattern(language) + SPACE),
                    maybe(oneof(Lookup <EnumDatePrefix> .Patterns(language), "prefix") + SPACE),
                    oneof(new string[] { ROMAN, @"\d+" }, "century"),
                    oneof(new string[] { "è?[mr]e", "er", "re", "[eè]", "n?de?", "o" }),
                    SPACE,
                    @"s(?:\.|iècle)",
                    maybe(SPACE + oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix")),
                    END
                    );
                break;
            }

            case EnumLanguage.ES:
            {
                // XI siglo | siglo XI
                //pattern = @"^(?:siglo\s+)?(?<century>[MCDLXVI]+|\d+)(?:\s+siglo)?$";
                pattern = String.Concat(
                    START,
                    maybe(DateCirca.Pattern(language) + SPACE),
                    maybe(oneof(Lookup <EnumDatePrefix> .Patterns(language), "prefix") + SPACE),
                    maybe("Siglo" + SPACE),
                    oneof(new string[] { ROMAN, @"\d+" }, "century"),
                    maybe(SPACE + "Siglo"),
                    maybe(SPACE + oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix")),
                    END
                    );
                break;
            }

            case EnumLanguage.NL:
            {
                pattern = String.Concat(
                    START,
                    maybe(DateCirca.Pattern(language) + SPACE),
                    maybe(oneof(Lookup <EnumDatePrefix> .Patterns(language), "prefix") + SPACE),
                    group(@"\d+", "century"),
                    oneof(new string[] { "e", "ste", "de" }),
                    SPACE,
                    "eeuw",
                    maybe(SPACE + oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix")),
                    END
                    );
                break;
            }

            case EnumLanguage.SV:
            {
                // 1700-talet | 18:e århundradet | 18:e seklet | 1700-tal
                pattern = String.Concat(
                    START,
                    maybe(DateCirca.Pattern(language) + SPACE),
                    maybe(oneof(Lookup <EnumDatePrefix> .Patterns(language), "prefix") + SPACE),
                    oneof(new string[] {
                        String.Concat(
                            group(@"\d+", "century"),
                            oneof(new string[] { ":a", ":e" }),
                            SPACE,
                            oneof(new string[] { "århundradet", "seklet" })
                            ),
                        String.Concat(
                            group(@"\d+00", "century"),
                            @"-tal",
                            maybe("et")
                            )
                    }),
                    maybe(SPACE + oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix")),
                    END
                    );
                break;
            }

            default:
            {
                //pattern = @"^(?:c(?:irca|\.)?\s+)?(?<centuryNo>\d+)(?:st|nd|rd|th)\s+(?:century|centuries)(?:\s+(?<suffix>ad|bc|ce))?$";
                pattern = String.Concat(
                    START,                                                                       // ^
                    maybe(DateCirca.Pattern(language) + SPACE),
                    maybe(oneof(Lookup <EnumDatePrefix> .Patterns(language), "prefix") + SPACE), // (?:(?:C(?:\.|irca)|Intorno al)\s)?
                    group(@"\d+", "century"),                                                    // (?<century>\d+)
                    oneof(new string[] { "st", "nd", "rd", "th" }),
                    SPACE,
                    "century",                                                                   // century
                    maybe(SPACE + oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix")), // (?:\s(?<suffix>A\.?D\.?|B\.?C\.?))?
                    END                                                                          // $
                    );
                break;
            }
            }
            return(pattern);
        }
コード例 #9
0
        private static string GetPattern(EnumLanguage language = EnumLanguage.NONE)
        {
            string pattern = "";

            switch (language)
            {
            case EnumLanguage.CY:
            {
                pattern = String.Concat(
                    START,
                    maybe(DateCirca.Pattern(language) + SPACE),
                    maybe(oneof(Lookup <EnumDatePrefix> .Patterns(language), "prefix") + SPACE),
                    group(@"\d+", "millennium"),
                    oneof(new string[] { "af", @"a?il", "ain", "ydd", @"f?ed", "eg" }),
                    SPACE,
                    "mileniwm",
                    maybe(SPACE + oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix")),
                    END
                    );
                break;
            }

            case EnumLanguage.FR:
            {
                pattern = String.Concat(
                    START,
                    maybe(DateCirca.Pattern(language) + SPACE),
                    maybe(oneof(Lookup <EnumDatePrefix> .Patterns(language), "prefix") + SPACE),
                    oneof(new string[] { ROMAN, @"\d+" }, "millennium"),
                    oneof(new string[] { "è?[mr]e", "er", "re", "[eè]", "n?de?", "o" }),
                    SPACE,
                    "millénaire",
                    maybe(SPACE + oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix")),
                    END
                    );
                break;
            }

            case EnumLanguage.IT:
                // ^(?:(?:C(?:\.|irca)|Intorno al)\s)?(?<millennium>[MCDLXVI]+)\s?(?:esimo|mo|°|º)?\smillennio(?:\s(?<suffix>a\.?C\.?|d\.?C\.?))?$
                pattern = String.Concat(
                    START,
                    maybe(DateCirca.Pattern(language) + SPACE),
                    maybe(oneof(Lookup <EnumDatePrefix> .Patterns(language), "prefix") + SPACE),     // (?:(?:C(?:\.|irca)|Intorno al)\s)?
                    oneof(new string[] {
                    String.Concat(
                        "millennio",
                        SPACE,
                        oneof(new string[] { ROMAN, @"\d+" }, "millennium"),
                        maybe(SPACE),
                        maybe(oneof(new string[] { "esimo", "mo", "°", "º" }))         // (?:esimo|mo|°|º)?
                        ),
                    String.Concat(
                        oneof(new string[] { ROMAN, @"\d+" }, "millennium"),
                        maybe(SPACE),
                        maybe(oneof(new string[] { "esimo", "mo", "°", "º" })),         // (?:esimo|mo|°|º)?
                        "millennio"
                        )
                }),
                    maybe(SPACE + oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix")), // (?:\s(?<suffix>a\.?C\.?|d\.?C\.?))?
                    END                                                                          // $
                    );
                break;

            default:
                // ^(?:(?:C(?:\.|irca)|around|approx(?:\.|imately))\s)?(?<millennium>\d+)(?:st|nd|rd|th)\smillennium(?:\s(?<suffix>AD|BC|CE|BP))?$
                pattern = String.Concat(
                    START,
                    maybe(DateCirca.Pattern(language) + SPACE),
                    maybe(oneof(Lookup <EnumDatePrefix> .Patterns(language), "prefix") + SPACE), // (?:(?:C(?:\.|irca)|around|approx(?:\.|imately))\s)?
                    group(@"\d+", "millennium"),                                                 // (?<millennium>\d+)
                    oneof(new string[] { "st", "nd", "rd", "th" }),                              // (?:st|nd|rd|th)
                    SPACE,                                                                       // \s
                    "millennium",                                                                // millennium
                    maybe(SPACE + oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix")), // (?:\s(?<suffix>AD|BC|CE|BP))?
                    END                                                                          // $
                    );
                break;
            }
            return(pattern);
        }
コード例 #10
0
        private static string GetPattern(EnumLanguage language = EnumLanguage.NONE)
        {
            string pattern = "";

            switch (language)
            {
            case EnumLanguage.CY:
                pattern = String.Concat(
                    START,
                    maybe(DateCirca.Pattern(language) + SPACE),
                    maybe(oneof(Lookup <EnumDatePrefix> .Patterns(language), "prefix") + SPACE),
                    oneof(Lookup <EnumOrdinal> .Patterns(language), "ordinal"),
                    SPACE,
                    "mileniwm",
                    maybe(SPACE + oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix")),
                    END
                    );
                break;

            case EnumLanguage.FR:
                pattern = String.Concat(
                    START,
                    maybe(DateCirca.Pattern(language) + SPACE),
                    maybe(oneof(Lookup <EnumDatePrefix> .Patterns(language), "prefix") + SPACE),
                    oneof(Lookup <EnumOrdinal> .Patterns(language), "ordinal"),
                    SPACE,
                    "millénaire",
                    maybe(SPACE + oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix")),
                    END
                    );
                break;

            case EnumLanguage.IT:
                pattern = String.Concat(
                    START,                                         // ^
                    maybe(DateCirca.Pattern(language) + SPACE),    // (?:(?:C(?:\.|irca)|Intorno al)\s)?
                    maybe(oneof(Lookup <EnumDatePrefix> .Patterns(language), "prefix") + SPACE),
                    oneof(new string[] {
                    @"millennio\s" + oneof(Lookup <EnumOrdinal> .Patterns(language), "ordinal"),
                    oneof(Lookup <EnumOrdinal> .Patterns(language), "ordinal") + @"\smillennio"
                }),
                    maybe(SPACE + oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix")), // (?:\s(?<suffix>a\.?C\.?|d\.?C\.?))?
                    END                                                                          // $
                    );
                break;

            default:
                pattern = String.Concat(
                    START,                                                                       // ^
                    maybe(DateCirca.Pattern(language) + SPACE),
                    maybe(oneof(Lookup <EnumDatePrefix> .Patterns(language), "prefix") + SPACE), // (?:
                    oneof(Lookup <EnumOrdinal> .Patterns(language), "ordinal"),
                    SPACE,
                    "millennium",
                    maybe(SPACE + oneof(Lookup <EnumDateSuffix> .Patterns(language), "suffix")),
                    END
                    );
                break;
            }
            return(pattern);
        }