use crate::emoji::EMOJI_PATTERN;
use regex::Regex;
pub const SPACES: &str = r"\s+";
pub const ORDINAL_L1: &str = r"(?-u:\d*1\dth|[04-9]th|1st|2nd|3rd|[02-9]1st|[02-9]2nd|[02-9]3rd|[02-9][04-9]th|\d+\d[04-9]th|\d+\d1st|\d+\d2nd|\d+\d3rd)";
pub const NUMBER_L1: &str = r"(?-u:\d+/\d+|\d(?:[\.,\-/]?\d)*(?:\.\d+)?)";
pub const NUMBER_DV: &str = r"[\x{0966}-\x{096F}]+/[\x{0966}-\x{096F}]+|[\x{0966}-\x{096F}](?:[\.,\-/]?[\x{0966}-\x{096F}])*(?:\.[\x{0966}-\x{096F}]+)?";
pub const MENTION: &str = r"@(?-u:\w)+";
pub const HASHTAG_L1: &str = r"(?i)#[a-z\x{00C0}-\x{00D6}\x{00D8}-\x{00F6}\x{00F8}-\x{00FF}_][a-z0-9\x{00C0}-\x{00D6}\x{00D8}-\x{00F6}\x{00F8}-\x{00FF}_]*";
pub const HASHTAG_DV: &str = r"(?i)#[\x{0900}-\x{0963}\x{0970}-\x{097F}_][\x{0900}-\x{0963}\x{0970}-\x{097F}\x{0966}-\x{096F}0-9_]*";
pub const EMAIL: &str = r"(?i)[\-!#$%&'*+/=?^A-Za-z0-9_{|}~](?:\.?[\-!#$%&'*+/=?^A-Za-z0-9_`{|}~])*@[a-z0-9](?:-?\.?[a-z0-9])*(?:\.[a-z](?:-?[a-z0-9])*)+";
pub const CURRENCY: &str = r"[\x{20BF}\x{20BD}\x{20B9}\x{20A8}$\x{00A3}\x{00A5}\x{20AC}\x{20A9}]";
pub const PUNCTUATION: &str =
"['\u{2019}\u{2018}\u{2019}`\u{201C}\u{201D}\"\\[\\](){}\u{2026},.!;?\\-:\u{0964}\u{0965}]";
pub const QUOTED_PHRASE: &str = r#""[^"]*""#;
pub const URL: &str =
r"(?i)(?:https?://)(?:[\da-z\.\-]+)\.(?:[a-z\.]{2,6})(?:[/A-Za-z0-9_\.\-?#=]*)*/?";
pub const EMOTICON: &str = r"(?i):-?[dps*/\[\]{}()]|;-?[/()d]|<3";
pub const TIME: &str =
r"(?i)(?:(?-u:\d)|[01](?-u:\d)|2[0-3]):?(?:[0-5][0-9])?\s?(?:[ap]\.?m\.?|hours|hrs)";
pub const WORD_L1: &str = r"(?i)[a-z\x{00C0}-\x{00D6}\x{00D8}-\x{00F6}\x{00F8}-\x{00FF}][a-z\x{00C0}-\x{00D6}\x{00D8}-\x{00F6}\x{00F8}-\x{00FF}']*";
pub const WORD_DV: &str = r"(?i)[\x{0900}-\x{094F}\x{0951}-\x{0963}\x{0970}-\x{097F}]+";
pub const SYMBOL: &str = r"[\x{0950}~@#%\^\+=\*\|/<>&]";
pub const POS_SINGULAR: &str = r"(?i)^([a-z]+)('s)$";
pub const POS_PLURAL: &str = r"(?i)^([a-z]+s)(')$";
pub const QUOTED_PHRASE_CAT: &str = "quoted_phrase";
pub const URL_CAT: &str = "url";
pub const EMAIL_CAT: &str = "email";
pub const MENTION_CAT: &str = "mention";
pub const HASHTAG_CAT: &str = "hashtag";
pub const EMOJI_CAT: &str = "emoji";
pub const EMOTICON_CAT: &str = "emoticon";
pub const TIME_CAT: &str = "time";
pub const ORDINAL_CAT: &str = "ordinal";
pub const NUMBER_CAT: &str = "number";
pub const CURRENCY_CAT: &str = "currency";
pub const WORD_CAT: &str = "word";
pub const PUNCTUATION_CAT: &str = "punctuation";
pub const SYMBOL_CAT: &str = "symbol";
#[derive(Debug, Clone)]
pub struct Rule {
pub regex: Regex,
pub category: String,
}
pub fn master() -> Vec<Rule> {
let specs: [(&str, &str); 17] = [
(QUOTED_PHRASE, QUOTED_PHRASE_CAT),
(URL, URL_CAT),
(EMAIL, EMAIL_CAT),
(MENTION, MENTION_CAT),
(HASHTAG_L1, HASHTAG_CAT),
(HASHTAG_DV, HASHTAG_CAT),
(EMOJI_PATTERN, EMOJI_CAT),
(EMOTICON, EMOTICON_CAT),
(TIME, TIME_CAT),
(ORDINAL_L1, ORDINAL_CAT),
(NUMBER_L1, NUMBER_CAT),
(NUMBER_DV, NUMBER_CAT),
(CURRENCY, CURRENCY_CAT),
(WORD_L1, WORD_CAT),
(WORD_DV, WORD_CAT),
(PUNCTUATION, PUNCTUATION_CAT),
(SYMBOL, SYMBOL_CAT),
];
specs
.iter()
.map(|(pat, cat)| Rule {
regex: Regex::new(pat).expect("built-in pattern compiles"),
category: (*cat).to_string(),
})
.collect()
}