“R错误中的映射应用”;点[[1L]][[1L]]中的错误:类型为'的对象;关闭';不可再附加“;
我有以下代码:“R错误中的映射应用”;点[[1L]][[1L]]中的错误:类型为'的对象;关闭';不可再附加“;,r,mapply,R,Mapply,我有以下代码:mapply(annotate,maxs,s,ann) 其中annotate是一个函数,它接受注释器对象(maxs)、字符串和注释对象(ann)。s是字符串列表,ann是长度相等的注释对象列表 这就是我得到的错误: 点[[1L]][[1L]]中存在错误:“closure”类型的对象不可用 可附属 信息和代码: s <- c("hello world", "hello world")
mapply(annotate,maxs,s,ann)
其中annotate是一个函数,它接受注释器对象(maxs)、字符串和注释对象(ann)。s是字符串列表,ann是长度相等的注释对象列表
这就是我得到的错误:
点[[1L]][[1L]]中存在错误:“closure”类型的对象不可用
可附属
信息和代码:
s <- c("hello world", "hello world")
require(openNLP)
require(NLP)
require(openNLPmodels.en)
require(tm) #optional
require(hash) #optional
require(openNLPdata) #optional
sent_token_annotator <- Maxent_Sent_Token_Annotator()
word_token_annotator <- Maxent_Word_Token_Annotator()
pos_tag_annotator <- Maxent_POS_Tag_Annotator()
ann <- sapply(s, annotate, list(sent_token_annotator,
word_token_annotator,
pos_tag_annotator))
maxs<-Maxent_Chunk_Annotator(probs = FALSE)
> maxs; str(maxs); s; str(s); ann; str(ann);
An annotator inheriting from classes
Simple_Chunk_Annotator Annotator
with description
Computes chunk annotations using the Apache OpenNLP Maxent chunker employing the default model for language 'en'.
function (s, a)
- attr(*, "meta")=List of 1
..$ description: chr "Computes chunk annotations using the Apache OpenNLP Maxent chunker employing the default model for language 'en'."
- attr(*, "class")= chr [1:2] "Simple_Chunk_Annotator" "Annotator"
[1] "hello world" "hello world"
chr [1:2] "hello world" "hello world"
id type start end features
1 sentence 1 23 constituents=<<integer,4>>
2 word 1 5 POS=UH
3 word 7 11 POS=NN
4 word 13 17 POS=UH
5 word 19 23 POS=NN
List of 5
$ :Classes 'Annotation', 'Span' hidden list of 5
..$ id : int 1
..$ type : chr "sentence"
..$ start : int 1
..$ end : int 23
..$ features:List of 1
.. ..$ :List of 1
.. .. ..$ constituents: int [1:4] 2 3 4 5
..- attr(*, "meta")=List of 2
.. ..$ POS_tagset : chr "en-ptb"
.. ..$ POS_tagset_URL: chr "http://www.comp.leeds.ac.uk/ccalas/tagsets/upenn.html"
$ :Classes 'Annotation', 'Span' hidden list of 5
..$ id : int 2
..$ type : chr "word"
..$ start : int 1
..$ end : int 5
..$ features:List of 1
.. ..$ :List of 1
.. .. ..$ POS: chr "UH"
..- attr(*, "meta")=List of 2
.. ..$ POS_tagset : chr "en-ptb"
.. ..$ POS_tagset_URL: chr "http://www.comp.leeds.ac.uk/ccalas/tagsets/upenn.html"
$ :Classes 'Annotation', 'Span' hidden list of 5
..$ id : int 3
..$ type : chr "word"
..$ start : int 7
..$ end : int 11
..$ features:List of 1
.. ..$ :List of 1
.. .. ..$ POS: chr "NN"
..- attr(*, "meta")=List of 2
.. ..$ POS_tagset : chr "en-ptb"
.. ..$ POS_tagset_URL: chr "http://www.comp.leeds.ac.uk/ccalas/tagsets/upenn.html"
$ :Classes 'Annotation', 'Span' hidden list of 5
..$ id : int 4
..$ type : chr "word"
..$ start : int 13
..$ end : int 17
..$ features:List of 1
.. ..$ :List of 1
.. .. ..$ POS: chr "UH"
..- attr(*, "meta")=List of 2
.. ..$ POS_tagset : chr "en-ptb"
.. ..$ POS_tagset_URL: chr "http://www.comp.leeds.ac.uk/ccalas/tagsets/upenn.html"
$ :Classes 'Annotation', 'Span' hidden list of 5
..$ id : int 5
..$ type : chr "word"
..$ start : int 19
..$ end : int 23
..$ features:List of 1
.. ..$ :List of 1
.. .. ..$ POS: chr "NN"
..- attr(*, "meta")=List of 2
.. ..$ POS_tagset : chr "en-ptb"
.. ..$ POS_tagset_URL: chr "http://www.comp.leeds.ac.uk/ccalas/tagsets/upenn.html"
- attr(*, "class")= chr [1:2] "Annotation" "Span"
- attr(*, "meta")=List of 2
..$ POS_tagset : chr "en-ptb"
..$ POS_tagset_URL: chr "http://www.comp.leeds.ac.uk/ccalas/tagsets/upenn.html"
s请提供一个带有数据的可复制示例。很可能是代码中的一些错误。您能否提供示例数据,或至少显示注释,str(maxs)
str(s)
str(ann)
?TY的结果。更新了问题。泰,你用的是什么包装?请在mapply
之前发布您的实际代码块,包括所有库
行和所有必要的行。我更新了问题。TY.请提供一个可复制的示例和数据。很可能是代码中的一些错误。您能否提供示例数据,或至少显示注释,str(maxs)
str(s)
str(ann)
?TY的结果。更新了问题。泰,你用的是什么包装?请在mapply
之前发布您的实际代码块,包括所有库
行和所有必要的行。我更新了问题。泰。