I am running TreeTagger via Python (I know there is a Wrapper, but I try to do by myself) using the subprocess.call()
method:
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 I use subprocess.call()
or system.os()
it always says:
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.
But when I run TreeTagger over the same file via the Windows Shell, everything works fine. It is perfectly clear that there is no such file to find within the Pearl Script of TreeTagger. Why is it searching for the file swahili_one_word_per_line_tt.txt
in this directory when I call it via Python anyways?