Learn R Programming

sumer (version 1.0.0)

info: Retrieve Information About Sumerian Signs

Description

Analyzes a transliterated Sumerian text string and retrieves detailed information about each sign, including syllabic readings, sign names, cuneiform symbols, and alternative readings.

The function info computes the result and returns an object of class "info". The print method displays a summary of different text representations in the console.

Usage

info(x, mapping = NULL)

# S3 method for info print(x, flatten = FALSE, ...)

Value

info returns a data frame of class c("info", "data.frame") with one row per sign and the following columns:

reading

The syllabic reading of the sign. For lowercase input, this is the standardized input; for other types, this is the default syllable from the mapping.

sign

The Unicode cuneiform character corresponding to the sign.

name

The canonical sign name in uppercase.

alternatives

A comma-separated string of all possible syllabic readings for the sign.

The data frame has an attribute "separators" containing the separator characters between signs.

print.info prints the following to the console and returns x invisibly:

Sign table

Each sign with its cuneiform symbol, name, and alternative readings.

syllables

The text with syllabic readings, using hyphens as separators within words.

sign names

The text with sign names, using periods as separators within words.

cuneiform text

The text rendered in Unicode cuneiform characters, with hyphens and periods removed.

Arguments

x

For info: a character string of length 1 containing transliterated Sumerian text.

For print.info: an object of class "info".

mapping

A data frame containing the sign mapping table with columns syllables, name, and cuneiform. If NULL (the default), the package's internal mapping file etcsl_mapping.txt is loaded.

flatten

Logical. If TRUE, grammar indicators in the text are removed (such as parentheses, brackets, braces, and operators). If FALSE (the default), the original separators are preserved.

...

Additional arguments passed to the print method (currently unused).

Details

The function info performs the following steps:

  1. Splits the input string into signs and separators using split_sumerian.

  2. Standardizes the signs.

  3. Looks up each sign in the mapping table based on its type:

    • Type 1 (lowercase): Searches for a matching syllable reading.

    • Type 2 (uppercase): Searches for a matching sign name.

    • Type 3 (cuneiform): Searches for a matching cuneiform character.

  4. Returns a data frame with the results, along with the separators stored as an attribute.

The mapping table must contain the following columns:

syllables

Comma-separated list of possible syllabic readings for the sign. The first reading is used as the default.

name

The canonical sign name in uppercase.

cuneiform

The Unicode cuneiform character.

The print method displays each sign with its name and alternative readings, followed by three text representations: syllables, sign names, and cuneiform text.

See Also

split_sumerian for splitting Sumerian text into signs,

Examples

Run this code
library(stringr)

# Basic usage - compute and print
info("lugal-e")

# Store the result for further processing
result <- info("an-ki")
result

# Access the underlying data frame
result$sign
result$name

# Print with and without flattened separators
result <- info("(an)na")
print(result)
print(result, flatten = TRUE)

# Using a custom mapping table
path <- system.file("extdata", "etcsl_mapping.txt", package = "sumer")
my_mapping <- read.csv2(path, sep=";", na.strings="")
info("an-ki", mapping = my_mapping)

Run the code above in your browser using DataLab