News for hackers. Stuff that matters.
Re:Knuth and the Unix Way by telemachos on Thursday December 08, 2011 @01:16PM (#3330308)
I know that this really isn't the point, but this is bugging me: McIlroy's pipeline doesn't properly handle words like don't or home-spun.[1]

My first thought for a fix (still split on spaces, but now we need to remove left-over punctuation):

    tr -s '[:space:]' '\n' | tr -d '",.!?' | etc.
I doubt the tr of that time had the character classes, but it gets at the general idea. I'm sure there are better alternatives, and I would be happy to hear them.

Oh, and also, we would need to remove single-quotes that might be left-over too, but only if they are at word boundaries, rather than within words. I'm going back to work now...

[1] https://gist.github.com/1447872

Re:Knuth and the Unix Way by oconnor0 on Thursday December 08, 2011 @01:30PM (#3330383)
Does Knuth's version handle those words? Since that would discredit the article's claim that McIlroy's version was bug-free.
Re:Knuth and the Unix Way by jhck on Thursday December 08, 2011 @03:32PM (#3330992)
No, Knuth's version doesn't handle those words either. Here's how he defines a word in his literate program:

Let's agree that a word is a sequence of one or more contiguous letters; "Bentley" is a word, but "ain't" isn't. The sequence of letters should be maximal, in the sense that it cannot be lengthened without including a nonletter.

Re:Knuth and the Unix Way by tjr on Thursday December 08, 2011 @02:24PM (#3330668)
Whether if it does or doesn't, it probably includes an explanation as to why it does or doesn't, perhaps with references to articles going into more detail on the virtues of each possibility.
Re:Knuth and the Unix Way by qdog on Thursday December 08, 2011 @02:14PM (#3330613)
Although the consensus seems to be contractions count as one word, some people still believe they should count as two.

I suppose then the problem would be counting "can't" as a "can" and a "not".

Bug-free seems a bit of a strong claim either way, good catch ;)

Re:Knuth and the Unix Way by telemachos on Thursday December 08, 2011 @01:36PM (#3330423)
I don't know (I haven't seen the full original articles.) One of the McIlroy quotes mentions "handling of punctuation" and "isolation of words", so clearly they were thinking of some of these edge cases.

> In particular the isolation of words, the handling of punctuation, and the treatment of case distinctions are built in.