junhewk / RcppMeCab

RcppMeCab: Rcpp Interface of CJK Morpheme Analyzer MeCab
25 stars 9 forks source link

pos() function only return Exception: list() when format = "list" #4

Closed mrchypark closed 6 years ago

mrchypark commented 6 years ago
> tar <- "안녕하세요 저는 박찬엽 입니다."
> Encoding(tar)
[1] "UTF-8"
> pos(tar, sys_dic = "c:\\mecab")
Exception: 
list()

but when format = "data.frame" return is ok.

pos(tar, format = "data.frame")
  doc_id sentence_id token_id  token    pos subtype
1      1           1        1   안녕    NNG    행위
2      1           1        2     하    XSV        
3      1           1        3   세요  EP+EF        
4      1           1        4     저     NP        
5      1           1        5     는     JX        
6      1           1        6 박찬엽    NNP    인명
7      1           1        7 입니다 VCP+EF        
8      1           1        8      .     SF   

my sessionInfo() below

R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=Korean_Korea.949  LC_CTYPE=Korean_Korea.949    LC_MONETARY=Korean_Korea.949
[4] LC_NUMERIC=C                 LC_TIME=Korean_Korea.949    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] RcppMeCab_0.0.1.2

loaded via a namespace (and not attached):
[1] compiler_3.5.1     tools_3.5.1        Rcpp_0.12.18       RcppParallel_4.4.1
mrchypark commented 6 years ago

I don't know why function is work...

junhewk commented 6 years ago

Hi @mrchypark ,

The problem is the location you provide for sys_dic.

> pos(tar, sys_dic = "c:/mecab")
Exception: 
list()
> pos(tar)
$`안녕하세요 저는 박찬엽 입니다.`
[1] "안녕/NNG"      "하/XSV"        "세요/EP+EF"    "저/NP"         "는/JX"         "박찬엽/NNP"    "입니다/VCP+EF" "./SF"         

> pos(tar, sys_dic = "c:/mecab/mecab-ko-dic/")
$`안녕하세요 저는 박찬엽 입니다.`
[1] "안녕/NNG"      "하/XSV"        "세요/EP+EF"    "저/NP"         "는/JX"         "박찬엽/NNP"    "입니다/VCP+EF" "./SF" 

You should put the location for the MeCab-dic (or MeCab-ko-dic, in this case).

Thanks!

mrchypark commented 6 years ago

Do you have any plan to manage sys_dic location with environmental variables?