SimpleNLG
SimpleNLG is a simple Java API designed to facilitate the generation of Natural Language. It was originally developed at theUniversity of Aberdeen’s Department of Computing Science. The discussion list for SimpleNLG is on Google Groups.
SimpleNLG is intended to function as a “realisation engine” for Natural Language Generation architectures, and has been used successfully in a number of projects, both academic and commercial. It handles the following:
- Lexicon/morphology system: The default lexicon computes inflected forms (morphological realisation). We believe this has fair coverage. Better coverage can be obtained by using the NIH Specialist Lexicon (which is supported by SimpleNLG).
- Realiser: Generates texts from a syntactic form. Grammatical coverage is limited compared to tools such as KPML andFUF/SURGE, but we believe it is adequate for many NLG tasks.
- Microplanning: Currently just simple aggregation, hopefully will grow over time.
Getting Started (adapted from here)
SimpleNLG is a library, which means it cannot run as a stand alone application. You will need to have your own Java program/main method that utilizes the classes and methods in the SimpleNLG library.
To enable your program to make use of the simplenlg library, you’ll need to:
- Download the simplenlg zip file from the Download tab.
- Extract then add simplenlg’s jar file to your classpath. (For instructions on how to do this in Eclipse, see Appendix B).
- Create a new Java class which has the main method in it. In this example, let’s call the new class TestMain.
- At the top of that class, put in the following import statements:
import simplenlg.framework.*; import simplenlg.lexicon.*; import simplenlg.realiser.english.*; import simplenlg.phrasespec.*; import simplenlg.features.*; - Create a SimpleNLG lexicon, NLGFactory, and realiser using the following statements:
Lexicon lexicon = Lexicon.getDefaultLexicon(); NLGFactory nlgFactory = new NLGFactory(lexicon); Realiser realiser = new Realiser(lexicon);
Following these steps, you should have code that looks like the following:
import simplenlg.framework.*;
import simplenlg.lexicon.*;
import simplenlg.realiser.english.*;
import simplenlg.phrasespec.*;
import simplenlg.features.*;
public class TestMain {
public static void main(String[] args) {
Lexicon lexicon = Lexicon.getDefaultLexicon();
NLGFactory nlgFactory = new NLGFactory(lexicon);
Realiser realiser = new Realiser(lexicon);
}
}
You’re now ready to make use of simplenlg to generate sentences!
→ For further examples on ways to use simplenlg, take a look at the java files in testsrc. A stand-alone example is provided in testsrc/StandAloneExample.java.
