opus-data/OpusData.R

28 lines
721 B
R
Raw Normal View History

#!/usr/bin/env Rscript
2021-01-19 11:09:12 +01:00
# Attach package to workspace, execute with every new session
2021-01-27 15:49:11 +01:00
source("ReadOpus.R")
2021-01-19 11:09:12 +01:00
2021-01-19 14:26:16 +01:00
# Determine file path
2021-01-21 10:32:13 +01:00
path <- paste(getwd(), "/OPUS/", sep = "")
2021-01-28 08:29:01 +01:00
file_name <- commandArgs(trailingOnly = TRUE)[1]
2021-01-19 14:26:16 +01:00
file_path <- paste(path, file_name, sep = "")
2021-01-27 15:49:11 +01:00
# Convert opus binary file into dataframe
2021-02-08 18:21:39 +01:00
data <- read_opus_univ(file_path, 5)
2021-01-19 14:26:16 +01:00
# Set working directory to path where the result file should appear
2021-01-28 08:29:01 +01:00
setwd(paste(path, "../DPT", sep = ""))
2021-01-15 15:39:19 +01:00
2021-01-19 11:09:12 +01:00
# Replace last "." with "_", add ".DPT" and create file
file_name <- paste(sub(".([^.]*)$", "_\\1", file_name), ".DPT", sep = "")
file.create(file_name)
# Fill file with dataframe
2021-01-27 15:49:11 +01:00
write.table(data, file_name, row.names = FALSE, col.names = FALSE, sep = ",")
2021-01-15 15:39:19 +01:00
2021-01-19 14:26:16 +01:00