I'm trying to parse sentence with Malt Parser in NLTK. When I did raw_parse(sent) it gave an error with exit code 1. I executed java command on terminal and it gives class Not Found exception, I don't understand what is wrong now?
java -Xmx1024m -jar /usr/local/bin/malt.jar -w /home/abc/maltparser-1.7.2 -c engmalt.linear-1.7 -i /home/abc/maltparser-1.7.2/malt_input.conllrPZgwc -o /home/abc/maltparser-1.7.2/malt_output.conllDMSKpg -m parse
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Layout
Your working directory is not correctly set. Log4j is a package used by Malt Parser (see: maltparser-1.7.2/lib/log4j.jar). Which is used for logging logically.
In order to run maltparser in NLTK, the working directory should be set to this folder (in your case: /home/abc/maltparser-1.7.2).
So, step one is getting the latest NLTK from git:
git clone https://github.com/nltk/nltk.git
Install NLTK:
sudo python setup.py install
To run Malt Parser using NLTK try this code example:
import os
import nltk
os.environ['MALTPARSERHOME']="/home/abc/maltparser-1.7.2"
verbose = False
maltParser = nltk.parse.malt.MaltParser(working_dir="/home/abc/maltparser-1.7.2",
mco="engmalt.linear-1.7",
additional_java_args=['-Xmx512m'])
print(maltParser.raw_parse('This is a test sentence', verbose=verbose).tree().pprint())
As you may notice I'm using the pre-learned mco file (engmalt.linear-1.7), which can be downloaded from here:
http://www.maltparser.org/mco/english_parser/engmalt.html
Move this mco file to: /home/abc/maltparser-1.7.2 directory.
Finally NLTK only except malt.jar. So create a copy (or rename):
cp maltparser-1.7.2.jar malt.jar
Which can still be located in your /home/abc/maltparser-1.7.2.jar directory.
Hopefully you'll get it running!
Related
I'm really new to maven and storm so I'm trying to follow the instructions in https://github.com/apache/storm/tree/master/examples/storm-starter. My current path is /home/luc/theTest/storm/examples/storm-starter. Inside the target folder there is a storm-starter-2.0.0-SNAPSHOT.jar file. I'm getting stuck when running
storm jar target/storm-starter-*.jar org.apache.storm.starter.ExclamationTopology -local
I get this error
ionTopology -local
Running: /usr/lib/jvm/java-8-openjdk-amd64/bin/java -client -Ddaemon.name= -Dstorm.options= -Dstorm.home=/home/luc/stormTest/apache-storm-1.1.1 -Dstorm.log.dir=/home/luc/stormTest/apache-storm-1.1.1/logs -Djava.library.path=/usr/local/lib:/opt/local/lib:/usr/lib -Dstorm.conf.file= -cp /home/luc/stormTest/apache-storm-1.1.1/lib/servlet-api-2.5.jar:/home/luc/stormTest/apache-storm-1.1.1/lib/slf4j-api-1.7.21.jar:/home/luc/stormTest/apache-storm-1.1.1/lib/objenesis-2.1.jar:/home/luc/stormTest/apache-storm-1.1.1/lib/kryo-3.0.3.jar:/home/luc/stormTest/apache-storm-1.1.1/lib/log4j-core-2.8.2.jar:/home/luc/stormTest/apache-storm-1.1.1/lib/log4j-over-slf4j-1.6.6.jar:/home/luc/stormTest/apache-storm-1.1.1/lib/storm-core-1.1.1.jar:/home/luc/stormTest/apache-storm-1.1.1/lib/log4j-slf4j-impl-2.8.2.jar:/home/luc/stormTest/apache-storm-1.1.1/lib/minlog-1.3.0.jar:/home/luc/stormTest/apache-storm-1.1.1/lib/log4j-api-2.8.2.jar:/home/luc/stormTest/apache-storm-1.1.1/lib/clojure-1.7.0.jar:/home/luc/stormTest/apache-storm-1.1.1/lib/ring-cors-0.1.5.jar:/home/luc/stormTest/apache-storm-1.1.1/lib/asm-5.0.3.jar:/home/luc/stormTest/apache-storm-1.1.1/lib/reflectasm-1.10.1.jar:/home/luc/stormTest/apache-storm-1.1.1/lib/disruptor-3.3.2.jar:/home/luc/stormTest/apache-storm-1.1.1/lib/storm-rename-hack-1.1.1.jar:target/storm-starter-2.0.0-SNAPSHOT.jar:/home/luc/stormTest/apache-storm-1.1.1/conf:/home/luc/stormTest/apache-storm-1.1.1/bin -Dstorm.jar=target/storm-starter-2.0.0-SNAPSHOT.jar -Dstorm.dependency.jars= -Dstorm.dependency.artifacts={} org.apache.storm.starter.ExclamationTopology -local
Error: Could not find or load main class org.apache.storm.starter.ExclamationTopology
Am I doing something wrong? I'm also a bit confused on whether I have to run the nimbus and supervisor first. I tried with and without them and neither worked anyways. Been searching the web but nothing works. Not sure what else to try.
This is usually caused by inconsistent versions of storm-client and storm-starter. Try following these steps to get the example working.
download the latest release from http://storm.apache.org/downloads.html
in this example, we will use version 1.1.1
extract this to a folder, lets call it ${STORM_HOME}
cd into ${STORM_HOME}/examples/storm-starter
execute mvn package -DskipTests=true
this should build the storm-starter jar in target folder
${STORM_HOME}/examples/storm-starter/target/storm-starter-1.1.1.jar
run the example from ${STORM_HOME} directory:
./bin/storm jar examples/storm-starter/target/storm-starter-1.1.1.jar org.apache.storm.starter.ExclamationTopology
don't add the -local flag since it seems like the ExclamationTopology is only deployed in a LocalCluster if no args are passed. You can check the source code here: ${STORM_HOME}/examples/storm-starter/src/jvm/org/apache/storm/starter/ExclamationTopology.java
I am trying to install Matlab on a Linux machine, but setting LD_LIBRARY_PATH (as the installation requires) breaks other library files. I am not an Linux expert, but I have tried several things and cannot get it working correctly. I have even contacted Matlab support, got the issue elevated to the dev team, and was basically told "haha sucks to suck". I have seen a few other people online have had the same issue, but either their questions were never answered or they had a slightly different problem and their solution didn't apply to me.
Installing on a VM running Ubuntu:
I set LD_LIBRARY_PATH as the instructions say, then it breaks network files. I can ping google.com, but I cannot nslookup google.com or visit it in a browser. Nslookup provides this error:
nslookup: /usr/local/MATLAB/MATLAB_Runtime/v90/bin/glnxa64/libcrypto.so.1.0.0: no version information available (required by /usr/lib/libdns.so.100)
03-Feb-2016 11:32:22.361 ENGINE_by_id failed (crypto failure)
03-Feb-2016 11:32:22.362 error:25070067:DSO support routines:DSO_load:could not load the shared library:dso_lib.c:244:
03-Feb-2016 11:32:22.363 error:260B6084:engine routines:DYNAMIC_LOAD:dso not found:eng_dyn.c:447:
03-Feb-2016 11:32:22.363 error:2606A074:engine routines:ENGINE_by_id:no such engine:eng_list.c:418:id=gost
(null): dst_lib_init: crypto failure
The installation worked though (I can run my Java programs that reference compiled Matlab functions). Unsetting LD_LIBRARY_PATH fixes the network files but then I can't run programs anymore.
Installing on EC2 instance:
On an EC2 instance it does not break the network files (nslookup is fine). Instead it messes up Python library files. Trying to use any aws cli command, I get the error:
File "/usr/bin/aws", line 19, in <module>
import awscli.clidriver
File "/usr/lib/python2.7/dist-packages/awscli/clidriver.py", line 16, in <module>
import botocore.session
File "/usr/lib/python2.7/dist-packages/botocore/session.py", line 25, in <module>
import botocore.config
File "/usr/lib/python2.7/dist-packages/botocore/config.py", line 18, in <module>
from botocore.compat import six
File "/usr/lib/python2.7/dist-packages/botocore/compat.py", line 139, in <module>
import xml.etree.cElementTree
File "/usr/lib64/python2.7/xml/etree/cElementTree.py", line 3, in <module>
from _elementtree import *
ImportError: PyCapsule_Import could not import module "pyexpat"
Printing sys.path in Python shows lib-dynload is already there though, so it doesn't seem to the problem.
And when trying to run the program, I get:
Exception in thread "main" java.lang.LinkageError: libXt.so.6: cannot open shared object file: No such file or directory
at com.mathworks.toolbox.javabuilder.internal.DynamicLibraryUtils.dlopen(Native Method)
at com.mathworks.toolbox.javabuilder.internal.DynamicLibraryUtils.loadLibraryAndBindNativeMethods(DynamicLibraryUtils.java:134)
at com.mathworks.toolbox.javabuilder.internal.MWMCR.<clinit>(MWMCR.java:1529)
at VectorAddExample.VectorAddExampleMCRFactory.newInstance(VectorAddExampleMCRFactory.java:48)
at VectorAddExample.VectorAddExampleMCRFactory.newInstance(VectorAddExampleMCRFactory.java:59)
at VectorAddExample.VectorAddClass.<init>(VectorAddClass.java:62)
at com.mypackage.Example.main(Example.java:13)
I'm at a brick wall and really have no clue how to proceed.
Maybe something else already needs LD_LIBRARY_PATH set to work. Make sure you prepend not overwrite:
export LD_LIBRARY_PATH=new/path:$LD_LIBRARY_PATH
Edit:
OK, if LD_LIBRARY_PATH was initially empty, this suggests that Matlab comes with shared libraries that are incompatible with your system ones:
nslookup: /usr/local/MATLAB/MATLAB_Runtime/v90/bin/glnxa64/libcrypto.so.1.0.0: no version information available (required by /usr/lib/libdns.so.100)
suggests that /usr/lib/libdns.so.100 needs libcrypto.so.1.0.0, which is now being resolved to the one that comes with MATLAB, which is incompatible.
You can check the dependencies of a dll by
ldd /usr/lib/libcrypto.so.1.0.0
and hopefully you can find a configuration that keeps both MATLAB and your system happy. Unfortunately, this may involve a lot of trial and error.
If there is no such configuration, you can try setting LD_LIBRARY_PATH only when you run MATLAB:
LD_LIBRARY_PATH=$MATLAB_LD_LIBRARY_PATH matlab
Edit 2:
Well, for the Python issue, it seems to boil down to pyexpat, which is a wrapper around the standard expat XML parser. Try doing (name guessed since I don't have a Linux right now):
ldd /usr/local/lib/python2.7/site-packages/libpyexpat.so
and see what that depends on. Probably, it will be libexpat.so, which is now being resolved to MATLAB's version.
try the following command:
export LD_LIBRARY_PATH=/usr/local/MATLAB/MATLAB_Runtime/v90/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v90/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v90/sys/os/glnxa64:$LD_LIBRARY_PATH
Perhaps not helpful for OP but if you are generating a python package with MATLAB, you could modify the generated __init__.py file MATLAB creates for your package.
Specifically, the generated __init__.py file contains the following line (as of MATLAB 2017a):
PLATFORM_DICT = {'Windows': ['PATH','dll',''], 'Linux': ['LD_LIBRARY_PATH','so','libmw'], 'Darwin': ['DYMCR_LIBRARY_PATH','dylib','libmw']}
For Linux platform, you could simply replace LD_LIBRARY_PATH with something else such as MCR_LIBRARY_PATH to prevent mucking with your shared libs.
sed -i -e 's/LD_LIBRARY_PATH/MCR_LIBRARY_PATH/g' /MY/PACKAGE/BUILD/PATH/__init__.py
Then obviously export MCR_LIBRARY_PATH before using python.
I've to "compile" compass files dynamically in my java soft'. So, following explications found on stackoverflow, I've done these steps :
Get JRuby (1.7.3), configure PATH to jruby.jar and binaries (gem, rake ...) and learn to launch ruby script from Java
Get compass and dependancies gems into a local directory, using following command line
gem install -i ./compass compass
=> So I get a directory ./compass/ containing bin, cache,doc, gems & specifications directories.
Put gems in a jar using following command line (think to use a jar name which is not the same as the gems, to avoid JRuby "require" the jar instead of the gems)
jar cf compass-lib.jar -C compass .
Write a test script test.rb in local directory to test my jar. It contains :
require 'compass'
Compass.add_configuration(
{
:project_path => '.',
:sass_path => 'styles/scss',
:css_path => 'styles/css'
},
'custom' # A name for the configuration, can be anything you want
)
Compass.compiler.compile('test.scss', 'test.css')
Execute this script with JRuby, with following command line :
jruby -I . -rcompass-lib.jar test.rb
And get this error ...
Unable to load Sass. Please install it with one of the following commands:
gem install sass --pre
LoadError: no such file to load -- jar:file:C:/jruby-1.7.3/lib/jruby.jar!/gems/s
ass-3.2.8/lib/sass/../sass
require at org/jruby/RubyKernel.java:1027
require at c:/jruby-1.7.3/lib/ruby/shared/rubygems/custom_require.rb:36
(root) at jar:file:C:/jruby-1.7.3/lib/jruby.jar!/gems/sass-3.2.8/lib/sass/ver
sion.rb:5
require at org/jruby/RubyKernel.java:1027
(root) at c:/jruby-1.7.3/lib/ruby/shared/rubygems/custom_require.rb:1
require at c:/jruby-1.7.3/lib/ruby/shared/rubygems/custom_require.rb:36
require at org/jruby/RubyKernel.java:1027
(root) at jar:file:C:/jruby-1.7.3/lib/jruby.jar!/gems/sass-3.2.8/lib/sass.rb:
9
(root) at c:/jruby-1.7.3/lib/ruby/shared/rubygems/custom_require.rb:1
require at org/jruby/RubyKernel.java:1027
require at c:/jruby-1.7.3/lib/ruby/shared/rubygems/custom_require.rb:60
(root) at jar:file:C:/jruby-1.7.3/lib/jruby.jar!/gems/compass-0.12.2/lib/comp
ass/dependencies.rb:6
each at org/jruby/RubyArray.java:1613
(root) at c:/jruby-1.7.3/lib/ruby/shared/rubygems/custom_require.rb:1
require at org/jruby/RubyKernel.java:1027
require at c:/jruby-1.7.3/lib/ruby/shared/rubygems/custom_require.rb:36
(root) at test.rb:1
An idea of the problem and, maybe, of solution ? ;) Thanks by advance.
[UPDATE #1]
After Jörg W Mittag obvious suggestion, the error disapear. Thanks ;) Now, it just don't find the scss file, so it's a "normal problem" ;)
[UPDATE #2]
Having used compass with success in IRB, it's time to transpose the test through Java. So, I wrote some lines in Java to execute my ruby script, using only absolute path to avoid problems in a first time.
InputStream myFile = ISRessources.getFile("C:/Path/To/My/test.rb");
new ScriptingContainer().runScriptlet(myFile, "test.rb");
But ... how to "load" my compass-lib.jar ? What's the equivalent of the -r in JRuby ? I've tried to includ gems into jruby.jar, to add compass-lib.jar in externals jars in java build path, but both don't work, I still have :
LoadError: no such file to load -- compass
require at org/jruby/RubyKernel.java:1027
(root) at test.rb:1
Any idea ?
The error message says:
Unable to load Sass. Please install it with one of the following commands:
gem install sass --pre
I have an Jar file that is working perfectly fine on my Mac using console:
MacBook-Pro-Pavel:PDFparser pavelpigalev$ java -jar PDFparser.jar
Usage: java PDFparser <input-pdf> -p1 <password> -c1 -i0 -s1
-p1 : PDF password
-c1 : write JSON to console
-i0 : don't extract images
-s1 : take page screenshots [WARNING: currently in beta]
MacBook-Pro-Pavel:PDFparser pavelpigalev$ java -jar PDFparser.jar f5.pdf
MacBook-Pro-Pavel:PDFparser pavelpigalev$
It creates a folder and puts out images that I need in that folder.
But if I use it on the web server (also using console) it gives me this error:
[root#somesite.com pdfparser]$ ls
ffive.pdf lib PDFparser.jar README.TXT
[root#somesite.com pdfparser]$ java -jar "PDFparser.jar"
Usage: java PDFparser <input-pdf> -p1 <password> -c1 -i0 -s1
-p1 : PDF password
-c1 : write JSON to console
-i0 : don't extract images
-s1 : take page screenshots [WARNING: currently in beta]
[root#somesite.com pdfparser]$ java -jar "PDFparser.jar" ffive.pdf
Exception in thread "main" java.lang.ClassNotFoundException: javax.vecmath.Vector2d not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:PDFparser.jar], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
at java.net.URLClassLoader.findClass(libgcj.so.10)
at java.lang.ClassLoader.loadClass(libgcj.so.10)
at java.lang.ClassLoader.loadClass(libgcj.so.10)
at java.lang.reflect.Field.getType(libgcj.so.10)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.excludeField(ReflectiveTypeAdapterFactory.java:56)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:111)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:72)
at com.google.gson.Gson.getAdapter(Gson.java:353)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory.create(CollectionTypeAdapterFactory.java:52)
at com.google.gson.Gson.getAdapter(Gson.java:353)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.<init>(ReflectiveTypeAdapterFactory.java:82)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:81)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:118)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:72)
at com.google.gson.Gson.getAdapter(Gson.java:353)
at com.google.gson.Gson.toJson(Gson.java:578)
at com.google.gson.Gson.toJson(Gson.java:565)
at com.google.gson.Gson.toJson(Gson.java:520)
at com.google.gson.Gson.toJson(Gson.java:500)
at pdfparser.PDFparser.main(PDFparser.java:163)
I didn't make this Jar file, I don't really know much about Java. I work with PHP and I really need this program working well on server. Can someone help me with that?
Place vechmath .jar in your class path
Or - Add your supporting .jars to the classpath
export CLASSPATH=$CLASSPATH:/path/to/vecmath.jar
Or - Supply at the Runtime
java -cp vecmath-xxx.jar -jar Yourjar.jar
Importance of Classpath
You're not using the same JVM that the one in your macbook. You're using GNU JVM as seen in not found in gnu.gcj.runtime.SystemClassLoader
Try a java -version to confim that and then change your JVM
Try to find vecmath-1.3.1.jar file on you Mac and place it in the same dir as PDFparser.jar is located. Try to run. If no success then try to run as follow:
java -cp vecmath-1.3.1.jar -jar "PDFparser.jar"
Has anyone played around with the CCNx code over from http://www.ccnx.org/.
I unzip the project and loading the .project file in the javasrc directory into Eclipse. The project builds with no errors.
I'm guess I need to start the CCNDaemon (org.ccnx.ccn.impl.support.CCNDaemon) but I get an error at:
java.io.IOException: Cannot run program "../ccnd/agent/ccnd": error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
at org.ccnx.ccn.impl.support.CCNDaemon$CCNDWorkerThread.initialize(CCNDaemon.java:93)
at org.ccnx.ccn.impl.support.Daemon$WorkerThread.run(Daemon.java:125)
It looks like its trying to build a new process with
private static final String DEFAULT_CCND_COMMAND_STRING = "../ccnd/agent/ccnd";
protected String _command = DEFAULT_CCND_COMMAND_STRING;
...
ProcessBuilder pb = new ProcessBuilder(_command);
I don't have the ccnd operating system process. Do I need to build the C++ code? Or is there some way to run this with pure java? Thanks for the help!
Based on my findings, it turns out that all CCN applications require a CCNx Daemon. This is only based in C right now. So you have to build the C code with all the dependencies. The Java code actually calls the ccnd (CCN Daemon) to run with the ProcessBuilder.
I wrote up a blog post about how I got it to work for Ubuntu... but its basically.
C Source Dependencies:
sudo apt-get install git-core python-dev libssl-dev libpcap-dev libexpat1-dev athena-jot
Run:
./configure
Build CCN with:
make
Test with:
make test
Start the ccnd:
ccndstart
The blog post has more details.
If you add -start in the arguments block in the "Run configuration" dialog in Eclipse before you run the CCNDaemon, there should be no errors.
————————————————————————————————————————————
2011-10-5 19:49:39 org.ccnx.ccn.impl.support.Daemon startDaemon
信息: Starting daemon with command line: java -Djava.library.path=.:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java -cp /Users/thomas/Downloads/ccnx-0.4.1/javasrc /bin:/Applications/eclipse/plugins/org.junit_4.8.2.v4_8_2_v20110321-1705/junit.jar:/Applications/eclipse/plugins/org.hamcrest.core_1.1.0.v20090501071000.jar:/Users/thomas/Downloads/ccnx-0.4.1/javasrc/lib/bcprov-jdk16-143.jar:/Users/thomas/Downloads/ccnx-0.4.1/javasrc/lib/junit-4.3.1.jar:/Users/thomas/Downloads/ccnx-0.4.1/javasrc/lib/kxml2-2.3.0.jar org.ccnx.ccn.impl.support.CCNDaemon -daemon
Started daemon ccnd. PID 3127
2011-10-5 19:49:40 org.ccnx.ccn.impl.support.Daemon startDaemon
信息: Started daemon ccnd. PID 3127
——————————————————————————————————————————————————————————————————————————
(blank lines introduced for clarity)