Stanford Parser using command line - command-line

I am new to using the Stanford Parser. I would like to use the command line to receive the typed dependencies. I changed the directory in cmd to the file where the Stanford Parser- files are and then used the following command:
C:\...directory...\java -cp stanford-parser.jar edu.stanford.nlp.parser.lexparser.LexializedParser -outputFormat "typedDependencies" englishPCFG.ser.gz input.txt
input.txt is in the same Stanford-Parser file. But the I get the following exception:
Loading parser from serialized file englishPCFG.ser.gz...
java.io.IOException: Unable to resolve "englishPCFG.ser.gz" as either class path, filename or URL
I tries some Syntax-modifications like brackets but it didn't work. Does anybody have an idea?
SOLVED:
java -cp C:\stanford-parser.jar; stanford-parser-3.2.0-models.jar edu.stanford.nlp.parser.lexparser.LexicalizedParser -outputFormat "typedDependencies" edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz .txt

Related

Exception in thread "main" java.io.FileNotFoundException: t.txt (No such file or directory)

I wrote a scala script named updateTables.scala and created a .txt file named t.txtunder the directory com/sk/data in IntelliJ IDEA. One clause in updateTables.scala tries to read t.txt:val wholeQuery = Source.fromFile("t.txt").
I use mvn clean package in Windows PowerShell to obtain a jar package from the project SparkScalaExample and then use spark-submit to execute the jar package. But error FileNotFoundException is thrown out.
I have tried various paths of t.txt, such as
absolute path D:\SparkScalaExample\src\main\scala\com\sk\data\t.txt,
path from content root src/main/scala/com/sk/data/t.txt,
path from source root com/sk/data/t.txt, but none of them works. Put t.txt under SparkScalaExample doesn't work either.
The following picture is the directory structure of project SparkScalaExample.
So, where should I put t.txt and which path of t.txt should I use?
Thanks very much for your help!
Because I run spark-submit on a server, If I want to read file t.txt by Source.fromFile, two requirements have to be met:
t.txt has to be in the server;
the path of t.txt in Source.fromFile has to be where it is located.
After meeting the two requirements, it works!

Apache Spark Multiple sources found for csv Error

I'm trying to run my spark program using the spark-submit command (i'm working with scala), i specified the master adress, the class name, the jar file with all dependencies, the input file and then the output file but i'm having and error:
Exception in thread "main" org.apache.spark.sql.AnalysisException:
Multiple sources found for csv
(org.apache.spark.sql.execution.datasources.v2.csv.CSVDataSourceV2,
org.apache.spark.sql.execution.datasources.csv.CSVFileFormat), please
specify the fully qualified class name.;
Here is a screenshot for this error, What is it about? How can i fix it?
Thank you
Here you got some warnings also,
If you correctly run your fat-jar file with correct permissions you can get a output like this for ./spark-submit
Check whether if correctly set environmental variables for spark (~/.bashrc). Also check the source CSV file permissions. May be it will be the problem.
If you are running on linux environment set the folder permissions for the source CSV folder as
sudo chmod -R 777 /source_folder
After that again try to run ./spark-submit with your fat-jar file.

Encrypt a PDF file in the command line using pdftk command

i am tiring to perform PDF file encryption using pdftk and installed the dependency modules of PDF::Tk [Perl integration for the pdf toolkit (pdftk)] , but getting error as mentioned below. Can any one please help me in resolving the below issue.
Source code: test.pl
use PDF::Tk;
system(pdftk input.pdf output outPDF.pdf owner_pw foopass) or die "Error!!!!!!!!!!\n";
output:
Can't locate object method "pdftk" via package "input" (perhaps you forgot to load "input"?) at test.pl line 2.
use PDF::Tk module functions instead the system. PDF::Tk is a wrapper over the pdftk utility, so using system is the topic it avoids:
use PDF::Tk;
my $doc=PDF::Tk->new();
$doc->call_pdftk('input.pdf', 'outPDF.pdf', 'owner_pw', 'foopass');
Note: The PDF::Tk constructor could be used to set the pdftk binary. It defaults value is "/usr/bin/pdftk"
my $doc=PDF::Tk->new({pdftk=>'/other/path/to/bin/pdftk'});

Difference between calling command line directly or from makefile

I have a confusing problem concerning mingw make and windows command line (Win7):
I have a makefile which shall call a vbs file to convert .vds files to .png files. here is the code of the makefile (without the defined variables, you can see the result in the picture below).
VSD2PNG: $(VISIO_OUTPUT)
#echo *** converting visio files to png files finished
define vsd_rule
$(1): $(call FILTER_FUNCTION,$(basename $(notdir $(1))),$(VISIO_FILES))
$(VSD_SCRIPT) $$< $(VISIO_OUTPUT_DIR)
endef
$(foreach file,$(VISIO_OUTPUT),$(eval $(call vsd_rule,$(file))))
leads to
As you can see, the command should call .\tools\visio\convert(.vbs) with two arguments (input file & output directory). Surprising is that the same command executed in windows command line works fine. I tried some modifications to solve the problem (unsuccessfully):
adding file extension to vbs-script leads to error 193, but I cannot find out, what that means.
calling the script without any arguments should lead to a runtime-error in the script, but that leads to make error -1 again (or with file extension 193).
using absolute path for script
Does anybody know more about the differences between calling a script directly from command line or from makefile, which should usually lead to the command line?

Executing the FOP command line as batch from Perl

I am converting XML to PDF using Apache. I am executing the FOP command line as batch file( since the input file will be vary) from Perl as like below:
Creating Batch file:
open (OUT2, '>', 'c:\test\fop-1.0\run.bat');
print OUT2 "cd\\\ncd c:\\test\\fop-1\.0\\\n C:\\test\\fop-1\.0\\fop\.bat -c C:\\test\\fop-1\.0\\conf\\fop-config\.xml -xsl C:\\test\\fop-1\.0\\test.xsl -xml c:\test\document2.xml -pdf c:\test\document2.pdf";
close (OUT2);
Executing batch file using system command:
$cmd2 ="c:\\test\\fop-1.0\\test.bat";
system("$cmd2");
I am embedding the svg files in the fop. I am getting the output when I run batch file manually, but by executing from perl I am getting the following error:
org.apache.fop.image.loader.batik.PreloaderSVG$Loader ge...
Can anyone help me to resolve this problem?
Try something like
system "cmd","/c","c:\\test\\fop-1.0\\test.bat";