# Read translations from a single text document
filename <- system.file("extdata", "text_with_translations.txt", package = "sumer")
translations <- read_translated_text(filename)
# View the structure
head(translations)
#Make some custom unifications (here: removing the word "the")
translations$meaning <- gsub("\\bthe\\b", "", translations$meaning, ignore.case = TRUE)
translations$meaning <- trimws(gsub("\\s+", " ", translations$meaning))
# View the structure
head(translations)
#Convert the result into a dictionary
dictionary <- convert_to_dictionary(translations)
# View the structure
head(dictionary)
# View entries for a specific sign
dictionary[dictionary$sign_name == "EN", ]
# With custom mapping
path <- system.file("extdata", "etcsl_mapping.txt", package = "sumer")
mapping <- read.csv2(path, sep=";", na.strings="")
translations <- read_translated_text(filename, mapping = mapping)
dictionary <- convert_to_dictionary(translations, mapping = mapping)
head(dictionary)
Run the code above in your browser using DataLab