Inglese golf - usando le contrazioni


9

Non ho riso tanto dal contenuto di Stack Exchange quanto da questo . Penso che tutti apprezzerete questa sfida, poiché è ispirato da ciò che è laggiù.

Scriverai una funzione o un programma che è code-golf, cioè dovrebbe essere il più breve possibile.

Dato un testo, restituisci (entrambi con qualsiasi mezzo) il testo in cui avrai contratto quante più parole possibili secondo questa tabella .

Non devi estrarre informazioni dalla tabella, ma devi avere tutte le informazioni necessarie incluse nel tuo codice.

Tutte le regole di default non dovrebbero essere infrante in quanto non avremo alcuna concorrenza sleale.

Non è necessario considerare il testo se non è scritto in maiuscolo come nella tabella, quindi non è necessario convertirlo you all WOULD not haveo You all would not havein y'all'dn't've.

Puoi abbinare solo il buon vecchio apostrofo (U + 0027) o qualsiasi altro carino ; qualunque cosa tu voglia.

Esempio di input sopra ↑ e output corrispondente sotto ↓

Non ho riso tanto dal contenuto di StackExchange come da questo . Penso che vi godrete questa sfida, perché è ispirato da ciò che è laggiù.

Scriverai una funzione o un programma che è code-golf, cioè dovrebbe essere il più breve possibile.

Dato un testo, restituisci (entrambi con ogni mezzo) il testo in cui avrai contratto quante più parole possibili secondo questa tabella .

Non devi estrarre informazioni dalla tabella, piuttosto devi avere tutte le informazioni necessarie incluse nel tuo codice.

Tutte le regole predefinite non dovrebbero essere infrante in quanto non avremo alcuna concorrenza sleale.

Non è necessario considerare il testo se non è in maiuscolo come nella tabella, quindi non è necessario convertirlo you all WOULD not haveo You all would not havein y'all'dn't've.

Puoi abbinare solo il buon vecchio apostrofo (U + 0027) o qualsiasi altro carino ; qualunque cosa tu voglia.


Il tuo esempio è sbagliato, giusto?
A Simmons,

@ N ^ BZ sì, è quello!
A Simmons,

Risposte:


4

Perl, 3429 1095 byte

Compresso il testo.

versione codificata dello script

@a=split('!',uncompress(<DATA>.<DATA>));while(<>){chomp;$l=$_;for$d(@a){chomp $d;($x,$y)=split(/,/,$d);if($l=~m/$y/){$l=~s/$y/$x/g}}print "$l\n"}
__DATA__
x<9c>uVK<b2><a3>0^L<dc><e7>^Tdņ<8b>p^Lϋ'<b8>^FpUL<e2><e2><f6><a3><af>-<9b><bc>^Mv<b7>d<a9>%<c4><c7>m<fb>xLn^[<f6>x<dc><ee><ee><e5>      <be><<e3>^_<87>^P<ae>^B<e3>{}<8c>^_?<d1>fX<dc><c7>^K    n<95>^G<df><ce>V^M<b7><fb>#^P^C<8b><e0><e8>^S^Q<b0>*Ø<d1>3<9e>1<ec><cf>ሷ<fb><e2>4^[<ec>L.<e6><95>D<9c>^X'<c5>^_<cf><c4>G<aa>[<fc><f8><98>^V^O<e7>^_^L(<a8>^_<b2><a9>N}<88>#<b8><ae><88><d3><e2><d6><d5><e0>^\^DrR^L<9a>J<96>$D<e3>^P:{@s̘.<e6>^A<da>c<a1><a6>^G^B<f3>!<c3>      <81>H<84>9|<81><a1>A<d8><db><db>}<86>`3W;s<b1>sS+<db>%Ռ<89>f<ad>S^P'<9d><c7>^M<f6>n<c3>^]<f7>t^^jWg^N<cc>!^CU<ab><a5><86>^C2<84><83>% @W<c0>V<84><fa><88>^L<80><90>^Y<b0>^H)<98><a5>^@<e4>^LGm8rB4^N<aa>b<f5><e8>^@<d7><e1>^M^N<9b>^[<dd>6m<ee><81><f5>l<e1><b9>^\2]<b4>7<f3><a5><b6>j^P<ae>:<8b><e3>;<b1>^_<ac><e2>^F;<f2>B<86><9d>v<ef>i\qe<a7>8<fe><ac><f1><e7><df>^T<ff>^N^G<8c>^C^A`<d7>q<8a>؈<f8><96><f4><b4><e1>#<d0>^Sd<a8>5<ca><e0><bc>&^]<ea><a4>S<9d><ba><b1><ae>~<d2><e7>ē<9c><ea>h^[<86>{<9d>tx<93>^]ob<95><ea><9c><c2><c5>'<90><8b><be>FxW$<99>^W<89>Xj<f7><8b>՘<80><8d><9b><ff>^S^_'<d6>"[)<bc>^X(<9a>ښ^V|9<ab><cd>(&<95><d3>^F0<b2><d4>^S;<a5>N<da><c0>o6i<a5><9a><92>՝<be>^[<82><f0>q<f7><a2>^Uv<b5>L<a2>U$Z<fa>"<db>s<a6>D4<88>6<b4><18><a5><8a>FC2^Z<d2>7Z^E^_^K<bc><b3>%5<ed><ab>h1<a9>l<b6><f6>¯<e7><8d>x6<8a>H<b6><9a>^B<be>Xk^QlL<8d><ae><f4><9b>        <8b>9^VG<af>^]\%^NQ<89>^Y:m     ><e3>_<d8>wZ<b9>p<a1><b0>hfmm<bf>^T<ca><e4>K<fd>Ử\*<81>SOI▒%w^]g<a2><fb>Q.^^<9d>Y-<dd>A{<c8><f0>ƻ^KU<bf>^P<e4>A<ed><f4><e5>a^Q<ae>^Q^X<f8><ad>fS<ad>k^S^X=~<89><ab><b7> <a8><97>^D<d4><f6><9d>6Fw\<93>s<ce><f1>^H<89>?^]<b8>ώ@Ɩg<87>^?%p=<e8><a7>$<f3><cf>Fַb<c6>[<99><e5><be>#<90>²<bf><f4>=<cb>H<e4>v^^4<82>t5<fb>ڝ<ec><fb>ސUy<82>/r<a3><8a>^A<f1>!<f5><e5><9f><\E<ac><8c>7<ae>z?^ZN<a2>"<85>q<91><e2><c8><<f3><b9><^D<96>^H^]<e6>^?^Pb>^ϐ<a0>^E<f4><a0><93><df>5J%8?^Z<b4><f2><9f>Q<96><89><cf><f5>!h<a9>pa4?r$<80>O<b2><82>H<e1><a3><dc>/<84><ec>^S<db>{R<fc><f4><ae>^@AM<8a><b5>o<85>ѮEnZԞE<92>^TU<b5><c2> H<f2>jƓÝ%<dc><c9><e1>N^Mw<d2><f9>S<c3>)<a4>pQ'<a6>^[^W<fa><c1>V^R<b1>|<90><9b>b<cd><e7><f8>2<b3><fa>16o<89>s<84>^FLg|^O<d4>^H<82>e^L<bf>x]]<ac><99>^F<bf>ڋl<b5>6<a7><f5><95>И/<e7><eb>S<af>^<8d>^]<e8><f8><86>[<8d>^\<8d>^DA<cd><d3>(,~2^RHH4^Y      <c3><d4><d8>/<91><fc><f2><8a><8b>F},<91><ae>ҍb<e2>^K    <ff><92><91>z\<ba><fa>^_<bf><fc><b5><8f>

perl -MCompress::Zlib script.pl <sample.txt
You will write a function or program that's code-golf, i.e. it'd've to be as short as you can make it.
Given a text, return (both by any means) the text where you'll have contracted as many words as possible according this table.
You shan't pull information from the table, rather you must've all necessary information included in your code.
All default rules oughtn't to be broken as we'lln't've any unfair competition.
You needn't consider text if 'tisn't capitalized as in the table, so you mustn't convert y'all WOULD not've or You all wouldn't've to y'all'dn't've.
You may match just the good ol' apostrophe (U+0027) or any nice ones; whatever you wanna.

Immagino che tu possa usare perl -p0 s1-golfed.plper sbarazzarti del loop while avvolto:$/="\n";for$d(<DATA>){($x)=$d=~/(.*),(.*)\b/;s/$2/$x/g}
andlrc

E rimuovi la necessità di $x:for$d(<DATA>){$d=~s~(.*),(.*)\b~"s/$2/$1/g"~eeg}
andlrc
Utilizzando il nostro sito, riconosci di aver letto e compreso le nostre Informativa sui cookie e Informativa sulla privacy.
Licensed under cc by-sa 3.0 with attribution required.