You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mika Hämäläinen edited this page Aug 12, 2020
·
6 revisions
Creating a sentence
Syntax maker is a tool that creates syntactically correct Finnish sentences based on grammar.json.
Creating a sentence
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:
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