Hi Jinseung

Jython itself is a java program so if you are running it successfully it is finding the system libraries (like java.lang.* and java.util.*). Your example from earlier, java.lang.System, is a standard system class, and will be available in something like rt.jar, which doesn't need to be explicitly added to the classpath. Though you may have the source unpacked somewhere, it's not loading it from there at runtime - it's using rt.jar.

Happy scripting with Jython. You should find that Java tutorial posted earlier useful too.


From: Jinseung Eu <jinseung.eu@ling-phil.ox.ac.uk>
To: Don Coleman <don.coleman@gmail.com>; jython-users@lists.sourceforge.net
Sent: Monday, 16 March, 2009 4:48:42 AM
Subject: Re: [Jython-users] Trouble using Stanford parser with Jython

Thanks, Coleman.

You really helped me and now it works. The problem was that I didn't provide the full path for the .jar file. When I initially added that file to sys.path successfully, I just assumed that it was being accessed all right, but this was wrong. I didn't know that you can even add a non-existent file to the path.

Anyway, may I ask another question? Why is it that I need a .jar file for the Stanford parser while I can access other built-in Java classes without it, just by specifying the directory path and class name (which is in .java format)?

I would like to add points to your reputation on this site, but I din't know how to do that. I would appreciate if you can tell me how.

Thank you very much.

Don Coleman 쓴 글:
You need standford-parser.jar in the classpath, not stanford-parser-2008/src.

Jython won't compile Java source.

The stanford-parser-2008 folder does not need to be inside the
jython-2.2.1 directory

Here's the steps I followed

$ curl -O http://www-nlp.stanford.edu/downloads/stanford-parser-2008-10-26.tgz Untar $ tar xzf stanford-parser-2008-10-26.tgz Change to the directory with the parser $ cd stanford-parser-2008-10-26 Check the make sure the parser works $ ./lexparser.csh testsent.txt Try in jython $ jython Jython 2.2.1 on java1.6.0_07 Type "copyright", "credits" or "license" for more information.
import sys
from edu.stanford.nlp.parser import Parser
This assumes that stanford-parser.jar is in the same directory where
you start Jython. If inot, enter the full path to
There is a build.xml script in stanford-parser-2008-10-26.  If you
have apache ant installed, you can build the code by typing "ant".
Then you can add the directory with the compiled classes instead of
On Sun, Mar 15, 2009 at 7:56 AM, Jinseung Eu
<jinseung.eu@ling-phil.ox.ac.uk> wrote:

I am having a trouble using a program called Stanford Parser 1.6.1 (To unzip
it, you may have to unzip it twice):

I have posted several messages but have not received a full solution. So I
am posting it again with all updates.

I renamed the unzipped folder as "stanford-parser-2008" and put it inside
the jython 2.2.1 folder and added the path as follows:

import sys

Then I accessed the following packages within src, and this worked:
import edu.stanford.nlp.parser

But when I try to access a class within it I get an error:

import edu.stanford.nlp.parser.Parser
Traceback ...
File "<console>"....
ImportError: no module named Parser

from edu.stanford.nlp.parser import Parser
Traceback ...
File "<console>"....
ImportError: cannot import name Parser

This problem was encountered by someone else two years ago
Here Charlie resolves the issue by adding "stanford-parser.jar" to sys.path.
--> But this doesn't work for me. I don't know why. Do I need to put the
unzipped folder somewhere else?

Below, Jeff suggests I need to compile the "Parser.java" file to
"Parser.class" file.
--> I tried the compilation but failed (Perhaps I put the file in the wrong
place for compilation, or the file is not meant to be compiled).
--> Also I am not entirely convinced that a .class file is necessary here.
Jython can import .java files like System.java (in java.lang) and
Random.java (in java.util). Then, why do I have to have a .class file for
the Stanford parser? /

Can someone please help me get solve this puzzle?
Thanks a lot.

Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com _______________________________________________ Jython-users mailing list Jython-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jython-users

Stay connected to the people that matter most with a smarter inbox. Take a look.