Scientists at the University of Edinburgh have created a machine that generates its own one-line jokes following a simple set of rules.

The system was designed to utilize a common component in modern jokes, where a statement is followed up by a surprising comment.

And just like its human counterparts, the computer comedian has developed a knack for rather politically incorrect jokes – particularly those of a sexist nature.

Other one-liners steer more to the surreal rather than the funny.

The machine was designed to take unnatural pairings of words and to make a connection between them.

Most common jokes produced were those comparing men or women with another object, for example: "I like my women like I like my gas…natural."

David Matthews, one of the scientists who helped create the software at University of Edinburgh’s School of Informatics, said that when they tested jokes on volunteers they did laugh, but not as much as man made humour.

"The Holy Grail for machine-generated comedy would be to include cultural references, but these are very hard to capture."

Matthews is due to present the computer at the Association for Computational Linguistics annual meeting in Bulgaria.