Skip to main content
Warning: You are using the test version of PyPI. This is a pre-production deployment of Warehouse. Changes made here affect the production instance of TestPyPI (
Help us improve Python packaging - Donate today!

An NLG tool for Finnish

Project Description

syntax_maker is a script that tries to create syntactically correct Finnish sentences based on a hand written grammar and automatically learned information about the language.

** NOTE 1: ** This tool requires Omorfi, you can download the correct binary version from ** NOTE 2: ** You need to install libhfst and hfst from

## Creating a sentence ##

Everything starts with a verb. To start a new sentece, call createVerbPharse with the desired verb. This will select the correct verb phrase template in grammar.json based on what is known about the verb’s valency. E.g. for the verb sammua VP1 is chosen and for the verb nuolla VP2 gets selected. If you need to create sentences with the copula, use createCopulaPhrase.


from syntaxmaker.syntax_maker import * vp = createVerbPharse(“uneksia”)

The next thing we’ll need to do is to add a subject for the verb pharse. This can be done by creating a noun phrase based on a noun or personal pronoun. If you want to use a personal pronoun, call createPersonalPronounPhrase. Otherwise, a regular noun phrase can be created by createPhrase("NP", noun).

Let’s add a subject and an object to our verb phrase:

vp.components[“subject”] = createPhrase(“NP”, “rantaleijona”, {u”NUM”: “PL”})

dir_object = createPhrase(“NP”, “aalto”, {u”NUM”: “PL”}) vp.components[“dir_object”] = dir_object

We can get a string representation of the sentence:

>>>print vp.to_string() rantaleijonat uneksivat aalloista

Furthermore, we can add an adjective to define one of our noun phrases by creating an adjective phrase with createPhrase("AP", adjective). An adverb can be added to the adjective phrase when we create an adverb phrase createPhrase("AdvP", adverb).

Let’s add an adjective to our object:

ap = createPhrase(“AP”, “korkea”) dir_object.components[“attribute”] = ap

And an adverb to the adjective phrase:

ap.components[“attribute”] = createPhrase(“AdvP”, “erittäin”)

The new string representation of the sentence will thus be:

>>>print vp.to_string() rantaleijonat uneksivat erittäin korkeista aalloista
Release History

Release History

This version
History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
syntaxmaker-1.0.1-py2.7.egg (2.5 MB) Copy SHA256 Checksum SHA256 2.7 Egg Aug 17, 2015
syntaxmaker-1.0.1-py2.py3-none-any.whl (2.5 MB) Copy SHA256 Checksum SHA256 py2.py3 Wheel Aug 17, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting