Search code examples
rwindowspathtext-miningpos-tagger

path error for tree tagger with koRpus R package


I try to use treeTagger that I installed from here in R with the package koRpus.

library(koRpus)
tagged.results <- treetag(as.factor("salut ça va"), treetagger="manual", lang="fr", TT.options=list(path="C:\\TreeTagger\\bin\\tree-tagger.exe"))

generates the following error :

Erreur dans path.expand(path) : argument 'path' incorrect

Which I don't understand because I can see all the files in this path, which are : tree-tagger and tree-tagger-flush (application files), tag-french and chunk-french which are windows command file.

I also tried :

set.kRp.env(TT.cmd="C:\\TreeTagger\\bin\\tree-tagger.exe", lang="fr")
tagged.text <- treetag(as.factor("salut ça va"),lang="fr")

The second generates the same error


Solution

  • There are several issues here. First the as.factor("salut ca va") should be a file with that text in it. You are also missing a preset value inside of TT.options. You will want to put preset="fr" after the path argument. Finally the path itself should point to the root directory.

    The documentation here states "TT.options A list of options to configure how TreeTagger is called. You have two basic choices: Either you choose one of the pre-defined presets or you give a full set of valid options: path Mandatory: The absolute path to the TreeTagger root directory. That is where its subfolders bin, cmd and lib are located."

    You are pointing the path variable inside of the bin directory to the .exe file. Run the following code to point to the root directory where the bin directory is located as follows:

    library(koRpus)
    tagged.results <- treetag("test.txt", treetagger="manual", lang="fr", TT.options=list(path="C:\\TreeTagger", preset="fr"))