12

I get a Body cannot contain "" error when trying to post this question on SE, but know not how to resolve it.

What is the best way to unpack SequenceMatcher loop results in Python so that values can be easily accessed and processed?

from difflib import *

orig =
"陳仲舉言為士則,行為世範,登車攬轡,有澄清天下之志。為豫章太守,至,便問徐孺子所在,欲先看之。主簿白:「群情欲府君先入廨。」陳曰:「武王式商容之閭,席不暇煖。吾之禮賢,有何不可!」"

commented =
"陳仲舉言為士則,行為世範,登車攬轡,有澄清天下之志。汝南先賢傳曰:「陳蕃字仲舉,汝南平輿人。有室,荒蕪不埽除,曰:『大丈夫當為國家埽天下。』值漢桓之末,閹豎用事,外戚豪橫。及拜太傅,與大將軍竇武謀誅宦官,反為所害。」為豫章太守,海內先賢傳曰:「蕃為尚書,以忠正忤貴戚,不得在臺,遷豫章太守。」至,便問徐孺子所在,欲先看之。謝承後漢書曰:「徐稚字孺子,豫章南昌人。清妙高跱,超世絕俗。前後為諸公所闢,雖不就,及其死,萬里赴吊。常豫炙雞一隻,以綿漬酒中,暴乾以裹雞,徑到所赴塚隧外,以水漬綿,斗米飯,白茅為藉,以雞置前。酹酒畢,留謁即去,不見喪主。」主簿白:「群情欲府君先入廨。」陳曰:「武王式商容之閭,席不暇煗。許叔重曰:「商容,殷之賢人,老子師也。」車上跽曰式。吾之禮賢,有何不可!」袁宏漢紀曰:「蕃在豫章,為稚獨設一榻,去則懸之,見禮如此。」"

diff = SequenceMatcher(None, orig, commented) 

The current iteration code stores match results in a list like this:

match_id [Match(a=0, b=0, size=26), Match(a=26, b=108, size=6),
Match(a=32, b=146, size=15), Match(a=47, b=273, size=30), Match(a=78,
b=330, size=12), Match(a=90, b=372, size=0)] 

I'd eventually like to mark out the comments like so:

陳仲舉言為士則,行為世範,登車攬轡,有澄清天下之志。{{汝南先賢傳曰:「陳蕃字仲舉,汝南平輿人。有室,荒蕪不埽除,曰:『大丈夫當為國家埽天下。』值漢桓之末,閹豎用事,外戚豪橫。及拜太傅,與大將軍竇武謀誅宦官,反為所害。」}}為豫章太守,{{海內先賢傳曰:「蕃為尚書,以忠正忤貴戚,不得在臺,遷豫章太守。」}}至,便問徐孺子所在,欲先看之。{{謝承後漢書曰:「徐稚字孺子,豫章南昌人。清妙高跱,超世絕俗。前後為諸公所闢,雖不就,及其死,萬里赴吊。常豫炙雞一隻,以綿漬酒中,暴乾以裹雞,徑到所赴塚隧外,以水漬綿,斗米飯,白茅為藉,以雞置前。酹酒畢,留謁即去,不見喪主。」}}主簿白:「群情欲府君先入廨。」陳曰:「武王式商容之閭,席不暇煗。{{許叔重曰:「商容,殷之賢人,老子師也。」車上跽曰式。}}吾之禮賢,有何不可!」{{袁宏漢紀曰:「蕃在豫章,為稚獨設一榻,去則懸之,見禮如此。」}}

Which means, I am interested in unpacking the above SequenceMatcher results and do some calculations on specific b and size` values to yield this sequence:

rslt = [[0+26,108][108+6,146][146+15,273][273+30,330][330+12,372]]
  • 1
    Chinese characters are blocked on most sites due to spam. – Laurel Dec 20 '19 at 3:17
  • 6
    This is a great inconvenience for users working with CJK data. Is anyone working on fine-tuning the spam filter to allow legitimate posts containing Chinese characters? – Sati Dec 20 '19 at 5:24
11

Chinese characters are blocked in posts network-wide, with the exception of a few sites (including this one), because of persistent spam posts that use them.

The error message is intentionally kept nondescript to prevent spammers from catching on to the real cause why their posts are being blocked.

tl;dr: spammers prevent us from having nice things...

4

As a workaround you can still provide the original message, but in base64 encoding and instruct readers on how to decode it, like using Notepad++ plugin MIME tools. This will prevent the original text from being immediately visible though, so any search engine queries would fail to find it probably.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .