There's actually a precedent for even this story, an account of a word-generating machine that even induces a kind of psychosis amongst its users, in Gulliver's Travels of all things. This is the description of "The Engine", the machine which the Laputan scientists used to develop new theories and lines of inquiry:
The first professor I saw, was in a very large
room, with forty pupils about him. After
salutation, observing me to look earnestly
upon a frame, which took up the greatest
part of both the length and breadth of the
room, he said, "Perhaps I might wonder to
see him employed in a project for improving
speculative knowledge, by practical and
mechanical operations. But the world would
soon be sensible of its usefulness; and he
flattered himself, that a more noble,
exalted thought never sprang in any other
man's head. Every one knew how laborious the
usual method is of attaining to arts and
sciences; whereas, by his contrivance, the
most ignorant person, at a reasonable
charge, and with a little bodily labour,
might write books in philosophy, poetry,
politics, laws, mathematics, and theology,
without the least assistance from genius or
study." He then led me to the frame, about
the sides, whereof all his pupils stood in
ranks. It was twenty feet square, placed in
the middle of the room. The superfices was
composed of several bits of wood, about the
bigness of a die, but some larger than
others. They were all linked together by
slender wires. These bits of wood were
covered, on every square, with paper pasted
on them; and on these papers were written
all the words of their language, in their
several moods, tenses, and declensions; but
without any order. The professor then
desired me "to observe; for he was going to
set his engine at work." The pupils, at his
command, took each of them hold of an iron
handle, whereof there were forty fixed round
the edges of the frame; and giving them a
sudden turn, the whole disposition of the
words was entirely changed. He then
commanded six-and-thirty of the lads, to
read the several lines softly, as they
appeared upon the frame; and where they
found three or four words together that
might make part of a sentence, they dictated
to the four remaining boys, who were
scribes. This work was repeated three or
four times, and at every turn, the engine
was so contrived, that the words shifted
into new places, as the square bits of wood
moved upside down.
I mean that's Jonathan Swift, who is noted repeatedly as a huge influence on Dahl.
Dahl’s authorised biographer, Donald Sturrock even states it explicitly in a 2016 interview “I think he wanted to be a satirist like Jonathan Swift, I think it’s the way he would like to have gone had his career as a novelist taken off the way he wanted it to.”
Indeed, his debut novel in 1948 - a nuclear jeremiad, "Some Time Never: A Fable for Supermen" - has a prominent quote on its dust jacket describing it as having a "Swiftian quality".