# How can I generate natural language sentences given logical structures that contain the subject, verb and target?

I have a group of structures in a program that are very specific on their meaning, eg. this is a piece of code

randomItem = objects.concept.random("buyable")
idea.example(objects.concept.random("family", "friend")).does({
action: "go",
target: object.concent.random("shop")
}).then({
target: randomItem,
several: true
}).then({
question: true,
action: "know",
property: "amount",
target: randomItem,
several: true
})


I have worked with natural language parsers before.

How do I go and transform this to Natural Language (the other way around), is there any way or method; I have logical structures in which I know who is the subject, what the verb and target.

Which methods can I use to generate language from this?

It might be simpler to generate the language output yourself since you've already got a concrete concept structure in code.

Maybe you'll also want to be aware of potential future applications such as parsing your own output back to the inputs.

With that said, you could investigate Markov Chains or Google around a bit for Natural Language Processing and Natural Language Generation.

https://stackoverflow.com/questions/33068943/library-for-generating-natural-language-verbs-in-javascript

• I understand, however I'm creating a proof of concept and this problem has been solved before so I don't want to solve it from scratch or invent my own solution, I was wondering if there was some library that was ready to solve this sort of issues or efficient method. – Onza Apr 18 '17 at 11:54

Look at MUMBLE, which is a kind of transducer working from Conceptual Dependency structures (which are similar to what you've got) and produce English output.

A Lisp implementation of Meehan's TALESPIN program, which includes a simplified version of MUMBLE can be found here: https://github.com/lispm/CommonLispCode/blob/master/micro-talespin.lisp -- the generator part starts at about line 1030. It should be easy to follow, even if you do not know Lisp.