使用 KoNLP 在 R 中提取名词时出错
Error extracting noun in R using KoNLP
我试图为 R 提取名词。当使用程序 R 时,出现错误。我写了下面的代码:
setwd("C:\Users\kyu\Desktop\1-1file")
library(KoNLP)
useSejongDic()
txt <- readLines(file("1_2000.csv"))
nouns <- sapply(txt, extractNoun, USE.NAMES = F)
并且,错误显示如下:
setwd("C:\Users\kyu\Desktop\1-1file")
library(KoNLP)
useSejongDic()
Backup was just finished!
87007 words were added to dic_user.txt.
txt <- readLines(file("1_2000.csv"))
nouns <- sapply(txt, extractNoun, USE.NAMES = F)
java.lang.ArrayIndexOutOfBoundsException Error in
Encoding<-
(*tmp*
, value = "UTF-8") : a character vector
argument expected
为什么会这样?我加载1_2000.csv个文件,有2000行数据。这是数据太多了吗?如何提取大型数据文件中的名词?我将 R 3.2.4 与 RStudio 一起使用,并在 Windows 8.1 x64.
上使用 Excel 2016 版
行数应该不是问题。
我认为编码可能有问题。看到这个 。您的 .csv 文件编码为 EUC-KR。
我使用
将编码更改为 UTF-8
txtUTF <- read.csv(file.choose(), encoding = 'UTF-8')
nouns <- sapply(txtUTF, extractNoun, USE.NAMES = F)
但这会导致以下错误:
Warning message:
In preprocessing(sentence) : Input must be legitimate character!
所以这可能是您输入的错误。我看不懂韩语,所以无法进一步帮助你。
我试图为 R 提取名词。当使用程序 R 时,出现错误。我写了下面的代码:
setwd("C:\Users\kyu\Desktop\1-1file")
library(KoNLP)
useSejongDic()
txt <- readLines(file("1_2000.csv"))
nouns <- sapply(txt, extractNoun, USE.NAMES = F)
并且,错误显示如下:
setwd("C:\Users\kyu\Desktop\1-1file")
library(KoNLP)
useSejongDic()
Backup was just finished!
87007 words were added to dic_user.txt.
txt <- readLines(file("1_2000.csv"))
nouns <- sapply(txt, extractNoun, USE.NAMES = F)
java.lang.ArrayIndexOutOfBoundsException Error in
Encoding<-
(*tmp*
, value = "UTF-8") : a character vector argument expected
为什么会这样?我加载1_2000.csv个文件,有2000行数据。这是数据太多了吗?如何提取大型数据文件中的名词?我将 R 3.2.4 与 RStudio 一起使用,并在 Windows 8.1 x64.
上使用 Excel 2016 版行数应该不是问题。
我认为编码可能有问题。看到这个
我使用
将编码更改为 UTF-8txtUTF <- read.csv(file.choose(), encoding = 'UTF-8')
nouns <- sapply(txtUTF, extractNoun, USE.NAMES = F)
但这会导致以下错误:
Warning message: In preprocessing(sentence) : Input must be legitimate character!
所以这可能是您输入的错误。我看不懂韩语,所以无法进一步帮助你。