Sandborg-Petersen Morphology Decoder
This lightweight decoder implements the Sandborg-Petersen morphology schema for Koine Greek — especially New Testament and related texts — in a simple, browser-based tool.
You can try it online at https://tonyjurg.github.io/Sandborg-Petersen-decoder/.
The online version allows also allows for prefilling the decoder with a specific tag by appending ?tag=<TAG> (for example, ?tag=N-NSF).
Decoder formats
Two functionaly equivalent coding implementations are stored on this repository:
Python package
Install release 1.2 from PyPI with:
python -m pip install sandborg-petersen-decoder
For development, install the current source checkout with:
python -m pip install .
Permissive mode is the default. It returns all fields that can be recovered and
includes an Errors list when validation finds a problem:
from sp_morph_decoder import decode_tag
result = decode_tag("N-XYZ")
print(result["Errors"])
Strict mode raises MorphologyDecodeError. The exception retains the partial
result and the individual validation messages:
from sp_morph_decoder import MorphologyDecodeError, decode_tag
try:
result = decode_tag("N-XYZ", mode="strict")
except MorphologyDecodeError as error:
print(error.errors)
print(error.result)
The package also provides a command-line interface:
sp-morph-decode V-PAI-3S --mode strict
python -m sp_morph_decoder V-PAI-3S
See the Python package guide for installation, API, strict-mode, typing, and command-line documentation.
Definitional document
A descriptive document with parsing information is available via github.com/biblicalhumanities.
Integrating in HTML page
Using a JavaScript generated button
Because the online decoder requires JavaScript to function, it is reasonable to embed a link to it directly in any HTML page using a method depending on JavaScript as well. This approach also lets you open it in a new, resizable window of a specified size.
The first step is to add a script anywhere inside your <HEAD> section, or at the top of your <BODY> section:
<SCRIPT>
function openMinimalWindow() {
window.open(
'https://tonyjurg.github.io/Sandborg-Petersen-decoder/',
'_blank',
'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=800,height=600'
);
}
</SCRIPT>
In the <BODY> section include the following:
<BUTTON onclick="openMinimalWindow()">Open Morph decoder</button>
This will put a button on your page similair to the image below:
If JavaScript is enabled, clicking this button will launch the decoder in a new 800×600 px window without toolbars or menus.
Adding a direct link
If you prefer a simple hyperlink that opens in a full browser tab, just use:
<A HREF="https://tonyjurg.github.io/Sandborg-Petersen-decoder/" TARGET="_blank">Open Morph decoder</A>
Open decoder for a specific tags
You can also open the decoder pre-filled for a specific tag by appending a tag query parameter to its URL. In our HTML/JavaScript implementation, a small script reads the URL’s tag parameter and uses it to initialize the decoder, which is especially handy if you’ve already run your analysis in Python.
import pandas as pd
from IPython.display import HTML
base_url = "https://tonyjurg.github.io/Sandborg-Petersen-decoder/?tag="
# Simple example data
results = [
("Βίβλος", "N-NSF"),
("λόγος", "N-NSM"),
]
# Build dataframe
df = pd.DataFrame(results, columns=["Word", "Tag"])
# Embed clickable HTML links in the 'Tag' column
df["Tag"] = df["Tag"].apply(lambda tag: f'<a href="{base_url}{tag}" target="decoder">{tag}</a>')
# Display as an HTML table with clickable links
HTML(df.to_html(escape=False, index=False))
This will produce the following table:
| Word | Tag |
|---|---|
| Βίβλος | N-NSF |
| λόγος | N-NSM |
Note the use of target="decoder" would normally reuse a single named window. However, in a sanitized environment like Jupyter Notebook, each click opens a new window because Jupyter’s security model isolates browsing contexts. In contrast, when you save the same HTML locally (or serve it as a regular web page), clicks targeting the same window name correctly reuse that single window.
See the following small Jupyter Notebook to see the code in action.
Tag validation agains the MACULA GNT dataset
License
The original software and associated documentation are licensed under the
MIT License. MACULA-derived validation data in testing/output/ and
data embedded in the validation notebook remain available under
CC BY 4.0 with the required
MACULA attribution. See NOTICE.md for the exact scope, attribution,
and historical-release information.
Responsible disclosure
AI-assisted tools have been used in a limited capacity to audit this repository, identify possible defects, suggest improvements to the original code, and help develop automated tests. All resulting changes are reviewed and tested by the repository maintainer before inclusion. Scholarly interpretation, design decisions, and final responsibility for the code remain with the human author.
Acknowledgements
Release files for sandborg-petersen-decoder 1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sandborg_petersen_decoder-1.2.tar.gz | 9.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sandborg_petersen_decoder-1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.4 kB
Release files / sandborg_petersen_decoder-1.2.tar.gz
| Download URL | sandborg_petersen_decoder-1.2.tar.gz |
|---|---|
| Size | 9.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fb51b072c800e1a9b311d2840baf57639f30d6ed5676ca7630b4c2f1d1669826
|
|
BLAKE2b-256 checksum How to use checksums |
9ec9cd3620cc2ba9d180997cd8ca5de01cefd7da931d55159a67df718658ab5c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 10, 2026.
Transparency logRelease files / sandborg_petersen_decoder-1.2-py3-none-any.whl
| Download URL | sandborg_petersen_decoder-1.2-py3-none-any.whl |
|---|---|
| Size | 11.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4a00cd55f879355b92aa9f0499bfd573dc45e028197e58b5d1af1d5657e7628d
|
|
BLAKE2b-256 checksum How to use checksums |
f0d4978fe24019a644d367366cdbc4b7aaec46e304047ed6ae7acf0299875333
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 10, 2026.
Transparency log