How to use the reynir.NounPhrase function in reynir

To help you get started, we’ve selected a few reynir examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mideind / ReynirPackage / test / test_cases.py View on Github external
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
github mideind / ReynirPackage / test / test_cases.py View on Github external
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"
github mideind / ReynirPackage / test / test_cases.py View on Github external
"Þ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)
github mideind / ReynirPackage / test / test_cases.py View on Github external
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"
github mideind / ReynirPackage / test / test_cases.py View on Github external
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
github mideind / ReynirPackage / test / test_cases.py View on Github external
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"
github mideind / ReynirPackage / test / test_cases.py View on Github external
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"
github mideind / ReynirPackage / test / test_cases.py View on Github external
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"