How to build jar files for apertium translation pairs - jar

I am new to apertium. When I tried to generate the jar file for the language pair it gives the following error.
apertium#ap-vbox:~/lttoolbox/lttoolbox-java$ ./apertium-pack-j
/home/apertium/apertium-trunk/apertium-svn/apertium-ca-it1/modes/ca-it.mode
cp: cannot stat
''\''/home/apertium/apertium-trunk/apertium-svn/apertium-ca-it1/ca-it.automorf.bin'\''':
No such file or directory zip warning: name not matched:
data/ca-it.automorf.bin'
But these files are present in the specified path.
Can you please help me to resolve this error?

Related

renaming a 7zip extracted folder error Access i denied R

I extracted a TxtinOut named folder using the following cmd in R
shell('7z x D:/Region02/test.7z -oD:/Region02 -r -y')
I want to rename this folder TxtinOut to New_Name. I tried file.rename() but faced an ERROR: reason 'Access is denied'
file.rename("D:\\Region02\\TxtinOut", "D:\\Region02\\New_Name")
Can anyone suggest how I can proceed?
Make sure you are in the right directory setwd("right directory") and that the files exist which you can check by using list.files or file.exists. You can use this code to rename your file:
from <- c("TxtinOut")
to <- c("New_Name")
file.rename(from, to)

Set wd in RStudio

I am creating a series of r scripts that will be used by multiple people, meaning that the working directory of files used and stored will differ. There are two folders, one for the R code, called "rcode," and another to store the generated outputs, called "data". These two folders will always be shared in tandem. To accommodate for the changing working directory I created a "global" script that has the following lines of code and resides in the "rcode" folder:
source_path = rstudioapi::getActiveDocumentContext()$path
setwd(dirname(source_path))
swd_data <- paste0("..\\data\\")
The first line gets the source path of the global script. The second line makes this the working directory. The third line essentially tells the script to store an output in the "data" folder, which has the same path as the "rcode" folder. So to read in a csv file within the "data" folder I write:
old_total_demand <- read.csv(paste0(swd_data, "boerne_total_demand.csv"))
When I use this script on my Windows laptop it works beautifully, but when I use it on my Mac I get the following error:
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
cannot open file '..\data\demand\boerne_total_demand.csv': No such file or directory
Would anyone have any idea why this would be? Thanks in advance for the help.
I'm not sure what systems your collaborators will be using, but you may run into issues due to differences between Window/Mac/Linux with regards to how paths are written. I suggest you create a R Project .Rprj using RStudio and save that in your directory that contains subdirectories for data and rcode, and share the entire project directory.
/Project_dir/MyProject.Rprj
/Project_dir/data/
/Project_dir/rcode/
Then from the R project opened through RStudio you should be able to directly refer to your data by:
data <- read.csv("data/boerne_total_demand.csv")
The working directory will always be where your .Rproj is stored, so you can avoid having to setwd as it causes lots of chaos when sharing and collaborating with others.
I have this code from my current script at hand.
I hope you like it !
path <- dirname(getActiveDocumentContext()$path)
setwd(path)
swd_path <- paste0(path,"/data/")
if(!dir.exists(swd_path)){
dir.create(swd_path)
}
old_total_demand <- read.csv(paste0(swd_data, "boerne_total_demand.csv"))

importing a CSV file

I just started learning R which is my first programming language. I tried importing a CSV file from my system which is on my downloads in my computer using:
getwd()
setwd("/downloads")
statesInfo <- read.csv('stateData.csv')
But i keep getting the error message below.
setwd("/downloads")
Error in setwd("/downloads") : cannot change working directory
statesInfo <- read.csv('stateData.csv')
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
cannot open file 'stateData.csv': No such file or directory.
Could I be getting it wrong.
R is unable to recognize the directory that you're referring to and that's why you get the first error.
The working directory remains unchanged and R can not find the file stateData.csv in the current working directory which results in the second error message.
For setting a working directory use the full path instead: setwd("C:/Users/yourname/Downloads/") - notice the forward slash instead of the back-slash.
However, If you're only importing files, you do not need to change your working directory every time. You can simply refer to files in other locations. If you're using windows - you will need to use ./ for sub-folders and ../ for folders that are one level up. For example. if your working directory is set to 'C:/Users/yourname/Desktop/R' and you want to read a file from the 'Downloads' folder, simply use the below code:
dat <- read.csv("../../Downloads/stateData.csv")
the first ../ takes you one level up to the 'Desktop' and the second ../ takes you to 'Users'. From there you are referring to 'Downloads' folder where the stateData.csv file is located.
EDIT
The above works for Windows isntallations, for Mac/others you would have to use the tilda notation: e.g. ~/Desktop
So, it should be like this.
setwd("c:/mydir")
Also.
MyData <- read.csv(file="c:/mydir/TheDataIWantToReadIn.csv", header=TRUE, sep=",")

R error when using untar

I'm running a script with input parameters that are referenced in the code to automate the directory creation, download of file and untar of file. I would be fine with unzip, however this particular file I want to analyze is .tar.gz. I manually unpacked and it was tar.gz, unpacked to .tar file. Would that be the problem?
Full error: Error in untar2(tarfile, files, list, exdir) : unsupported entry type ‘’
Running Windows 10, 64 bit, R set to: [Default] [64-bit] C:\Program Files\R\R-3.2.2
Script notes one solution found (issues, lines 28-31), but I don't really understand it.
I did install 7-zip on my computer, restart and of course restart R:
`#DOWNLOADING AND UNZIPPING TAR FILE
#load required packages.
#If there is a load package error, use install.packages("[package]")
library(dplyr)
library(lubridate)
library(XML) # HTML processing
options(stringsAsFactors = FALSE)
#Set directory locations, data file and fetch data file from internet
#enter full url including file name between ' ' marks
mainDir<-"C:/R/BEES/"
subDir<-"C:/R/BEES/Killers"
Fetch<-'http://dds.cr.usgs.gov/pub/data/nationalatlas/afrbeep020_nt00218.tar.gz'
ArchFile<-basename(Fetch)
download.file<-(ArchFile)
#Check for file directories and create if directory if it doesn't exist
if(!file.exists(mainDir)){dir.create(mainDir)}
if(!file.exists(subDir)){dir.create(subDir)}
#set the working directory
setwd(file.path(subDir))
#check if file exists and download if it doesn't exist.
if(!file.exists(ArchFile))
{download.file (url=Fetch,destfile=ArchFile,method='auto')}
#unpack and view file list
untar(path.expand(ArchFile),list=TRUE,exdir=subDir,compressed="gzip")
list.files(subDir)
#Error: Error in untar2(tarfile, files, list, exdir) :
# unsupported entry type ‘’
#Need solution to use tar/untar app
#instructions here: https://stevemosher.wordpress.com/step-10-build/`
Appreciate feedback - I've been lurking around StackOverflow for some time to use other people's solutions.

SCons Binary Directory

How is the binary/executable directory specified in SCons? It's easy to do as follows:
Program( target = 'bin/helloworld', source = 'src/helloworld.cc' )
The problem with this approach is when trying to do cross-platform builds. Here's an example that works:
StaticLibrary( target = 'helloworld', source = 'src/helloworldlib.cc' )
The output of this on a Unix system is a library named libhelloworld.a. An example where it doesn't work follows:
StaticLibrary( target = 'lib/helloworld', source = 'src/helloworldlib.cc' )
The output on a Unix system of this is a file helloworld.a in directory lib. This causes problems when LIBS is specified as ['helloworld'], which is the cross platform way to do it.
What is the parameter name to pass into StaticLibrary, SharedLibrary, and Program to output binaries into a directory other than the base directory?
The manual suggests that you use a variant directory and a SConscript file in the source directory. In your example, place a SConscript file in the src directory:
StaticLibrary(target="helloworld", source="helloworldlib.cc")
and call that from the main SConstruct file:
SConscript("src/SConscript", variant_dir="lib")

Resources