Skip to content

Commit 8c753ba

Browse files
Merge pull request #1 from timofruehwirth/dev
merge for v0.1.0-beta.4
2 parents bc22f52 + 8e0dc27 commit 8c753ba

File tree

4 files changed

+118
-138
lines changed

4 files changed

+118
-138
lines changed

README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1-
# tei_rdfa
1+
> [!IMPORTANT]
2+
> tei-rdfa is currently in beta and welcomes feedback from early adopters.
3+
4+
# tei-rdfa
25

36
A Python utility for extracting RDFa data from TEI-XML documents.
47

8+
![tei-rdfa](tei-rdfa.png)
9+
510
## Overview
611

7-
`tei_rdfa()` is a dedicated function that extracts Resource Description Framework in Attributes (RDFa) data embedded in TEI (Text Encoding Initiative) XML documents and converts it into a standard RDF graph. The function handles native TEI namespace formatting through `<prefixDef>` elements (inside the `<encodingDesc>` section of the `<teiHeader>`).
12+
`tei_rdfa()` is a dedicated function that extracts RDFa (Resource Description Framework in Attributes) data embedded in TEI (Text Encoding Initiative) XML documents and converts it into a standard RDF graph.
13+
14+
The function handles native TEI namespace formatting through `<prefixDef>` elements (`//tei:encodingDesc/tei:listPrefixDef/tei:prefixDef`) rather than through the HTML5-style `prefix` or XHTML/XML-style `xmlns:prefix` attributes.[^1]
815

916
## Features
1017

@@ -21,7 +28,7 @@ A Python utility for extracting RDFa data from TEI-XML documents.
2128

2229
- `xmlfile` (str): File path or URL to a TEI-XML file (must have `.xml` or `.tei` extension)
2330
- `xpath_expr` (str, optional): XPath expression to target specific elements for RDFa extraction; will otherwise target the XML root element
24-
- `verbose` (bool, default=True): Controls logging output and graph serialization display
31+
- `verbose` (bool, default=True): Controls logging output
2532

2633
## Dependencies
2734

@@ -40,6 +47,12 @@ The package includes several helper functions that handle specific aspects of RD
4047

4148
Error messages provide contextual information to facilitate debugging and resolution.
4249

50+
## Installation
51+
52+
```shell
53+
pip install tei-rdfa
54+
```
55+
4356
## Example Usage
4457

4558
```python
@@ -77,3 +90,6 @@ The repository is organized as follows:
7790
- **tei_rdfa/** contains project metadata and configuration
7891
- **tei_rdfa/tei_rdfa/** contains the package implementation
7992
- **tei_rdfa/tei_rdfa/ipynb/** contains a Jupyter notebook demonstrating usage examples and error scenarios
93+
94+
---
95+
[^1]: See https://github.com/TEIC/TEI/issues/1860.

tei-rdfa.png

14.8 KB
Loading

tei_rdfa/__init__.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,7 @@ def tei_rdfa(xmlfile: str, xpath_expr: Optional[str] = None, verbose: bool = Tru
6969

7070
# output graph
7171
if verbose: # check verbosity status
72-
logger.info('Serializing RDF graph in Turtle format ...')
73-
print(g.serialize(format='turtle'))
74-
75-
logger.info('Serializing RDF graph in RDF-XML format ...')
76-
print(g.serialize(format='xml'))
72+
logger.info(f'Returning RDF graph with {len(g)} triples ...')
7773

7874
return g # return RDF graph for futher processing
7975

0 commit comments

Comments
 (0)