How to use the reynir.Greynir 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_serializers.py View on Github external
new = r.loads_single(json_str)

        assert new.tree is not None

        assert orig.tokens == new.tokens
        assert orig.terminals == new.terminals

        assert orig.tree.flat_with_all_variants == orig.tree.flat_with_all_variants
        cls = r.__class__
        assert json.loads(orig.dumps(cls, indent=2)) == json.loads(new.dumps(cls, indent=2))


if __name__ == "__main__":
    # When invoked as a main module, do a verbose test
    from reynir import Greynir
    r = Greynir()
    test_serializers(r)
    r.__class__.cleanup()
github mideind / ReynirPackage / test / test_cases.py View on Github external
def r():
    """ Provide a module-scoped Greynir instance as a test fixture """
    from reynir import Greynir
    r = Greynir()
    yield r
    # Do teardown here
    r.__class__.cleanup()
github mideind / ReynirPackage / test / test_cases.py View on Github external
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"


if __name__ == "__main__":
    # When invoked as a main module, do a verbose test
    from reynir import Greynir
    r = Greynir()
    test_cases(r)
    test_noun_phrases(r)
    test_casting()
    test_addresses()
    r.__class__.cleanup()
github mideind / ReynirPackage / test / test_serializers.py View on Github external
def r():
    """ Provide a module-scoped Greynir instance as a test fixture """
    from reynir import Greynir
    r = Greynir()
    yield r
    # Do teardown here
    r.__class__.cleanup()
github mideind / ReynirPackage / test / test_reynir.py View on Github external
def test_lemmas():
    from reynir import Greynir
    g = Greynir()
    s = g.parse_single(
        "Hallbjörn borðaði ísinn kl. 14 meðan Icelandair át 3 teppi "
        "frá Íran og Xochitl var tilbeðin."
    )
    assert (
        list(zip(s.lemmas, s.categories)) == [
            ('Hallbjörn', 'kk'), ('borða', 'so'), ('ís', 'kk'), ('kl. 14', ''),
            ('meðan', 'st'), ('Icelandair', 'entity'), ('éta', 'so'), ('3', ''),
            ('teppi', 'hk'), ('frá', 'fs'), ('Íran', 'hk'), ('og', 'st'),
            ('Xochitl', 'entity'), ('vera', 'so'), ('tilbiðja', 'so'), ('.', '')
        ]
    )
    assert (
        s.lemmas_and_cats == [
            ('Hallbjörn', 'person_kk'), ('borða', 'so'), ('ís', 'kk'), ('kl. 14', ''),
            ('meðan', 'st'), ('Icelandair', 'entity'), ('éta', 'so'), ('3', ''),