Question

I got the terminal to work with SenseRelate::AllWords, with this command:

wsd.pl --context test.txt --format raw --

However, now I'm trying to run wsd.pl from my Java code, it looks like this:

public static void main(String args[] ) throws IOException {
        String line;
        ProcessBuilder pb = new ProcessBuilder("wsd.pl", "--context test.txt", "--format raw");
        pb.redirectErrorStream(true);
        Process process =  pb.start();
        InputStream stdout = process.getInputStream();


        BufferedReader reader = new BufferedReader (new InputStreamReader(stdout));

        while ((line = reader.readLine ()) != null) {
            System.out.println ("Stdout: " + line);
        }
    }

It gives me errors:

Stdout: Unknown option: context test.txt
Stdout: Unknown option: format raw

test.txt path is to the source folder of the project (top level, next to src, .git, etc.)

I've tried some different ways: adding arguments to a list and create a new process based on that list, different ways of formatting the arguments but no, it won't work. Can someone help out? I guess it's some syntax I'm not familiar with.

Thanks!

Was it helpful?

Solution

ProcessBuilder pb = new ProcessBuilder("wsd.pl", "--context", "test.txt", "--format", "raw");

Also make sure your working directory is correct.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top