0

I have to use a stemmer available on github in my Python code. The author of that github project has given a Usage command line in the README which is:

  java -jar khoja-stemmer-command-line.jar test-in.txt test-out.txt

Each of the row of a dataframe in python has to go as test-in.txt to this command and test-out.txt will give the output. Can anyone please how can I integrate this from beginning (command line in python) to end?

1 Answer 1

1

You can use:

import os
os.system("java -jar khoja-stemmer-command-line.jar test-in.txt test-out.txt")

If you are using a version of Python above 3.5, you can use subprocess (docs here).

Sign up to request clarification or add additional context in comments.

3 Comments

Worth noting, depending on what you need to do it might be better to use subprocess instead.
Ok one other question: I have a Java class let's suppose Stemmer. If I had to access this in the Main java file it would have been like: Stemmer mystemmer = new Stemmer (); String result = mystemmer.stem(token); However, I have that 'token' present in python, and I have to pass it like that^ to the java class method and then get the result in python. can you please tell how to do that?
That should be a new question :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.