Skip to content

Different kinds of phrases

Mika Hämäläinen edited this page Aug 12, 2020 · 18 revisions

Phrases

NP, AP, AdvP...

For most of the phrase types, you can just use create_phrase(name, head, morphology={}) which creates a new phrase based on the name parameter and grammar.json. For example if name="NP", a noun phrase is created. Head is the desired word in lemmatized form. And the optional parameter morphology can be used to force certain morphological features. such as plural or a certain case.

 from syntaxmaker.syntax_maker import *
 np1 = create_phrase("NP", "kissa", morphology={"PERS": "3", "NUM": "SG"}) #kissa
 np2 = create_phrase("NP", "kissa", morphology={"PERS": "3", "NUM": "PL"}) #kissat

Adjective and adverb phrases

It is possible to create an adjective/adverb phrase also by running the following

from syntaxmaker.syntax_maker import *
ap = create_adjective_phrase("hieno", degree="Comp") #hienompi
adv = create_adverb_phrase("yleinen", degree="Comp") #yleisempi

degree can be used to specify whether the adjective/adverb should be in comparative (Comp) or superlative (Superl).

Adposition phrases

create_adposition_phrase(adposition, np) selects automatically the correct phrase type (preposition or postposition phrase) based on the given adposition. The np parameter defines the noun phrase used with the given adposition

For example:

np = create_phrase("NP", "kissa")
pp = create_adposition_phrase("ilman", np)
print(pp)
>>> ilman kissaa

To add the newly created adposition phrase to a verb phrase, use add_advlp_to_vp(vp, advlp). Where advlp is the adposition phrase.

Copula

You need a special kind of verb phrase for copula. Currently, you can only form phrases that are type X is Y with the verb olla. I.e. not phrases like X has Y or there is X. create_copula_phrase(predicative_case="Nom")

vp = create_copula_phrase()
subject = create_phrase("NP", "koira", {u"PERS": "3", u"NUM": "SG"})
predicative = create_phrase("NP", "eläin")
vp.components["subject"] = subject
vp.components["predicative"] = predicative
print(vp)
>> koira on eläin

Verb phrases

Take a look at Creating a sentence, the basics create_verb_pharse(head)

vp = create_verb_pharse("uneksia")
subject = create_phrase("NP", "rantaleijona", {u"PERS": "3", u"NUM": "PL"})
dobject = create_phrase("NP", "aalto", {u"PERS": "3", u"NUM": "PL"})
dobject.components["attribute"] = create_phrase("AP", "korkea")
dobject.components["attribute"].components["attribute"] = create_phrase("AdvP", "erittäin")
vp.components["subject"] = subject
vp.components["dir_object"] = dobject
print(vp)
>> rantaleijonat uneksivat erittäin korkeista aalloista