Skip to content

This morphological decoder provided a lightweight decoder for the Sandborg-Petersen Morphology which is primarily tailored for Koine Greek, especially as it appears in New Testament studies and similar texts.

License

Notifications You must be signed in to change notification settings

tonyjurg/Sandborg-Petersen-decoder

Repository files navigation

Project Status: Active – The project has reached a stable, usable state and is being actively developed. Online Tool DOI SWH License: CC BY 4.0

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:

Definitional document

A descriptive document with parsing information is available via github.com/biblicalhumanities.

Integrating in HTML page

Using a JavScript generated button

Because the 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

Acknowledgements

About

This morphological decoder provided a lightweight decoder for the Sandborg-Petersen Morphology which is primarily tailored for Koine Greek, especially as it appears in New Testament studies and similar texts.

Topics

Resources

License

Stars

Watchers

Forks