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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sandborg_petersen_decoder-1.2.tar.gz.
File metadata
- Download URL: sandborg_petersen_decoder-1.2.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb51b072c800e1a9b311d2840baf57639f30d6ed5676ca7630b4c2f1d1669826
|
|
| MD5 |
f4629dd625a5ae60217e8ab5a8bb65dc
|
|
| BLAKE2b-256 |
9ec9cd3620cc2ba9d180997cd8ca5de01cefd7da931d55159a67df718658ab5c
|
Provenance
The following attestation bundles were made for sandborg_petersen_decoder-1.2.tar.gz:
Publisher:
publish-version.yml on tonyjurg/Sandborg-Petersen-decoder
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sandborg_petersen_decoder-1.2.tar.gz -
Subject digest:
fb51b072c800e1a9b311d2840baf57639f30d6ed5676ca7630b4c2f1d1669826 - Sigstore transparency entry: 2405917921
- Sigstore integration time:
-
Permalink:
tonyjurg/Sandborg-Petersen-decoder@386b83edfa5b30af5a0cf8029dd269f36a2badb4 -
Branch / Tag:
refs/tags/v1.2 - Owner: https://github.com/tonyjurg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-version.yml@386b83edfa5b30af5a0cf8029dd269f36a2badb4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sandborg_petersen_decoder-1.2-py3-none-any.whl.
File metadata
- Download URL: sandborg_petersen_decoder-1.2-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a00cd55f879355b92aa9f0499bfd573dc45e028197e58b5d1af1d5657e7628d
|
|
| MD5 |
26e3170c560e75ca41ddfe01f6ff4ea2
|
|
| BLAKE2b-256 |
f0d4978fe24019a644d367366cdbc4b7aaec46e304047ed6ae7acf0299875333
|
Provenance
The following attestation bundles were made for sandborg_petersen_decoder-1.2-py3-none-any.whl:
Publisher:
publish-version.yml on tonyjurg/Sandborg-Petersen-decoder
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sandborg_petersen_decoder-1.2-py3-none-any.whl -
Subject digest:
4a00cd55f879355b92aa9f0499bfd573dc45e028197e58b5d1af1d5657e7628d - Sigstore transparency entry: 2405917935
- Sigstore integration time:
-
Permalink:
tonyjurg/Sandborg-Petersen-decoder@386b83edfa5b30af5a0cf8029dd269f36a2badb4 -
Branch / Tag:
refs/tags/v1.2 - Owner: https://github.com/tonyjurg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-version.yml@386b83edfa5b30af5a0cf8029dd269f36a2badb4 -
Trigger Event:
push
-
Statement type: