Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
assert str(np) == "þrír skjóttir hestar"
assert len(np) == len(str(np))
assert "Umræðuefnið er {np:stofn}".format(np=np) == 'Umræðuefnið er skjóttur hestur'
try:
"Óleyfilegt {np:.2f}".format(np=np)
except ValueError:
pass
else:
assert False, "Should have raised ValueError"
try:
"Óleyfilegt {np:abc}".format(np=np)
except ValueError:
pass
else:
assert False, "Should have raised ValueError"
np = NounPhrase("Doddi át kökuna")
assert not np.parsed
assert np.gender is None
assert np.number is None
assert np.case is None
assert np.person is None
np = NounPhrase("")
assert not np.parsed
assert np.gender is None
assert np.number is None
assert np.case is None
assert np.person is None
from reynir import NounPhrase
np = NounPhrase(
"þrír glæsilegir lúxus-bíómiðar á Star Wars "
"og að auki tveir stútfullir pokar af ilmandi poppi"
)
assert np.parsed
assert len(np) == len(str(np))
assert (
"Hér er kvittunin þín fyrir {np:þgf}. "
"Þar með ertu búin(n) að kaupa {np:þf}.".format(np=np)
== "Hér er kvittunin þín fyrir þremur glæsilegum lúxus-bíómiðum "
"á Star Wars og að auki tveimur stútfullum pokum af ilmandi poppi. "
"Þar með ertu búin(n) að kaupa þrjá glæsilega lúxus-bíómiða "
"á Star Wars og að auki tvo stútfulla poka af ilmandi poppi."
)
np = NounPhrase('skjótti hesturinn')
assert np.parsed
assert np.case == "nf"
assert np.person == "p3"
assert np.number == "et"
assert np.gender == "kk"
assert str(np) == "skjótti hesturinn"
assert "Hér er {np:nf}".format(np=np) == 'Hér er skjótti hesturinn'
assert "Um {np:þf}".format(np=np) == 'Um skjótta hestinn'
assert "Frá {np:þgf}".format(np=np) == 'Frá skjótta hestinum'
assert "Til {np:ef}".format(np=np) == 'Til skjótta hestsins'
assert "Hér er {np:ángr}".format(np=np) == 'Hér er skjóttur hestur'
np = NounPhrase("þrír skjóttir hestar")
assert np.parsed
assert np.number == "ft"
assert np.case == "nf"
assert np.person == "p3"
"Þar með ertu búin(n) að kaupa þrjá glæsilega lúxus-bíómiða "
"á Star Wars og að auki tvo stútfulla poka af ilmandi poppi."
)
np = NounPhrase('skjótti hesturinn')
assert np.parsed
assert np.case == "nf"
assert np.person == "p3"
assert np.number == "et"
assert np.gender == "kk"
assert str(np) == "skjótti hesturinn"
assert "Hér er {np:nf}".format(np=np) == 'Hér er skjótti hesturinn'
assert "Um {np:þf}".format(np=np) == 'Um skjótta hestinn'
assert "Frá {np:þgf}".format(np=np) == 'Frá skjótta hestinum'
assert "Til {np:ef}".format(np=np) == 'Til skjótta hestsins'
assert "Hér er {np:ángr}".format(np=np) == 'Hér er skjóttur hestur'
np = NounPhrase("þrír skjóttir hestar")
assert np.parsed
assert np.number == "ft"
assert np.case == "nf"
assert np.person == "p3"
assert np.gender == "kk"
assert str(np) == "þrír skjóttir hestar"
assert len(np) == len(str(np))
assert "Umræðuefnið er {np:stofn}".format(np=np) == 'Umræðuefnið er skjóttur hestur'
try:
"Óleyfilegt {np:.2f}".format(np=np)
except ValueError:
pass
else:
assert False, "Should have raised ValueError"
try:
"Óleyfilegt {np:abc}".format(np=np)
def test_addresses():
from reynir import NounPhrase
np = NounPhrase("Laugavegi 20b")
assert np.nominative == "Laugavegur 20b"
assert np.accusative == "Laugaveg 20b"
assert np.dative == "Laugavegi 20b"
assert np.genitive == "Laugavegar 20b"
np = NounPhrase("Baugatanga 6C")
assert np.nominative == "Baugatangi 6C"
assert np.accusative == "Baugatanga 6C"
assert np.dative == "Baugatanga 6C"
assert np.genitive == "Baugatanga 6C"
np = NounPhrase("Æðarvarp 17")
assert np.nominative == "Æðarvarp 17"
assert np.accusative == "Æðarvarp 17"
assert np.dative == "Æðarvarpi 17"
assert np.genitive == "Æðarvarps 17"
np = NounPhrase("Vættaborgir 17")
assert np.nominative == "Vættaborgir 17"
pass
else:
assert False, "Should have raised ValueError"
try:
"Óleyfilegt {np:abc}".format(np=np)
except ValueError:
pass
else:
assert False, "Should have raised ValueError"
np = NounPhrase("Doddi át kökuna")
assert not np.parsed
assert np.gender is None
assert np.number is None
assert np.case is None
assert np.person is None
np = NounPhrase("")
assert not np.parsed
assert np.gender is None
assert np.number is None
assert np.case is None
assert np.person is None
np = NounPhrase("Æðarvarp 17")
assert np.nominative == "Æðarvarp 17"
assert np.accusative == "Æðarvarp 17"
assert np.dative == "Æðarvarpi 17"
assert np.genitive == "Æðarvarps 17"
np = NounPhrase("Vættaborgir 17")
assert np.nominative == "Vættaborgir 17"
assert np.accusative == "Vættaborgir 17"
assert np.dative == "Vættaborgum 17"
assert np.genitive == "Vættaborga 17"
np = NounPhrase("Vættaborga 17")
assert np.nominative == "Vættaborgir 17"
assert np.accusative == "Vættaborgir 17"
assert np.dative == "Vættaborgum 17"
assert np.genitive == "Vættaborga 17"
np = NounPhrase("Sólarsölum 3B")
assert np.nominative == "Sólarsalir 3B"
assert np.accusative == "Sólarsali 3B"
assert np.dative == "Sólarsölum 3B"
assert np.genitive == "Sólarsala 3B"
np = NounPhrase("Gamla vitanum í Garðskaga á Reykjanesi")
assert np.nominative == "Gamli vitinn í Garðskaga á Reykjanesi"
assert np.accusative == "Gamla vitann í Garðskaga á Reykjanesi"
assert np.dative == "Gamla vitanum í Garðskaga á Reykjanesi"
assert np.genitive == "Gamla vitans í Garðskaga á Reykjanesi"
np = NounPhrase("Gamla vitans í Garðskaga á Reykjanesi")
assert np.nominative == "Gamli vitinn í Garðskaga á Reykjanesi"
assert np.accusative == "Gamla vitann í Garðskaga á Reykjanesi"
assert np.dative == "Gamla vitanum í Garðskaga á Reykjanesi"
assert np.genitive == "Gamla vitans í Garðskaga á Reykjanesi"
def test_addresses():
from reynir import NounPhrase
np = NounPhrase("Laugavegi 20b")
assert np.nominative == "Laugavegur 20b"
assert np.accusative == "Laugaveg 20b"
assert np.dative == "Laugavegi 20b"
assert np.genitive == "Laugavegar 20b"
np = NounPhrase("Baugatanga 6C")
assert np.nominative == "Baugatangi 6C"
assert np.accusative == "Baugatanga 6C"
assert np.dative == "Baugatanga 6C"
assert np.genitive == "Baugatanga 6C"
np = NounPhrase("Æðarvarp 17")
assert np.nominative == "Æðarvarp 17"
assert np.accusative == "Æðarvarp 17"
assert np.dative == "Æðarvarpi 17"
assert np.genitive == "Æðarvarps 17"
np = NounPhrase("Vættaborgir 17")
assert np.nominative == "Vættaborgir 17"
assert np.accusative == "Vættaborgir 17"
assert np.dative == "Vættaborgum 17"
assert np.genitive == "Vættaborga 17"
np = NounPhrase("Vættaborga 17")
assert np.nominative == "Vættaborgir 17"
def test_addresses():
from reynir import NounPhrase
np = NounPhrase("Laugavegi 20b")
assert np.nominative == "Laugavegur 20b"
assert np.accusative == "Laugaveg 20b"
assert np.dative == "Laugavegi 20b"
assert np.genitive == "Laugavegar 20b"
np = NounPhrase("Baugatanga 6C")
assert np.nominative == "Baugatangi 6C"
assert np.accusative == "Baugatanga 6C"
assert np.dative == "Baugatanga 6C"
assert np.genitive == "Baugatanga 6C"
np = NounPhrase("Æðarvarp 17")
assert np.nominative == "Æðarvarp 17"
assert np.accusative == "Æðarvarp 17"
assert np.dative == "Æðarvarpi 17"
assert np.genitive == "Æðarvarps 17"
np = NounPhrase("Vættaborgir 17")
assert np.nominative == "Vættaborgir 17"
assert np.accusative == "Vættaborgir 17"
assert np.dative == "Vættaborgum 17"
assert np.genitive == "Vættaborga 17"
np = NounPhrase("Vættaborga 17")
assert np.nominative == "Vættaborgir 17"
assert np.accusative == "Vættaborgir 17"
assert np.dative == "Vættaborgum 17"
assert np.genitive == "Vættaborga 17"
np = NounPhrase("Sólarsölum 3B")
assert np.nominative == "Sólarsalir 3B"
def test_casting():
""" Test functions to cast words in nominative case to other cases """
from reynir.bindb import BIN_Db
db = BIN_Db()
assert db.cast_to_accusative("") == ""
assert db.cast_to_dative("") == ""
assert db.cast_to_genitive("") == ""
assert db.cast_to_accusative("xxx") == "xxx"
assert db.cast_to_dative("xxx") == "xxx"
assert db.cast_to_genitive("xxx") == "xxx"
assert db.cast_to_accusative("maðurinn") == "manninn"
assert db.cast_to_dative("maðurinn") == "manninum"
assert db.cast_to_genitive("maðurinn") == "mannsins"
assert db.cast_to_accusative("mennirnir") == "mennina"
assert db.cast_to_dative("mennirnir") == "mönnunum"
assert db.cast_to_genitive("mennirnir") == "mannanna"
def test_augment_terminal():
a = augment_terminal("so_subj_op_þf", "langaði", "OP-GM-FH-ÞT-3P-ET")
assert a == "so_subj_op_þf_et_fh_gm_þt"
a = augment_terminal("so_subj_sagnb_þf", "langað", "GM-SAGNB")
assert a == "so_subj_sagnb_þf_gm"
a = augment_terminal("so_subj_lhþt_et_kvk", "valin", "LHÞT-SB-KVK-NFET")
assert a == "so_subj_lhþt_et_kvk_nf_sb"
a = augment_terminal("so_subj_nh", "skorta", "GM-NH")
assert a == "so_subj_nh_gm"
a = augment_terminal("so_subj_nh_þgf", "blöskra", "GM-NH")
assert a == "so_subj_nh_þgf_gm"
a = augment_terminal("so_1_þf_subj_op_þgf", "þraut", "OP-GM-FH-ÞT-1P-ET")
assert a == "so_1_þf_subj_op_þgf_et_fh_gm_þt"
a = augment_terminal("so_2_þgf_þf_p1_et", "skrifa", "GM-FH-NT-1P-ET")
assert a == "so_2_þgf_þf_et_fh_gm_nt_p1"
a = augment_terminal("so_0_lhþt_et_kk", "kembdur", "LHÞT-SB-KK-NFET")
assert a == "so_0_et_kk_lhþt_nf_sb"