G_1991
G_1991

Reputation: 149

R-How dos the pos() function work for parts-of-speech tagging

I'm new to R and confused with the way the pos() function works. Here's why:

Example:

library(qdap)
s1<-c("Hello World")  
pos(s1)  

This produces the correct output saying the word count

wrd.cnt - 2     
NN -1(50%) 
UH-1(50%) 

whereas the following to operations throws errors:

s2<-"Hello"  
pos(s2)  

Error in apply(pro, 2, paster, digits = digits, symbol = s.ymb, override =   override) :   
  dim(X) must have a positive length  

s3<-c("Hello Hello")  
pos(s3)  

Error in apply(pro, 2, paster, digits = digits, symbol = s.ymb, override =   override) :   
  dim(X) must have a positive length  

I'm not able to understand why this is caused.

Upvotes: 2

Views: 1672

Answers (1)

Tyler Rinker
Tyler Rinker

Reputation: 109954

You have found a bug in this version of qdap cause by not using drop = FALSE while indexing.

The dev version will behave as expected. You can download it easily with this code:

if (!require("pacman")) install.packages("pacman"); library(pacman)
p_install_gh("trinker/qdap")

The following has been added to the NEWS file as well:

Here's the updated output:

library(qdap)
s1<-c("Hello World")  
pos(s1)  
##   wrd.cnt     NN     UH
## 1       2 1(50%) 1(50%)

s2<-"Hello"  
pos(s2)  
##   wrd.cnt      UH
## 1       1 1(100%)

Upvotes: 1

Related Questions