XXXX redacted: Difference between revisions
Content deleted Content added
Thundergnat (talk | contribs) m Remove stray apostrophe |
|||
Line 182:
[p|i|o] XXX? XXXX XXXXXX XXXXXX is in his XXXXXXX while playing XXX "XXXXXXX" brand XXXXXXXX. XXXXXX so XXX.
XXXX very XXXXXX, XXXXX you XXXXX?
</pre>
=={{header|Phix}}==
Written on the assumption that overkill implies partial (see talk page).
<lang Phix>enum WHOLE,PARTIAL,OVERKILL,INSENSITIVE
constant spunc = " \r\n\t.?\"" -- spaces and punctuation
function redact(string text, word, integer options)
sequence t_utf32 = utf8_to_utf32(text),
l_utf32 = t_utf32,
w_utf32 = utf8_to_utf32(word)
string opt = "[?|s]"
if options>INSENSITIVE then
options -= INSENSITIVE
opt[4] = 'i'
l_utf32 = lower(t_utf32)
w_utf32 = lower(w_utf32)
end if
opt[2] = "wpo"[options]
integer idx = 1
while true do
idx = match(w_utf32,l_utf32,idx)
if idx=0 then exit end if
integer edx = idx+length(w_utf32)-1
if options=WHOLE then
if (idx=1 or find(l_utf32[idx-1],spunc))
and (edx=length(l_utf32) or find(l_utf32[edx+1],spunc)) then
t_utf32[idx..edx] = 'X'
end if
elsif options=PARTIAL
or options=OVERKILL then
if options=OVERKILL then
while idx>1 and not find(l_utf32[idx-1],spunc) do idx -= 1 end while
while edx<length(l_utf32) and not find(l_utf32[edx+1],spunc) do edx += 1 end while
end if
t_utf32[idx..edx] = 'X'
end if
idx = edx+1
end while
--hmmm...
text = iff(string(t_utf32)?t_utf32:utf32_to_utf8(t_utf32))
return {opt,text}
end function
constant test = `
Tom? Toms bottom tomato is in his stomach while playing the "Tom-tom" brand tom-toms. That's so tom.
'Tis very tomish, don't you think?`,
tests = {"Tom","tom","t"}
for t=1 to length(tests) do
printf(1,"Redact %s:\n",{tests[t]})
for o=WHOLE to OVERKILL do
printf(1,"%s:%s\n",redact(test,tests[t],o))
printf(1,"%s:%s\n",redact(test,tests[t],o+INSENSITIVE))
end for
end for
constant ut = "🧑 👨 🧔 👨👩👦",
fmt = """
%s
Redact 👨 %s %s
Redact 👨👩👦 %s %s
"""
printf(1,fmt,{ut}&redact(ut,"👨",WHOLE)&redact(ut,"👨👩👦",WHOLE))</lang>
{{out}}
If you scroll down you'll see the windows console makes a complete mockery of those unicode characters (it should work unaltered on linux...) and it has replaced those right-hand combined characters with five X, but hey, at least it compiled cleanly and didn't crash!
<pre style="height:40ex;overflow:scroll;">
Redact Tom:
[w|s]:XXX? Toms bottom tomato is in his stomach while playing the "Tom-tom" brand tom-toms. That's so tom.
'Tis very tomish, don't you think?
[w|i]:XXX? Toms bottom tomato is in his stomach while playing the "Tom-tom" brand tom-toms. That's so XXX.
'Tis very tomish, don't you think?
[p|s]:XXX? XXXs bottom tomato is in his stomach while playing the "XXX-tom" brand tom-toms. That's so tom.
'Tis very tomish, don't you think?
[p|i]:XXX? XXXs botXXX XXXato is in his sXXXach while playing the "XXX-XXX" brand XXX-XXXs. That's so XXX.
'Tis very XXXish, don't you think?
[o|s]:XXX? XXXX bottom tomato is in his stomach while playing the "XXXXXXX" brand tom-toms. That's so tom.
'Tis very tomish, don't you think?
[o|i]:XXX? XXXX XXXXXX XXXXXX is in his XXXXXXX while playing the "XXXXXXX" brand XXXXXXXX. That's so XXX.
'Tis very XXXXXXX don't you think?
Redact tom:
[w|s]:Tom? Toms bottom tomato is in his stomach while playing the "Tom-tom" brand tom-toms. That's so XXX.
'Tis very tomish, don't you think?
[w|i]:XXX? Toms bottom tomato is in his stomach while playing the "Tom-tom" brand tom-toms. That's so XXX.
'Tis very tomish, don't you think?
[p|s]:Tom? Toms botXXX XXXato is in his sXXXach while playing the "Tom-XXX" brand XXX-XXXs. That's so XXX.
'Tis very XXXish, don't you think?
[p|i]:XXX? XXXs botXXX XXXato is in his sXXXach while playing the "XXX-XXX" brand XXX-XXXs. That's so XXX.
'Tis very XXXish, don't you think?
[o|s]:Tom? Toms XXXXXX XXXXXX is in his XXXXXXX while playing the "XXXXXXX" brand XXXXXXXX. That's so XXX.
'Tis very XXXXXXX don't you think?
[o|i]:XXX? XXXX XXXXXX XXXXXX is in his XXXXXXX while playing the "XXXXXXX" brand XXXXXXXX. That's so XXX.
'Tis very XXXXXXX don't you think?
Redact t:
[w|s]:Tom? Toms bottom tomato is in his stomach while playing the "Tom-tom" brand tom-toms. That's so tom.
'Tis very tomish, don't you think?
[w|i]:Tom? Toms bottom tomato is in his stomach while playing the "Tom-tom" brand tom-toms. That's so tom.
'Tis very tomish, don't you think?
[p|s]:Tom? Toms boXXom XomaXo is in his sXomach while playing Xhe "Tom-Xom" brand Xom-Xoms. ThaX's so Xom.
'Tis very Xomish, don'X you Xhink?
[p|i]:Xom? Xoms boXXom XomaXo is in his sXomach while playing Xhe "Xom-Xom" brand Xom-Xoms. XhaX's so Xom.
'Xis very Xomish, don'X you Xhink?
[o|s]:Tom? Toms XXXXXX XXXXXX is in his XXXXXXX while playing XXX "XXXXXXX" brand XXXXXXXX. XXXXXX so XXX.
'Tis very XXXXXXX XXXXX you XXXXX?
[o|i]:XXX? XXXX XXXXXX XXXXXX is in his XXXXXXX while playing XXX "XXXXXXX" brand XXXXXXXX. XXXXXX so XXX.
XXXX very XXXXXXX XXXXX you XXXXX?
ƒºæ ƒæ¿ ƒºö ƒæ¿ÔÇìƒæ®ÔÇìƒæª
Redact ƒæ¿ [w|s] ƒºæ X ƒºö ƒæ¿ÔÇìƒæ®ÔÇìƒæª
Redact ƒæ¿ÔÇìƒæ®ÔÇìƒæª [w|s] ƒºæ ƒæ¿ ƒºö XXXXX
</pre>
|