Closed CLRafaelR closed 3 years ago
Hello.
Thank you for your message.
The error message seems to be a problem with loading the 64-bit version of the MeCab library. On my Windows machines at hand, I can install without any problems, but I am aware that there are similar error reports.
If you don't care about the 64-bit version, you can use only the 32-bit version by doing the following
devtools::install_github("IshidaMotohiro/RMeCab", INSTALL_opts = "--no-multiarch")
The libmecab64.dll in my repository was built a long time ago. However, there are other people who have built and released 64-bit versions of the library. If you replace the libmecab64.dll in my repository with the latest version of the library, it may work.
https://github.com/ikegami-yukino/mecab https://github.com/shogo82148/mecab
I found that I could reproduce this installation issue (under R4.0.2 for Windows and Rtools4.0.0.28). And this is because the libmecab.dll specified in Makevars.win
is not placed in its expected directory when cloning from the HEAD branch. So, unfortunately, just adding INSTALL_opts
helps nothing here.
@CLRafaelR
A quick fix is available from this fork. To get things all ready, please follow the steps below:
Sys.setenv(MECAB_LIBS = stringr::str_sub(stringr::str_replace_all(Sys.which("libmecab.dll"), stringr::fixed("\\"), "/"), 1, -14))
remotes::install_github("paithiov909/RMeCab", ref = "update-Makevars", INSTALL_opts = "--no-multiarch")
Thank you.
On Windows machines in my environment, I can't install from the above folk, but I guess some can it, depending on environments.
Apology for the late reply. I appreciate the comments from both of you @IshidaMotohiro and @paithiov909, though I don't have enough time to try either method... Sorry about that, too.
@IshidaMotohiro
I would like to use 64-bit version, so tentatively I'm using the stable version (1.05).
@paithiov909
Although I work with Win 10, I have installed MeCab with UTF-8 encoding to my Win 10, since I also have some programmes which depend on MeCab only with UTF-8 encoding. Should I install another MeCab with Shift-JIS? Does the installation you suggested avoid rewriting the previous dictionary with UTF-8 encoding?
@CLRafaelR Actually, the package seems to work properly with UTF-8 encoded dictionary under Windows. However, in case you use with UTF-8 encoded one, it requires resetting encodings every time you call functions.
Here is an example using RMeCab with UTF-8 dictionary.
res <- RMeCab::RMeCabC(stringi::stri_enc_toutf8("隣の客はよく柿食う客だ"))
dplyr::glimpse(res)
#> List of 9
#> $ : Named chr "髫」"
#> ..- attr(*, "names")= chr "蜷崎ゥ\x9e"
#> $ : Named chr "縺ョ"
#> ..- attr(*, "names")= chr "蜉ゥ隧\x9e"
#> $ : Named chr "螳「"
#> ..- attr(*, "names")= chr "蜷崎ゥ\x9e"
#> $ : Named chr "縺ッ"
#> ..- attr(*, "names")= chr "蜉ゥ隧\x9e"
#> $ : Named chr "繧医¥"
#> ..- attr(*, "names")= chr "蜑ッ隧\x9e"
#> $ : Named chr "譟ソ"
#> ..- attr(*, "names")= chr "蜷崎ゥ\x9e"
#> $ : Named chr "鬟溘≧"
#> ..- attr(*, "names")= chr "蜍戊ゥ\x9e"
#> $ : Named chr "螳「"
#> ..- attr(*, "names")= chr "蜷崎ゥ\x9e"
#> $ : Named chr "縺\xa0"
#> ..- attr(*, "names")= chr "蜉ゥ蜍戊ゥ\x9e"
res <- lapply(res, function(elem){ Encoding(elem) <- "UTF-8"; Encoding(names(elem)) <- "UTF-8"; return(elem) })
dplyr::glimpse(res)
#> List of 9
#> $ : Named chr "隣"
#> ..- attr(*, "names")= chr "名詞"
#> $ : Named chr "の"
#> ..- attr(*, "names")= chr "助詞"
#> $ : Named chr "客"
#> ..- attr(*, "names")= chr "名詞"
#> $ : Named chr "は"
#> ..- attr(*, "names")= chr "助詞"
#> $ : Named chr "よく"
#> ..- attr(*, "names")= chr "副詞"
#> $ : Named chr "柿"
#> ..- attr(*, "names")= chr "名詞"
#> $ : Named chr "食う"
#> ..- attr(*, "names")= chr "動詞"
#> $ : Named chr "客"
#> ..- attr(*, "names")= chr "名詞"
#> $ : Named chr "だ"
#> ..- attr(*, "names")= chr "助動詞"
Created on 2021-03-13 by the reprex package (v1.0.0)
This is because RMeCab internally uses the default locale under Windows and this behavior cannot be changed by users. If you prefer UTF-8 encoding, it's ok to use that. Or not, it might be better to manually keep a backup of the present dictionary, recompile Shift-JIS one, copy that to somewhere, and finally redo compiling UTF-8 one.
You can use those system dictionaries by specifying via mecabrc.
res <- RMeCab::RMeCabC("隣の客はよく柿食う客だ", mecabrc = "/MeCab/ipadic-shiftjis/mecabrc")
dplyr::glimpse(res)
#> List of 9
#> $ : Named chr "隣"
#> ..- attr(*, "names")= chr "名詞"
#> $ : Named chr "の"
#> ..- attr(*, "names")= chr "助詞"
#> $ : Named chr "客"
#> ..- attr(*, "names")= chr "名詞"
#> $ : Named chr "は"
#> ..- attr(*, "names")= chr "助詞"
#> $ : Named chr "よく"
#> ..- attr(*, "names")= chr "副詞"
#> $ : Named chr "柿"
#> ..- attr(*, "names")= chr "名詞"
#> $ : Named chr "食う"
#> ..- attr(*, "names")= chr "動詞"
#> $ : Named chr "客"
#> ..- attr(*, "names")= chr "名詞"
#> $ : Named chr "だ"
#> ..- attr(*, "names")= chr "助動詞"
Created on 2021-03-13 by the reprex package (v1.0.0)
I'm trying to install the latest RMecab (1.07) from GitHub to a Windows 10 machine with R 4.0.2 using rtools40. However, the installation fails with the following error message. Would you mind telling me what I am missing?