我必须在我的 Python 代码中使用 github 上提供的词干分析器。该 github 项目的作者在 README 中给出了一个使用命令行:
java -jar khoja-stemmer-command-line.jar test-in.txt test-out.txt
Python 中数据帧的每一行都必须作为该命令的 test-in.txt,并且 test-out.txt 将给出输出。 谁能告诉我如何从头(python 中的命令行)到结束集成它?
最佳答案
您可以使用:
import os
os.system("java -jar khoja-stemmer-command-line.jar test-in.txt test-out.txt")
如果您使用的 Python 版本高于 3.5,则可以使用 subprocess
( docs here )。
关于java - 在 Python 中使用 Jar 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57695219/