3 ms·
That's mail. Parsing mail is undecidable, this is known, it's an ancient format (I use that term in the loosest sense) and can only be handled on a best-effort
by samatman 2y ago
That's mail. Parsing mail is undecidable, this is known, it's an ancient
format (I use that term in the loosest sense) and can only be handled
on a best-effort basis.
That is not a property of plain text files, of the sort we see above.
The rule there is very simple: single newlines are wrapping, double
newlines are paragraph breaks. Yes, you want to put a tiny bit more
effort into it to do a good job, someone might be sloppy about
trimming tailing whitespace on empty lines and so on, it would be
silly to let your parser break on three newlines, and so on.
> Hard wrapping text loses information.
Nonsense.
Spoiler alert: I hard-wrapped every paragraph in the reply above. So that's the existence proof: no it doesn't.
- mrob 2y agoYour "existence proof" is no such thing; you simply moved the deleted information to the metadata by telling us which reconstruction algorithm to use.
- samatman 2y agoAs far as I am able to parse it, this sentence is meaningless. Hacker News, not known for the immense sophistication of its markup, is, somehow, mysteriously, able to tell the difference between one newline (still a paragraph) and more than one (new paragraph). I don't know how they do it with all the deleted metadata reconstruction algorithm undecidable problems you're sure exist. Perhaps they use an LLM, to do a better job. We may never know for sure.
- mrob 2y agohere is a free verse poem with lines of unknown length and deliberate lack of uppercase or punctuation It's plain text. "Plain text" does not impose any restrictions on formatting. Was the poem two lines or three? Hard wrapping plain text loses information because it inserts non-semantic line breaks using the same character as already used for semantic line breaks. There is no way reliable way to distinguish the two, so the transformation is not reversible in the general case. The best you can do is guess from context, which, as the poem demonstrates, is not always possible.