In generating reports, sometimes there is a need to produce quite involved phrases in one of natural languages given numerical or boolean parameters.

To get a feel of it, it is enough to take a look at convert integers into words or time ago algorithms.

These solutions use (procedural/OO/functional) programming and Turing-complete computations, but the question is, whether there is some declarative approach, or hybrid approach, which can be more generic for this class of algorithms? By hybrid I understand decomposed into preparation phase (calculating or defining all necessary units, tuples and conditions), and phrase generation phase, which works with declarative definitions (some kind of domain-specific language)?

The current approach I see in Open Source projects is like the above-mentioned questions: conditional statements interspersed with string interpolations or concatenations. I guess, there are more optimal ones.

What I am searching for is some right term for the problem. I am sure there is a lot of research on the topic, but I have so far failed to come with good keywords to find suitable theory. This is something in between of constant phrases and arbitrary text generation. Ideally, the declarative part should be something easy for domain experts, like a grammar.

In practice, there is also table-driven approach, but what about theories?

Also found this oldish work A flexible shallow approach to text generation by S. Busemann and H.Horacek, but it goes too fast into too specific cases.

  • $\begingroup$ What's wrong with using a string of conditional statements? You want a different approach, but what's the motivation for that? Not everything has an elegant theory. To me the question sounds like "I know I can drive a nail in with a hammer, but can I drive a nail with a pair of pliers?" to which my answer would be "Maybe, but why would you want to?" I'm guessing you have some requirements that aren't met by conditional statements. Knowing what your requirements are, and why a string of conditional statements doesn't meet those requirements, might help us provide better answers. $\endgroup$
    – D.W.
    Dec 22 '16 at 17:09
  • $\begingroup$ I am curious because these problems seem like a good candidate to be solved with less expressive technique. Programs in less expressive DS languages are easier to "debug" and arguably write. Otherwise why we would have things like gettext/po-files when you always can add IFs? Why bother with RDF/OWL and simple rules, when everything can be expressed in Turing-complete PL? $\endgroup$
    – Roman Susi
    Dec 22 '16 at 18:43

I've found a survey on natural-language generation approaches by Albert Gatt, Emiel Krahmer, 2018. According to that, my question is about linguistic realization. And the paper mentions three most common ones:

  • human-crafted templates
  • human-crafted grammar-based systems
  • statistical approaches

If I remember correctly, there may also be rules-based NLG systems, which may be overlapping with the grammar-based in the above classification.

And I am sure there may be more approaches.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.