Learn R Programming

sumer (version 1.3.0)

grammatical_structure: Grammatical Structure of a Sumerian Expression

Description

Determines and visualizes the grammatical structure of a Sumerian expression. The function groups sub-expressions according to operator binding and composition rules and returns a bracketed string in which each bracket type indicates the grammatical role of the group:

  • () -- substantive (S)

  • <> -- verb (V)

  • [] -- attribute (A)

  • {} -- sentence (SEN)

The result has class "grammatical_structure" and comes with a print method that displays the bracket tree with color-coded groups in the console (requires ANSI color support).

Usage

grammatical_structure(s, type, expr = NULL)

# S3 method for grammatical_structure print(x, ...)

Value

A character string of class "grammatical_structure" with typed brackets showing the grammatical grouping. On error, a plain character string containing the error message.

Arguments

s

Character string. A Sumerian expression in cuneiform characters.

type

Character vector of grammatical types, one per sub-expression. Each entry is either a base type ("S", "V", "A") or an operator type (e.g. "Sx->V", "xS->A").

expr

Character vector of sub-expressions (e.g. the individual signs or sign groups that make up s). The function matches each expr[k] in s, determines the grouping, and returns the result with the original expressions in place.

x

An object of class "grammatical_structure".

...

Further arguments (currently unused).

Details

The grouping is performed in two stages. First, add_brackets inserts bracket groups based on operator binding strength and pairwise composition rules. Then each group is assigned a bracket type that reflects its grammatical role, as determined by the operator it contains or by the types of its elements.

The print method displays the resulting string with ANSI colors in the console. Each bracket type and its direct content (nesting level 0) are shown in a distinct color: green for (), blue for [], red for <>, and yellowish-brown for {}. Bracket pairs that contain only nested sub-groups (no bare symbols at nesting level 0) are shown in light gray.

See Also

apply_translation_rules for translating (instead of visualizing) the structure, add_brackets for the underlying grouping algorithm, split_sumerian for obtaining the sub-expressions from a Sumerian string

Examples

Run this code
x <- "mec3-ki-aj2-ga-ce-er ce du"
x <- as.cuneiform(x)
x

expr <- split_sumerian(x)$signs
expr

type <- c("S", "S", "Sx->A", "xS->A",  "S",  "Sx->S", "S", "Sx->V")

grammatical_structure(x, type, expr)


#You can also work with the transliteration:

x <- "mec3 ki aj2 ga ce er ce du"
expr <- split_sumerian(x)$signs

grammatical_structure(x, type, expr)


Run the code above in your browser using DataLab