Я запускаю TreeTagger через Python (я знаю, что есть Wrapper, но я пытаюсь сделать это сам), используя метод subprocess.call()
:
def call_treetagger(path_file, path_treetagger, language):
# Move the file with one word per line into the TreeTagger folder
source = path_file
destination = path_treetagger + '/swahili_one_word_per_line_tt.txt'
shutil.move(source, destination)
# call TreeTagger via cmd and run it with the moved file as input and in the selected language
cmd1 = 'cd ' + path_treetagger
subprocess.run(cmd1, shell=True)
if language == "sw":
tt_lang = 'tag-swahili'
if language == "en":
tt_lang = 'tag-english'
else:
tt_lang = 'tag-english'
cmd_tt = tt_lang + ' swahili_one_word_per_line_tt.txt' + ' call_via_python_results.txt'
subprocess.run(cmd_tt, shell=True)
call_treetagger("C:/Users/rosas/swahili_one_word_per_line.txt", "C:/TreeTagger", "sw")
Wether я использую subprocess.call()
или system.os()
это всегда говорит:
Can't open swahili_one_word_per_line_tt.txt: No such file or directory at C:\TreeTagger\cmd\utf8-tokenize.perl line 86.
reading parameters ...
tagging ...
finished.
Но когда я запускаю TreeTagger над тем же файлом через оболочку Windows, все работает отлично. Совершенно очевидно, что такого файла нет в Жемчужном скрипте TreeTagger. Почему он ищет файл swahili_one_word_per_line_tt.txt
в этом каталоге, когда я в любом случае вызываю его через Python?