import re

from scattertext import RegexFeatAndOffsetGetter



REGEX_DICT = {
  "assessments": "((our|my)\\s+(opinion|understanding)\\s+(is|was)\\s+that))|((it\\s+(is|was)\\s+(our|my)\\s+(opinion|understanding)\\s+(that)?))|((in\\s+(our|my)\\s+opinion))|(((our|my)\\s+take\\s+on))|((it\\s+(seems|seemed)\\s+to\\s+(us|me)\\s+(that)?))|((it\\s+(seems|seemed)\\s+(that)?))|((it\\s+would\\s+seem\\s+to\\s+(us|me)?))|((it\\s+would\\s+appear\\s+to\\s+(us|me)?))|((it\\s+appears\\s+to\\s+(us|me)?))|(((the|my|our)\\s+([\\w]+[\\s+])?point\\s+is\\s+(that)?))|(((the|my|our)\\s+([\\w]+[\\s+\\,]*){1,2}\\s+point\\s+is\\s+(that)?))|((it\\s+(looks|looked)\\s+to\\s+(us|me)\\s+(as\\s+if|like)))|((it\\s+(looks|looked)\\s+(as\\s+if|like|that\\s+way)))|(((we|i)\\s+(have|get|got)\\s+the\\s+impression\\s+(that)?))|(((our|my)\\s+impression\\s+(was|is)\\s+(that)?))|((in\\s+(our|my)\\s+book))|((to\\s+(our|my)\\s+mind))|((to\\s+(our|my)\\s+way\\s+of\\s+thinking))|((as\\s+far\\s+as\\s+(I\\s+am|I\\s+was|we\\s+are|we\\s+were)\\s+concerned))|((if\\s+you\\s+ask\\s+(me|us)))|(((our|my)\\s+feeling\\s+(is|was|would\\s+be)))|((from\\s+where\\s+(I\\'m|I\\s+am)\\s+(standing|sitting)))|(((we|I)\\s+(don\\'t)?\\s+think\\s+(that)?))|((all\\s+(we\\'re|I\\'m)\\s+saying\\s+is))|((what\\s+(I\\'m|we\\'re)\\s+saying\\s+is))|(((we\\'re|I\\'m)\\s+(not)?\\s+saying\\s+that))|((what\\s+(we\\'re|i\\'m)\\s+trying\\s+to\\s+say\\s+is))|((what\\s+(we|i)\\s+mean\\s+is\\s+(that)?)",
  "authority": r"according\s+to",
  "causation": "((so))|((therefore))|((because))|((hence))|((as\\s+a\\s+result))|((consequently))",
  "conditionals": "((if\\s+(we|you)\\s+want\\s+to\\s+([\\w]+[\\s+\\,]+){1,7}(we|you)\\s+(need\\s+to|must|have\\s+to)))|(((we|you)\\s+([\\w\\s+,]+)\\s+(must|have\\s+to|need\\s+to)\\s+([\\w]+[\\s+\\,]+){1,7}if\\s+\\s+(you|we)\\s+want\\s+to))|((it\\s+would\\s+be\\s+([\\w]+[\\s+\\,]+){0,2}nice\\s+if))|((wouldn\\'t\\s+it\\s+be\\s+([\\w]+[\\s+\\,]+){0,2}nice\\s+if))|((if\\s+([\\w]+[\\s+\\,]+){3,8}\\s+that\\s+would\\s+be\\s+([\\w]+[\\s+\\,]+){0,2}nice))|(((cannot|will\\s+not|won\\'t|can\\'t)\\s+([\\w]+[\\s+\\,]+){1,7}(if|unless)))|(((if|unless)\\s+([\\w]+[\\s+\\,]+){3,10}(cannot|will\\s+not|won\\'t|can\\'t)))|(((need|needs|must|has\\s+to|have\\s+to)\\s+([\\w]+[\\s+\\,]+){3,10}(in\\s+order\\s+)to))|(((in\\s+order\\s+)?to\\s+([\\w]+[\\s+\\,]+){3,10}(need|needs|must|has\\s+to|have\\s+to)))|((as\\s+long\\s+as\\s+(we|you)\\s+([\\w]+[\\s+\\,]+){3,10}(will|can|able|should|[a-zA-Z]+\\'ll)))|((([a-zA-Z]\\'ll|will|can|able|should)\\s+([\\w]+[\\s+\\,]+){3,10}as\\s+long\\s+as\\s+(we|you)))|(((you|he|we)\\s+better\\s+([\\w]+[\\s+\\,]+){3,10}or))|((otherwise))",
  "contrast": "((really))|((actually))|((as\\s+opposed\\s+to))|((instead\\s+of))|((rather\\s+than))|((there\\s+(are|is)\\s+([\\w]+[\\s+\\,]*){1,4}\\s+and\\s+(then\\s+)?there\\s+(are|is)))|(((is|that\\'s|it\\'s)\\s+a\\s+whole\\s+nother\\s+issue))|(((is|are|that\\'s|it\\'s)\\s+(very|quite|completely|totally\\s+)?different))|((whole\\s+new\\s+ballgame))|(((is|that\\'s|it\\'s)\\s+a\\s+(separate|different)\\s+(issue|question)))",
  "difficulty": "((((be|is|am|are|were|was|been|being))\\s+((absolutely|absurdly|resoundingly|amazingly|awfully|extremely|completely|highly|incredibly|perfectly|quite|really|strikingly|surprisingly|terribly|totally|unbelievably|hugely|unnaturally|unusually|utterly|very|tremendously|spectacularly))?easy))|((((be|is|am|are|were|was|been|being))\\s+a\\s+((absolute|extreme|incredible|perfect|phenomenal|spectacular|huge|major|tremendous|complete|considerable|real|terrible|total|unbelievable|utter|great|resounding))?breeze))|((((be|is|am|are|were|was|been|being))\\s+a\\s+((absolute|extreme|incredible|perfect|phenomenal|spectacular|huge|major|tremendous|complete|considerable|real|terrible|total|unbelievable|utter|great|resounding))?walk\\s+in\\s+the\\s+park))|((((be|is|am|are|were|was|been|being))\\s+a\\s+((absolute|extreme|incredible|perfect|phenomenal|spectacular|huge|major|tremendous|complete|considerable|real|terrible|total|unbelievable|utter|great|resounding))?piece\\s+of\\s+cake))|((((be|is|am|are|were|was|been|being))\\s+a\\s+((absolute|extreme|incredible|perfect|phenomenal|spectacular|huge|major|tremendous|complete|considerable|real|terrible|total|unbelievable|utter|great|resounding))?snap))|((((be|is|am|are|were|was|been|being))\\s+a\\s+((absolute|extreme|incredible|perfect|phenomenal|spectacular|huge|major|tremendous|complete|considerable|real|terrible|total|unbelievable|utter|great|resounding))?cinch))|((((be|is|am|are|were|was|been|being))\\s+((absolute|extreme|incredible|perfect|phenomenal|spectacular|huge|major|tremendous|complete|considerable|real|terrible|total|unbelievable|utter|great|resounding))?child's\\s+play))|((((be|is|am|are|were|was|been|being))\\s+((absolutely|absurdly|resoundingly|amazingly|awfully|extremely|completely|highly|incredibly|perfectly|quite|really|strikingly|surprisingly|terribly|totally|unbelievably|hugely|unnaturally|unusually|utterly|very|tremendously|spectacularly))?difficult))|((((be|is|am|are|were|was|been|being))\\s+a\\s+((absolute|extreme|incredible|perfect|phenomenal|spectacular|huge|major|tremendous|complete|considerable|real|terrible|total|unbelievable|utter|great|resounding))?pain))|((((be|is|am|are|were|was|been|being))\\s+a\\s+((absolute|extreme|incredible|perfect|phenomenal|spectacular|huge|major|tremendous|complete|considerable|real|terrible|total|unbelievable|utter|great|resounding))?pain\\s+in\\s+the\\s+(butt|neck|ass)))|((((be|is|am|are|were|was|been|being))\\s+a\\s+((absolute|extreme|incredible|perfect|phenomenal|spectacular|huge|major|tremendous|complete|considerable|real|terrible|total|unbelievable|utter|great|resounding))?(bitch|bastard)\\s+to))|((((be|is|am|are|were|was|been|being))\\s+no\\s+picnic))|((((be|is|am|are|were|was|been|being))\\s+((absolutely|absurdly|resoundingly|amazingly|awfully|extremely|completely|highly|incredibly|perfectly|quite|really|strikingly|surprisingly|terribly|totally|unbelievably|hugely|unnaturally|unusually|utterly|very|tremendously|spectacularly))?tricky))|((((be|is|am|are|were|was|been|being))\\s+((absolutely|absurdly|resoundingly|amazingly|awfully|extremely|completely|highly|incredibly|perfectly|quite|really|strikingly|surprisingly|terribly|totally|unbelievably|hugely|unnaturally|unusually|utterly|very|tremendously|spectacularly))?arduous))|((((be|is|am|are|were|was|been|being))\\s+a\\s+((absolute|extreme|incredible|perfect|phenomenal|spectacular|huge|major|tremendous|complete|considerable|real|terrible|total|unbelievable|utter|great|resounding))?challenge))|((((be|is|am|are|were|was|been|being))\\s+((absolutely|absurdly|resoundingly|amazingly|awfully|extremely|completely|highly|incredibly|perfectly|quite|really|strikingly|surprisingly|terribly|totally|unbelievably|hugely|unnaturally|unusually|utterly|very|tremendously|spectacularly))?challenging))|((((have|has|had|having))\\s+a\\s+((absolutely|absurdly|resoundingly|amazingly|awfully|extremely|completely|highly|incredibly|perfectly|quite|really|strikingly|surprisingly|terribly|totally|unbelievably|hugely|unnaturally|unusually|utterly|very|tremendously|spectacularly))?(hard|difficult)\\s+time))",
  "doubt": "(((i\\s+am|i\\'m)\\s+not\\s+(sure|convinced)))|((i\\s+(don\\'t|can\\'t|do\\s+not|cannot)\\s+see\\s+how))|((it\\s+(is\\s+not|isn\\'t)\\s+(clear|evident|obvious)\\s+(that)?))|((it\\'s\\s+not\\s+(clear|evident|obvious)\\s+(that)?))|(((we|i)\\s+doubt\\s+(that)?))|(((we|i)\\s+(am|are)\\s+doubtful))|(((we\\'re|i\\'m)\\s+doubtful))",
  "emphasis": "(((clearly))|((obviously))|((patently))|((when\\s+you\\s+(really\\s+)?think\\s+about\\s+it))|(((it\\s+is|it\\'s)\\s+((really|pretty)\\s+)?(obvious|evident|clear)\\s+(that)?))|((definitely))|((i\\s+have\\s+to\\s+say))|((i\\'ve\\s+got\\s+to\\s+say))|((i\\'ve\\s+gotta\\s+say))|((i\\s+should\\s+say))|((surely))|((for\\s+sure))|((((be|is|am|are|were|was|been|being))\\s+((sure)|(certain)|(confident))\\s+(that)?))|((of\\s+course))|((no\\s+doubt\\s+about\\s+it))|((doubtless))|((without\\s+a\\s+doubt))|((I\\s+have\\s+no\\s+doubt\\s+(that)?))|((I\\s+bet\\s+(that)?))|((((be|is|am|are|were|was|been|being))\\s+bound\\s+to))|((no\\s+two\\s+ways\\s+about\\s+it))|((there\\s+((is)|(are))\\s+no\\s+two\\s+ways\\s+about\\s+it))|((there\\'s\\s+no\\s+two\\s+ways\\s+about\\s+it))|((((the)|(one))\\s+((thing)|(issue)|(question)|(problem))\\s+((might|may|could|can|should|shall|will|would)\\s+)?((be|is|am|are|were|was|been|being))\\s+(that)?))|((my\\s+feeling\\s+is\\s+(that)?))|((that\\'s\\s+why))|((that\\s+is\\s+why))|((the\\s+idea\\s+(here\\s+)?is\\s+(that)?))|((((my)|(the))\\s+whole\\s+((point)|(question))\\s+is))|((what\\s+you\\s+have\\s+to\\s+do\\s+is))|((the\\s+reason\\s+is\\s+(that)?))|((here\\'s\\s+what))|((here\\s+is\\s+what))|((exactly))|((precisely))|((((am\\s+going\\s+to|are\\s+going\\s+to|is\\s+going\\s+to|am\\s+gonna|are\\s+gonna|is\\s+gonna))))|((((am\\s+not\\s+going\\s+to|are\\s+not\\s+going\\s+to|is\\s+not\\s+going\\s+to|am\\s+not\\s+gonna|are\\s+not\\s+gonna|is\\s+not\\s+gonna|ain\\'t\\s+gonna|isn\\'t\\s+gonna|aren\\'t\\s+gonna))))|((((i\\'m\\s+not\\s+going\\s+to|they\\'re\\s+not\\s+going\\s+to|she\\'s\\s+not\\s+going\\s+to|it\\'s\\s+not\\s+going\\s+to|we\\'re\\s+not\\s+going\\s+to|i\\'m\\s+not\\s+gonna|you\\'re\\s+not\\s+gonna|he\\'s\\s+not\\s+gonna|she\\'s\\s+not\\s+gonna|it\\'s\\s+not\\s+gonna|we\\'re\\s+not\\s+gonna|they\\'re\\s+not\\s+gonna|that\\'s\\s+not\\s+gonna))))|((((i\\'m\\s+going\\s+to|they\\'re\\s+going\\s+to|she\\'s\\s+going\\s+to|it\\'s\\s+going\\s+to|we\\'re\\s+going\\s+to|i\\'m\\s+gonna|you\\'re\\s+gonna|i\\'m\\s+gonna|you\\'re\\s+gonna|he\\'s\\s+gonna|she\\'s\\s+gonna|it\\'s\\s+gonna|we\\'re\\s+gonna|they\\'re\\s+gonna|that\\'s\\s+gonna))))|((what\\s+will\\s+happen\\s+is))|((what\\'ll\\s+happen\\s+is))|((what\\'s\\s+((gonna)|(going\\s+to))\\s+happen\\s+is))|((what\\s+is\\s+((gonna)|(going\\s+to))\\s+happen\\s+is))|((i\\s+want\\s+to\\s+(highlight|emphasize|underscore))))",
  "generalization": "((((everybody|everything|anybody|anything|nobody|nothing)\\s+(else|at\\s+all)))|((in\\s+the\\s+(world|universe)))|((of\\s+all\\s+times))|((in\\s+recent\\s+memory))|((in\\s+living\\s+history)))",
  "inconsistency": "(((except\\s+that))|((except\\s+for))|((with\\s+the\\s+exception\\s+of))|((however))|((nevertheless))|((that\\s+said))|((that\\s+having\\s+been\\s+said))|((that\\s+being\\s+said))|((despite))|((in\\s+spite\\s+of))|((even\\s+so))|((at\\s+the\\s+same\\s+time))|((still))|((wait\\s+a\\s+minute))|((hold\\s+on\\s+a\\s+second))|((hold\\s+on\\s+a\\s+sec))|((it\\'s\\s+just\\s+that))|((all\\s+well\\s+and\\s+good))|((as\\s+far\\s+as\\s+it\\s+goes))|((you\\s+might\\s+think\\s+(that)?))|((you\\s+may\\s+think\\s+(that)?)))",
  "inyourshoes": "(((what\\s+i\\s+would\\s+do))|((if\\s+i\\s+were\\s+you))|((i\\s+would\\s+not))|((i\\s+wouldn\\'t)))",
  "necessity": "(((a\\s+must))|((must))|((essential))|((indispensable))|((necessary))|((((be|is|am|are|were|was|been|being))\\s+a\\s+necessity))|((needed))|((required))|((requirement))|((can\\'t\\s+do\\s+without))|((got\\s+to))|((gotta))|((had\\s+better))|((hafta))|((have\\s+to))|((has\\s+to))|((need\\s+to))|((needs\\s+to))|((ought\\s+to))|((oughta))|((should))|((((i|you|he|she|it|we|they))\\s+better))|(((necesssitates|necessitated|necessitating|necessitate))))",
  "possibility": "(((you\\s+can))|((we\\s+can))|((you\\s+can\\'t))|((you\\s+cannot))|((we\\s+can\\'t))|((we\\s+cannot))|((you\\s+could))|((we\\s+could))|((((be|is|am|are|were|was|been|being))\\s+able\\s+to))|((there\\'s\\s+no\\s+way\\s+(that|for|of|to)?))|((any\\s+way\\s+(that|for|of|to)?))|((no\\s+way)))",
  "priority": "(((important))|((crucial))|((key))|((essential))|((critical))|((fundamental))|((key))|((major))|((vital))|((first\\s+and\\s+foremost))|(((now\\s+)?remember\\s+(that)?))|((keep\\s+in\\s+mind\\s+(that)?))|((don\\'t\\s+forget\\s+(that)?))|((let\\'s\\s+not\\s+forget))|((let\\'s\\s+keep\\s+in\\s+mind))|((let\\'s\\s+remember)))",
  "rhetoricalquestion": "(((do\\s+(we|you)\\s+(actually|really|still)\\s+(need|want)))|((why\\s+not))|((why\\s+don\\'t\\s+(we|you)))|((what\\s+if))|(((and\\s+)?who\\s+(wouldn\\'t|doesn\\'t)\\s+((like|adore|want|prefer|love|enjoy)))))",
  "structure": "(((first))|((secondly))|((first\\s+place))|((in\\s+the\\s+first\\s+place))|((first\\s+of\\s+all)))",
  "wants": "((((you|we|i)\\s+(don\\'t\\s+)?(want|wanna)))|(((you|we|i)\\s+might\\s+(not\\s+)?(want|wanna))))"
}

def span_getter(match: re.Match):
    return match.span('main')

def get_arglex_offset_getter() -> RegexFeatAndOffsetGetter:
    '''
    When using this, feature, cite the feature set as:
    Swapna Somasundaran, Josef Ruppenhofer, and Janyce Wiebe. 2007. Detecting Arguing and Sentiment in Meetings. In Proceedings of the 8th SIGdial Workshop on Discourse and Dialogue, pages 26–34, Antwerp, Belgium. Association for Computational Linguistics
    '''

    regex_dict = REGEX_DICT
    return RegexFeatAndOffsetGetter(
        regex_dict={k:'(?P<main>' + v + ')' for k,v in regex_dict.items()},
        flags=re.M | re.U | re.I,
        span_getter=span_getter
    )
