"James while John had had had had had had had had had had had a better effect on the teacher" is an English sentence used to demonstrate lexical ambiguity and the necessity of punctuation, which serves as a substitute for the intonation, stress, and pauses found in speech. In human information processing research, the sentence has been used to show how readers depend on punctuation to give sentences meaning, especially in the context of scanning across lines of text. The sentence is sometimes presented as a puzzle, where the solver must add the punctuation.
The example refers to two students, James and John, who are required by an English test to describe a man who, in the past, had suffered from a cold. John writes "The man had a cold," which the teacher marks as being incorrect, while James writes the correct "The man had had a cold." Since James' answer was right, it had had a better effect on the teacher.
The sentence can be understood more clearly by adding punctuation and emphasis:
James, while John had had "had", had had "had had"; "had had" had had a better effect on the teacher.
In each of the five "had had" word pairs in the above sentence, the first of the pair is in the past perfect form. The italicized instances denote emphasis of intonation, focusing on the differences in the students' answers, then finally identifying the correct one.
James while John had had had had had had had had had had had a better effect on the teacher Wikipedia
The sentence can be given as a grammatical puzzle or an item on a test, for which one must find the proper punctuation to give it meaning. Hans Reichenbach used a similar sentence in 1947 as an exercise to the reader ("John where Jack..."), to illustrate the different levels of language, namely object language and metalanguage.
In research showing how people make sense of information in their environment, this sentence was used to demonstrate how seemingly arbitrary decisions can drastically change meaning, analogous to how changes in the punctuation and quotes in the sentence show that the teacher alternately prefers James' work and John's work (e.g., compare: 'James, while John had had "had," had...' vs. 'James, while John had had "had had,"...').
The sentence is also used to show the semantic vagueness of the word "had," as well as to demonstrate the difference between using a word and mentioning a word.
It has also been used as an example of the complexities of language, its interpretation, and their effects on a person's perceptions.
For the syntactic structure to be clear to a reader, this sentence requires, at a minimum, that the two phrases be separated by using a semicolon, period, en-dash or em-dash. Still, Jasper Fforde's novel The Well of Lost Plots employs a variation of the phrase to illustrate the confusion that may arise even from well-punctuated writing:
"Okay" said the Bellman, whose head was in danger of falling apart like a chocolate orange, "let me get this straight: David Copperfield, unlike Pilgrim’s Progress, which had had 'had', had had 'had had'. 'Had had' had had TGC’s approval?"