Skip to content

Instantly share code, notes, and snippets.

@mesejo
Created November 4, 2021 10:41
Show Gist options
  • Save mesejo/c4a330ed75f32e07ffc444b983fbf810 to your computer and use it in GitHub Desktop.
Save mesejo/c4a330ed75f32e07ffc444b983fbf810 to your computer and use it in GitHub Desktop.
Atomic Groups vs Non-Atomic Groups
import perfplot
import re
import random
from string import ascii_lowercase
pattern = r"(?=(n(?:e(?:c(?:essary|k)|ed|xt|ighborly)|o(?:tebook|ndescript|rmal|is[ey])|a(?:ppy|me|useating|t(?:ion|ural))|i(?:fty|ne|ce|ppy)|u(?:mber(?:less)?|t))|k(?:ey|i(?:ck|nd|ll)|no(?:ck|t))|z(?:oo|any|i(?:nc|p)|ephyr)|v(?:o(?:ice|latile)|e(?:in|rsed?)|ulgar|a(?:nish|cuous|se)|iolet)|y(?:oung|a(?:rd|k)|ummy)|g(?:a(?:ze|rrulous)|e(?:ese|ntle)|l(?:ass|eaming|ue)|iant|o(?:od|ld|vernment)|u(?:itar|llible|ar(?:antee|ded)|sty)|host|r(?:ieving|ubby|e(?:en|a(?:sy|t))|o(?:u(?:chy|nd)|an|ovy)|a(?:ndfather|pe|ceful|t(?:is|e)|b)))|j(?:u(?:m(?:bled|p)|icy)|e(?:wel|lly)|a(?:il|zzy)|o(?:yous|lly|g))|u(?:mbrella|gliest|tter|sed?|n(?:becoming|ruly|fasten|kempt|used|wieldy|derstood|pack|a(?:ccountable|ble)|i(?:que|nterested|t)|equaled|s(?:ightly|uitable)|cle)|p)|i(?:tchy|cy|gnore|m(?:mense|p(?:erfect|o(?:rtant|lite|ssible)))|ll(?:\-informed|ustrious)|n(?:ject|v(?:incible|ention)|c(?:re(?:ase|dible)|ompetent)|nate|t(?:roduce|e(?:lligent|rest(?:ing)?))|sidious))|r(?:i(?:nse|ght|fle|ver)|u(?:ral|thless|le|d(?:dy|e)|in|b)|o(?:mantic|ugh|ll|bust|yal|[dt])|e(?:t(?:urn|ire)|bel|gret|m(?:iniscent|ember)|l(?:igion|a(?:tion|x)|ease)|flect|quest|s(?:ponsible|cue)|ward|a(?:dy|ction|son)|p(?:resentative|eat|ly)|co(?:ndite|rd)|dundant)|a(?:ce|mpant|i(?:se|lway)|diate|t(?:ty)?|spy|b(?:bits?|id)))|w(?:i(?:cked|ggly|de\-eyed|n(?:d(?:ow|y)|e)|l(?:ling|derness))|h(?:ole|i(?:ne|sper(?:ing)?|te|p))|a(?:ll|ve|r(?:like|[nm])?|iting|n(?:t(?:ing)?|der)|keful)|r(?:ist|ong|en(?:ch)?|y)|e(?:ll\-(?:groomed|made)|a(?:lth|k))|o(?:nderful|m(?:en|an)|ozy|bble|r(?:k(?:able)?|thless|r(?:ied|y)|d)))|qu(?:ack|estion|i(?:nce|ckest|ver|et|l[tl]))|p(?:h(?:obic|ysical)|r(?:ick|ay|e(?:ach|cious|vent|tend)|o(?:mise|bable|tective|fit|duce|perty|ud|gram|vide))|e(?:ck|ncil|r(?:iodic|son|mi(?:ssible|t)|form)|ace(?:ful)?|t)|u(?:rple|blic|zzling|ll|n(?:cture|ishment))|l(?:eas(?:ure|ant)|ough|a(?:in|stic|n(?:es?|t(?:ation)?)?|ce|usible|y))|a(?:use|ddle|r(?:ched|t(?:ner)?)|instaking|le|s(?:te|s)|n(?:cake)?|t)|o(?:w(?:er|der)|cket|ke|tato|ison|li(?:sh|t(?:ical|e))|s(?:s(?:essive|ible)|t))|i(?:zzas|quant|ck(?:le)?|pe|[ne]))|e(?:quable|scape|gg(?:nog)?|r(?:ror|ect)|vent|n(?:ormous|ergetic|d(?:urable)?|joy|courag(?:ing|e)|ter(?:taining)?)|fficacious|d(?:ge|ucat(?:ion|ed?))|yes|m(?:barrass|p(?:loy|ty))|l(?:bow|a(?:ted|stic)|e(?:gant|ctric))|x(?:ample|p(?:lain|e(?:r(?:ience|t)|ct))|c(?:use|lusive|it(?:ed|ing))|uberant|ist(?:ence)?)|a(?:table|r(?:thy|n)|sy))|s(?:y(?:stem|mptomatic)|w(?:eater|i(?:ft|ng|m))|queeze|o(?:r(?:did|t)|ng|ft|phisticated|othe|da)|m(?:ile|oggy|all|elly?)|t(?:a(?:re?|in|nding|ge)|u(?:rdy|ff)|i(?:ngy|r)|e(?:el|reotyped)|r(?:aw|ip(?:ed)?)|one)|e(?:arch|ttle|l(?:fish|ective)|cret(?:ary|ive)|nse)|c(?:en[et]|orch|a(?:r(?:ecrow|f)|ttered)|i(?:ntillating|ssors|ence)|hool|r(?:eeching|atch))|ki(?:n(?:ny)?|rt)|u(?:ffer|mmer|lky|per|ccessful|b(?:s(?:equent|tan(?:ce|tial))|tract)|r(?:round|prise)|ggest)|i(?:nk|sters|mpl(?:istic|e)|gnal|ck|lky?)|h(?:rug|o(?:ck|es|[pw])|i(?:ver|p)|e(?:ep|lf)|y)|p(?:a(?:de|r(?:k(?:le)?|e))|o(?:tty|on|nge)|ectacular|i(?:ritual|cy|ffy)|r(?:ay|out|ing)|y)|a(?:me|ssy|tisfy|il|lt|d)|l(?:eepy?|i(?:p(?:pery)?|m)|ow|ave)|n(?:o(?:tty|w)|iff))|t(?:ype|u(?:rn|b)|a(?:ngy|steful|rt|me|wdry|ll|x)|r(?:ot|amp|ee|icky?|u(?:culent|thful|st|e))|e(?:rri(?:fy|ble)|mp(?:er|orary)|lephone|nt|am|e(?:ny\-tiny|th)|st(?:ed)?)|w(?:i(?:st|g)|o)|o(?:wn|ngue|matoes|oth(?:some)?|rpid|[epy])|h(?:r(?:ead|ill)|i(?:ck|rsty|nkable)|umb|ought(?:less)?|a(?:nkful|w))|i(?:g(?:er|ht)|re(?:some|d)|[epn]))|o(?:nerous|utrageous|r(?:anges|der)|atmeal|v(?:al|e(?:rwrought|n))|dd|p(?:posite|en|timal)|b(?:ey|s(?:cene|e(?:rv(?:ation|e)|quious))|ject)|ff(?:er|ice)|ld(?:\-fashioned)?)|m(?:u(?:te|rder|ndane)|a(?:ilbox|ny|r(?:ry|velous)|ddening|l(?:icious|e)|jestic|g(?:nificent|ic(?:al)?)|t(?:ure|erial))|ysterious|o(?:ve|o[nr]|tionless)|i(?:ce|ghty|tten|st|xed|n(?:dless|ute|or|iature|e)|l(?:ky|itary))|e(?:dical|nd?|e(?:ting|k)|tal|mory|r(?:ciful|e)|a(?:ty?|sure)|ssy?))|l(?:e(?:gs|a(?:ther|n)|tt(?:uce|ers?))|u(?:xuriant|m(?:py|ber)|sh|nch|dicrous)|a(?:te|bore[dr]|ck(?:adaisical|ing)|mp|n(?:guid|d)|vish|ugh(?:able)?)|i(?:quid|t(?:tle|erate)|keable|ghten|v(?:ing|e)|[ep])|o(?:w(?:ly)?|ose|ng\-term|cket|ve|af))|b(?:r(?:o(?:ther|wn|ken)|eath|i(?:ght|dge)|ass)|e(?:am|g(?:inner)?|neficial|rserk|tter|ll)|u(?:tton|mpy|ilding|stling|r(?:st|ly|y))|l(?:ood|ade|ue|in[dk]|e(?:ss|ach))|a(?:d(?:ge)?|th|wdy|b(?:ies|y)|lance|it|ck|re|s(?:in|e))|i(?:zarre|t(?:ter)?|llowy|r(?:th(?:day)?|ds?)|g)|o(?:undary|r(?:der|e)|ard))|c(?:ircle|e(?:llar|metery|aseless)|u(?:mbersome|rv(?:ed?|y)|b)|l(?:osed?|ever|ip|a(?:ss|p)|u(?:ttered|b))|h(?:e(?:ese|ss|mical)|a(?:n(?:geable|nel)|llenge)|u(?:bby|nky)|i(?:cken|valrous|ef|l(?:d(?:ren|like)|ly)|n))|r(?:uel|i(?:me|b)|o(?:wded|ok(?:ed)?)|a(?:cker|sh|ven|wl|te)|ea(?:tor|m))|a(?:ble|nnon|gey|utious|r(?:e(?:ful|less)|ry|penter|ve|ing)?|kes?|l(?:endar|culator)|mp|p(?:ricious|able)|ttle)|o(?:il|m(?:fortable|m(?:on|and)|p(?:arison|lex|ete)|b)|n(?:fuse|t(?:rol|ain)|nection)|rn|al|wardly|o(?:rdinated|ing|k)|l(?:o(?:ssal|ur)|d)))|a(?:irport|xiomatic|v(?:oid|ailable)|c(?:hiever|id(?:ic)?|c(?:idental|eptable|urate)|t)|m(?:ount|azing|usement)|pp(?:r(?:eciate|ov(?:al|e))|liance|arel)|d(?:aptable|justment|orable|v(?:ertisement|ise))|wa(?:re|ke)|l(?:oof|coholic|l(?:ow|uring|eged)|ive)|n(?:xious|swer|imal)|fter(?:math|noon)|g(?:gressive|ree(?:ment)?)|r(?:ithmetic|gu(?:ment|e)|ch|r(?:ogant|ive))|s(?:piring|tonishing|hamed|k)|u(?:tomatic|nt)|tt(?:ac[kh]|e(?:nd|mpt))|b(?:iding|errant|l(?:aze|e)|aft|o(?:rtive|unding|ard)|s(?:tracted|orb(?:ing|ed))|rasive))|d(?:ynamic|r(?:own|u(?:nk|m)|a(?:wer|g)|ea(?:ry|m)|ink)|o(?:ll|ub(?:le|tful)|c(?:tor|k)|g)|i(?:vergent|ff(?:erent|icult)|ligent|s(?:c(?:reet|overy)|t(?:ribution|urbed)|like|gusted|a(?:gree|pp(?:ear|rove))))|a(?:ffy|ily|nce|mp|r[ke]|pper|zzling|ughter|d)|usty?|e(?:gree|vilish|b(?:onair|t)|li(?:ght|cate)|ranged|c(?:ision|eive|or(?:ate|ous))|a[dr]|ep|t(?:ermined|ail)|f(?:e(?:ctive|ated)|iant)|s(?:erve|troy|ire)))|f(?:e(?:eling|stive|igned|ar|rtile|male)|u(?:el|mbling|rry|turistic|ll)|i(?:xed|lthy|e(?:ld|rce)|n(?:ger|icky)|reman)|r(?:a(?:me|ntic)|uit|ightened|ogs|e(?:sh|e))|o(?:amy|und|o[dl]|r(?:getful|tunate))|l(?:o(?:o[rd]|ck|w)|u(?:ffy|ttering)|a(?:g(?:rant)?|ky|t))|a(?:ncy|st|i(?:nt|ries|thful)|r(?:\-flung)?|l(?:l(?:acious)?|se)))|h(?:y(?:pnotic|sterical)|u(?:m(?:drum)?|sky|g)|e(?:a(?:lth|venly)|l(?:pful|lish))|i(?:story|l(?:arious|l)|gh)|o(?:ok|uses|rse|me(?:l(?:ess|y))?|s(?:pital|e)|p)|a(?:nging|bitual|te?|unt|l(?:lowed|f)|ircut|r(?:mon(?:ious|y)|d(?:\-to\-find)?)))))\1"
tx_pattern = r"(?:n(?:e(?:c(?:essary|k)|ed|xt|ighborly)|o(?:tebook|ndescript|rmal|is[ey])|a(?:ppy|me|useating|t(?:ion|ural))|i(?:fty|ne|ce|ppy)|u(?:mber(?:less)?|t))|k(?:ey|i(?:ck|nd|ll)|no(?:ck|t))|z(?:oo|any|i(?:nc|p)|ephyr)|v(?:o(?:ice|latile)|e(?:in|rsed?)|ulgar|a(?:nish|cuous|se)|iolet)|y(?:oung|a(?:rd|k)|ummy)|g(?:a(?:ze|rrulous)|e(?:ese|ntle)|l(?:ass|eaming|ue)|iant|o(?:od|ld|vernment)|u(?:itar|llible|ar(?:antee|ded)|sty)|host|r(?:ieving|ubby|e(?:en|a(?:sy|t))|o(?:u(?:chy|nd)|an|ovy)|a(?:ndfather|pe|ceful|t(?:is|e)|b)))|j(?:u(?:m(?:bled|p)|icy)|e(?:wel|lly)|a(?:il|zzy)|o(?:yous|lly|g))|u(?:mbrella|gliest|tter|sed?|n(?:becoming|ruly|fasten|kempt|used|wieldy|derstood|pack|a(?:ccountable|ble)|i(?:que|nterested|t)|equaled|s(?:ightly|uitable)|cle)|p)|i(?:tchy|cy|gnore|m(?:mense|p(?:erfect|o(?:rtant|lite|ssible)))|ll(?:\-informed|ustrious)|n(?:ject|v(?:incible|ention)|c(?:re(?:ase|dible)|ompetent)|nate|t(?:roduce|e(?:lligent|rest(?:ing)?))|sidious))|r(?:i(?:nse|ght|fle|ver)|u(?:ral|thless|le|d(?:dy|e)|in|b)|o(?:mantic|ugh|ll|bust|yal|[dt])|e(?:t(?:urn|ire)|bel|gret|m(?:iniscent|ember)|l(?:igion|a(?:tion|x)|ease)|flect|quest|s(?:ponsible|cue)|ward|a(?:dy|ction|son)|p(?:resentative|eat|ly)|co(?:ndite|rd)|dundant)|a(?:ce|mpant|i(?:se|lway)|diate|t(?:ty)?|spy|b(?:bits?|id)))|w(?:i(?:cked|ggly|de\-eyed|n(?:d(?:ow|y)|e)|l(?:ling|derness))|h(?:ole|i(?:ne|sper(?:ing)?|te|p))|a(?:ll|ve|r(?:like|[nm])?|iting|n(?:t(?:ing)?|der)|keful)|r(?:ist|ong|en(?:ch)?|y)|e(?:ll\-(?:groomed|made)|a(?:lth|k))|o(?:nderful|m(?:en|an)|ozy|bble|r(?:k(?:able)?|thless|r(?:ied|y)|d)))|qu(?:ack|estion|i(?:nce|ckest|ver|et|l[tl]))|p(?:h(?:obic|ysical)|r(?:ick|ay|e(?:ach|cious|vent|tend)|o(?:mise|bable|tective|fit|duce|perty|ud|gram|vide))|e(?:ck|ncil|r(?:iodic|son|mi(?:ssible|t)|form)|ace(?:ful)?|t)|u(?:rple|blic|zzling|ll|n(?:cture|ishment))|l(?:eas(?:ure|ant)|ough|a(?:in|stic|n(?:es?|t(?:ation)?)?|ce|usible|y))|a(?:use|ddle|r(?:ched|t(?:ner)?)|instaking|le|s(?:te|s)|n(?:cake)?|t)|o(?:w(?:er|der)|cket|ke|tato|ison|li(?:sh|t(?:ical|e))|s(?:s(?:essive|ible)|t))|i(?:zzas|quant|ck(?:le)?|pe|[ne]))|e(?:quable|scape|gg(?:nog)?|r(?:ror|ect)|vent|n(?:ormous|ergetic|d(?:urable)?|joy|courag(?:ing|e)|ter(?:taining)?)|fficacious|d(?:ge|ucat(?:ion|ed?))|yes|m(?:barrass|p(?:loy|ty))|l(?:bow|a(?:ted|stic)|e(?:gant|ctric))|x(?:ample|p(?:lain|e(?:r(?:ience|t)|ct))|c(?:use|lusive|it(?:ed|ing))|uberant|ist(?:ence)?)|a(?:table|r(?:thy|n)|sy))|s(?:y(?:stem|mptomatic)|w(?:eater|i(?:ft|ng|m))|queeze|o(?:r(?:did|t)|ng|ft|phisticated|othe|da)|m(?:ile|oggy|all|elly?)|t(?:a(?:re?|in|nding|ge)|u(?:rdy|ff)|i(?:ngy|r)|e(?:el|reotyped)|r(?:aw|ip(?:ed)?)|one)|e(?:arch|ttle|l(?:fish|ective)|cret(?:ary|ive)|nse)|c(?:en[et]|orch|a(?:r(?:ecrow|f)|ttered)|i(?:ntillating|ssors|ence)|hool|r(?:eeching|atch))|ki(?:n(?:ny)?|rt)|u(?:ffer|mmer|lky|per|ccessful|b(?:s(?:equent|tan(?:ce|tial))|tract)|r(?:round|prise)|ggest)|i(?:nk|sters|mpl(?:istic|e)|gnal|ck|lky?)|h(?:rug|o(?:ck|es|[pw])|i(?:ver|p)|e(?:ep|lf)|y)|p(?:a(?:de|r(?:k(?:le)?|e))|o(?:tty|on|nge)|ectacular|i(?:ritual|cy|ffy)|r(?:ay|out|ing)|y)|a(?:me|ssy|tisfy|il|lt|d)|l(?:eepy?|i(?:p(?:pery)?|m)|ow|ave)|n(?:o(?:tty|w)|iff))|t(?:ype|u(?:rn|b)|a(?:ngy|steful|rt|me|wdry|ll|x)|r(?:ot|amp|ee|icky?|u(?:culent|thful|st|e))|e(?:rri(?:fy|ble)|mp(?:er|orary)|lephone|nt|am|e(?:ny\-tiny|th)|st(?:ed)?)|w(?:i(?:st|g)|o)|o(?:wn|ngue|matoes|oth(?:some)?|rpid|[epy])|h(?:r(?:ead|ill)|i(?:ck|rsty|nkable)|umb|ought(?:less)?|a(?:nkful|w))|i(?:g(?:er|ht)|re(?:some|d)|[epn]))|o(?:nerous|utrageous|r(?:anges|der)|atmeal|v(?:al|e(?:rwrought|n))|dd|p(?:posite|en|timal)|b(?:ey|s(?:cene|e(?:rv(?:ation|e)|quious))|ject)|ff(?:er|ice)|ld(?:\-fashioned)?)|m(?:u(?:te|rder|ndane)|a(?:ilbox|ny|r(?:ry|velous)|ddening|l(?:icious|e)|jestic|g(?:nificent|ic(?:al)?)|t(?:ure|erial))|ysterious|o(?:ve|o[nr]|tionless)|i(?:ce|ghty|tten|st|xed|n(?:dless|ute|or|iature|e)|l(?:ky|itary))|e(?:dical|nd?|e(?:ting|k)|tal|mory|r(?:ciful|e)|a(?:ty?|sure)|ssy?))|l(?:e(?:gs|a(?:ther|n)|tt(?:uce|ers?))|u(?:xuriant|m(?:py|ber)|sh|nch|dicrous)|a(?:te|bore[dr]|ck(?:adaisical|ing)|mp|n(?:guid|d)|vish|ugh(?:able)?)|i(?:quid|t(?:tle|erate)|keable|ghten|v(?:ing|e)|[ep])|o(?:w(?:ly)?|ose|ng\-term|cket|ve|af))|b(?:r(?:o(?:ther|wn|ken)|eath|i(?:ght|dge)|ass)|e(?:am|g(?:inner)?|neficial|rserk|tter|ll)|u(?:tton|mpy|ilding|stling|r(?:st|ly|y))|l(?:ood|ade|ue|in[dk]|e(?:ss|ach))|a(?:d(?:ge)?|th|wdy|b(?:ies|y)|lance|it|ck|re|s(?:in|e))|i(?:zarre|t(?:ter)?|llowy|r(?:th(?:day)?|ds?)|g)|o(?:undary|r(?:der|e)|ard))|c(?:ircle|e(?:llar|metery|aseless)|u(?:mbersome|rv(?:ed?|y)|b)|l(?:osed?|ever|ip|a(?:ss|p)|u(?:ttered|b))|h(?:e(?:ese|ss|mical)|a(?:n(?:geable|nel)|llenge)|u(?:bby|nky)|i(?:cken|valrous|ef|l(?:d(?:ren|like)|ly)|n))|r(?:uel|i(?:me|b)|o(?:wded|ok(?:ed)?)|a(?:cker|sh|ven|wl|te)|ea(?:tor|m))|a(?:ble|nnon|gey|utious|r(?:e(?:ful|less)|ry|penter|ve|ing)?|kes?|l(?:endar|culator)|mp|p(?:ricious|able)|ttle)|o(?:il|m(?:fortable|m(?:on|and)|p(?:arison|lex|ete)|b)|n(?:fuse|t(?:rol|ain)|nection)|rn|al|wardly|o(?:rdinated|ing|k)|l(?:o(?:ssal|ur)|d)))|a(?:irport|xiomatic|v(?:oid|ailable)|c(?:hiever|id(?:ic)?|c(?:idental|eptable|urate)|t)|m(?:ount|azing|usement)|pp(?:r(?:eciate|ov(?:al|e))|liance|arel)|d(?:aptable|justment|orable|v(?:ertisement|ise))|wa(?:re|ke)|l(?:oof|coholic|l(?:ow|uring|eged)|ive)|n(?:xious|swer|imal)|fter(?:math|noon)|g(?:gressive|ree(?:ment)?)|r(?:ithmetic|gu(?:ment|e)|ch|r(?:ogant|ive))|s(?:piring|tonishing|hamed|k)|u(?:tomatic|nt)|tt(?:ac[kh]|e(?:nd|mpt))|b(?:iding|errant|l(?:aze|e)|aft|o(?:rtive|unding|ard)|s(?:tracted|orb(?:ing|ed))|rasive))|d(?:ynamic|r(?:own|u(?:nk|m)|a(?:wer|g)|ea(?:ry|m)|ink)|o(?:ll|ub(?:le|tful)|c(?:tor|k)|g)|i(?:vergent|ff(?:erent|icult)|ligent|s(?:c(?:reet|overy)|t(?:ribution|urbed)|like|gusted|a(?:gree|pp(?:ear|rove))))|a(?:ffy|ily|nce|mp|r[ke]|pper|zzling|ughter|d)|usty?|e(?:gree|vilish|b(?:onair|t)|li(?:ght|cate)|ranged|c(?:ision|eive|or(?:ate|ous))|a[dr]|ep|t(?:ermined|ail)|f(?:e(?:ctive|ated)|iant)|s(?:erve|troy|ire)))|f(?:e(?:eling|stive|igned|ar|rtile|male)|u(?:el|mbling|rry|turistic|ll)|i(?:xed|lthy|e(?:ld|rce)|n(?:ger|icky)|reman)|r(?:a(?:me|ntic)|uit|ightened|ogs|e(?:sh|e))|o(?:amy|und|o[dl]|r(?:getful|tunate))|l(?:o(?:o[rd]|ck|w)|u(?:ffy|ttering)|a(?:g(?:rant)?|ky|t))|a(?:ncy|st|i(?:nt|ries|thful)|r(?:\-flung)?|l(?:l(?:acious)?|se)))|h(?:y(?:pnotic|sterical)|u(?:m(?:drum)?|sky|g)|e(?:a(?:lth|venly)|l(?:pful|lish))|i(?:story|l(?:arious|l)|gh)|o(?:ok|uses|rse|me(?:l(?:ess|y))?|s(?:pital|e)|p)|a(?:nging|bitual|te?|unt|l(?:lowed|f)|ircut|r(?:mon(?:ious|y)|d(?:\-to\-find)?))))"
words = []
with open("data.csv") as infile:
words.extend(set(infile.read().split()))
def setup(length):
sentences = []
for _ in range(length):
noise = ["".join(random.sample(ascii_lowercase, k=10)) for _ in range(30)]
sub = random.sample(words, k=30)
sentence = noise + sub
random.shuffle(sentence)
sentences.append(" ".join(sentence))
return sentences
def trrex(sentences):
result = [re.findall(tx_pattern, sentence) for sentence in sentences]
return result
def atomic(sentences):
result = [re.findall(pattern, sentence) for sentence in sentences]
return result
def equality(a, b):
return a == b
if __name__ == "__main__":
out = perfplot.bench(
setup=setup,
n_range=[length for length in range(100, 2000, 100)],
kernels=[trrex, atomic],
labels=["baseline", "atomic"],
xlabel="len(data)",
equality_check=equality,
)
out.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment