I don't know for sure - how about you post the error-message? Otherwise we
can't assess the problem.
Diez- Hide quoted text -
- Show quoted text -
Hi,
What i did was create a python file as:
import nltk
from java.util import Random
class NLPPresentation(Random):
def nextDouble(self):
return 1
def TagByBrown(self,sent):
"@sig public String[] TagByBrown(String sent)"
brown_a = nltk.corpus.brown.tagged_sents(categories='a')
bigram_tagger = nltk.BigramTagger(brown_a, cutoff=0)
lst = bigram_tagger.tag(sent.split())
return lst
I processed the following code through jythonc compiler to form a JAR
file. I then imported this jar
file into java ide (Java Builder). I then wrote the following program
in java to access this python class:
import org.python.core.PyException;
import org.python.core.PyInteger;
import org.python.core.PyObject;
import org.python.util.PythonInterpreter;
import java.util.Random;
import org.nltk.*;
import org.nltk.mallet.*;
public class SimpleEmbedded extends NLPPresentation{
public static void main(String[] args) throws PyException {
SimpleEmbedded so = new SimpleEmbedded();
String s = "he is a boy";
so.Call(s);
}
public void Call(String s)
{
String[] arr = TagByBrown(s);
System.out.println(arr[1]);
}
}
When i compile the above java code, i get the following error:
Exception in thread "main" Traceback (innermost last):
File "C:\jython2.2.1\NLPPresentation.py", line 0, in main
ImportError: no module named nltk
Your comments are highly appreciated.