opus-data/OpusData.R

31 lines
783 B
R

#!/usr/bin/env Rscript
# Attach packages to workspace, execute with every new session
source("ReadOpus.R")
# Determine file path
path <- commandArgs(trailingOnly = TRUE)[1]
file_name <- commandArgs(trailingOnly = TRUE)[2]
file_path <- paste(path, file_name, sep = "")
# Convert opus binary file into dataframe
data <- read_opus_univ(file_path, 5)
# Replace last "." with "_", add ".DPT"
file_name <- paste0(sub(".([^.]*)$", "_\\1", file_name), ".DPT")
# Determine target, where the result should appear
target_path <- paste0(path, "../DPT/", file_name)
# Create file
file.create(target_path)
# Fill file with dataframe
write.table(data, target_path, row.names = FALSE, col.names = FALSE, sep = ",")
# Call python script
system(paste('python3 transferData.py', file_name))