Learn R Programming

sumer (version 1.0.0)

look_up: Look Up Sumerian Signs or Search for Translations

Description

Searches a Sumerian dictionary either by sign name (forward lookup) or by translation text (reverse lookup).

The function look_up computes the search results and returns an object of class "look_up". The print method displays formatted results with cuneiform representations, grammatical types, and translation counts.

Usage

look_up(x, dic, lang = "sumer", width = 70)

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

Value

look_up returns an object of class "look_up", which is a list containing:

search

The original search term.

lang

The language setting used for the search.

width

The text width for formatting.

cuneiform

The cuneiform representation (only for Sumerian searches).

sign_name

The canonical sign name (only for Sumerian searches).

translations

A data frame with translations for the exact sign combination (only for Sumerian searches).

substrings

A named list of data frames with translations for individual signs and substrings (only for Sumerian searches).

matches

A data frame with matching entries (only for non-Sumerian searches).

print.look_up prints formatted dictionary entries to the console and returns x invisibly.

Arguments

x

For look_up: A character string specifying the search term. Can be either:

  • A Sumerian sign name (e.g., "AN", "AN.EN.ZU")

  • A cuneiform character string

  • A word or phrase to search in translations (e.g., "Gilgamesh", "heaven")

For print.look_up: An object of class "look_up" as returned by look_up.

dic

A dictionary data frame, typically created by make_dictionary or loaded with read_dictionary. Must contain columns sign_name, row_type, count, type, and meaning.

lang

Character string specifying whether x is a Sumerian expression ("sumer") or an English expression ("en").

width

Integer specifying the text width for line wrapping. Default is 70.

...

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

Details

Search Modes

The function operates in two modes depending on the input:

Forward Lookup (Sumerian input detected):

  1. Converts the sign name to cuneiform

  2. Retrieves all translations for the exact sign combination

  3. Retrieves translations for all individual signs and substrings

Reverse Lookup (non-Sumerian input):

  1. Searches for the term in all translation meanings

  2. Retrieves matching entries with sign names and cuneiform

Output Format

The print method displays results with:

  • Sign names with cuneiform representations

  • Occurrence counts in brackets (e.g., [29])

  • Grammatical type abbreviations (e.g., S, V)

  • Translation meanings with automatic line wrapping

  • Search term highlighting in blue for reverse lookups (only for ANSI-compatible terminals)

See Also

read_dictionary for loading dictionaries, make_dictionary for creating dictionaries, as.cuneiform for cuneiform conversion.

Examples

Run this code
# Load dictionary
dic <- read_dictionary()

# Forward lookup: search by phonetic spelling
look_up("d-suen", dic)

# Forward lookup: search by Sumerian sign name
look_up("AN", dic)
look_up("AN.EN.ZU", dic)

# Forward lookup: search by cuneiform character string
AN.NA <- paste0(intToUtf8(0x1202D), intToUtf8(0x1223E))
AN.NA
look_up(AN.NA, dic)

# Reverse lookup: search in translations
look_up("Gilgamesh", dic, "en")

# Adjust output width for narrow terminals
look_up("water", dic, "en", width = 50)

# Store results for later use
result <- look_up("lugal", dic)
result$cuneiform
result$translations

# Print stored results
print(result)

Run the code above in your browser using DataLab