Format converter from PoetryLab JSON to POSTDATA semantic formats
- Free software: Apache Software License 2.0
- Documentation: https://horace.readthedocs.io.
get_scansion_graph()
receives a scansion dictionary from Rantanplan and outputs an RDFLib Graph object. With it, serialization options become available.
from rantanplan import get_scansion
from horace import get_scansion_graph
poem = """Me gustas cuando callas porque estás como ausente,
y me oyes desde lejos, y mi voz no te toca.
Parece que los ojos se te hubieran volado
y parece que un beso te cerrara la boca.
Como todas las cosas están llenas de mi alma
emerges de las cosas, llena del alma mía.
Mariposa de sueño, te pareces a mi alma,
y te pareces a la palabra melancolía."""
scansion = get_scansion(poem)
graph = get_scansion_graph(scansion)
graph.serialize(format="xml")
Graphs can be joined together, which is useful when combining graphs generated from scansion, enjambment analysus, or extraction of named entities.
graphs = []
graphs.append(get_scansion_graph(scansion1))
graphs.append(get_scansion_graph(scansion2))
graph = reduce(lambda x, y: x + y, graphs) # union on graphs
graph.serialize(format="xml")
By default, xml
is used to serialize to RDF/XML. Other formats are supported as well, such as json-ld
, n3
, turtle
, and nt
.
This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.