-
-
Notifications
You must be signed in to change notification settings - Fork 4
Creating a sentence, the basics
Syntax maker is a tool that creates syntactically correct Finnish sentences based on grammar.json
.
Everything starts with a verb. To start a new sentece, call create_verb_pharse
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 create_copula_phrase
.
Example:
from syntaxmaker.syntax_maker import *
vp = create_verb_pharse("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 create_personal_pronoun_phrase
. Otherwise, a regular noun phrase can be created by create_phrase("NP", noun)
.
Let's add a subject and an object to our verb phrase:
vp.components["subject"] = create_phrase("NP", "rantaleijona", {u"NUM": "PL"})
dir_object = create_phrase("NP", "aalto", { u"NUM": "PL"})
vp.components["dir_object"] = dir_object
We can get a string representation of the sentence:
print(vp)
>> rantaleijonat uneksivat aalloista
Furthermore, we can add an adjective to define one of our noun phrases by creating an adjective phrase with create_phrase("AP", adjective)
. An adverb can be added to the adjective phrase when we create an adverb phrase create_phrase("AdvP", adverb)
.
Let's add an adjective to our object:
ap = create_phrase("AP", "korkea")
dir_object.components["attribute"] = ap
And an adverb to the adjective phrase:
ap.components["attribute"] = create_phrase("AdvP", "erittäin")
The new string representation of the sentence will thus be:
print(vp)
>> rantaleijonat uneksivat erittäin korkeista aalloista