Forums

Calling NLTK-related JAVA jar file from Pythonanywhere code

Hi,

First, a brief background: I am using Python and NLTK to develop a program to detect certain English grammar errors. The Part-Of-Speech (POS) tagger that I am forced to use is Stanford POS tagger (Java-based impelmentation).

Second, the issue: Whenever I tried to specify the jar file path using the folloiwng: model_path = '~/home/rawia/stanford-postagger/models/english-bidirectional-distsim.tagger' jar_path = '~/home/rawia/stanford-postagger/stanford-postagger.jar' tagger = nltk.tag.stanford.POSTagger(model_path, jar_path)

The following error message appears: "Could not find stanford-postagger.jar jar file at ~/home/rawia/stanford-postagger/stanford-postagger.jar"

Now, to my concern: I tried to look for answers in the forum. Then, I came to know that PythonAnwhere does not support Java. Is this the reason of the error I am facing?? If no, could you please help me in identifying where is the problm? If yes, is there Python hosting options that can support Java?

Thanks in advance, Rawia

Hi Rawia!

First things first, I'm afraid we don't support Java right now. It's on the list and I've added an upvote (though I appreciate that doesn't help much right now).

Secondly, something that is probably irrelevant in the light of the lack of Java -- the character ~ in a path represents your home directory, /home/rawia/. So when you write

model_path = '~/home/rawia/stanford-postagger/models/english-bidirectional-distsim.tagger'

...and so on, you probably should have

model_path = '/home/rawia/stanford-postagger/models/english-bidirectional-distsim.tagger'

without the ~.

Is there any broad guess about when Java might be supported? Within a year? Thanks!

Within a year sounds very likely indeed, but I can't promise.

Thanks, Giles.