library("jsonlite")
library("RCurl")
# the following function picks as parameters:
# either a text or a url
# app_id
# app_key
# include (a list of comma separated fields (you may insert: image,abstract,categories,types,lod))
# min_confidence (set by deafault to 0.6)
# language (set to automatic detection)
# social (which enables to parse hashtags etc. (set to false))
# it returns (unless no request errors (uncaught) occur) either a data.frame having as many rows as the annotations and
# columns based on the include parameter or a message 'No entities found'
# it corresponds to the followings GET requests:
# &min_confidence=min_confidence&lang=language&social=social
dataTxtNex <- function(input, app_id, app_key, include, min_confidence=.6, language='auto', social=F) {
params <- list()
params['$app_id'] <- app_id
params['$app_key'] <- app_key
if (grepl("^https?://", input)){
params['url'] <- input
} else {
params['text'] <- input
}
params['min_confidence'] <- min_confidence
params['social'] <- social
params['include'] <- include
params['lang'] <- language
dataTxtReply <- fromJSON(getForm(nex, .params=params, .checkParams = TRUE))
annotations <- dataTxtReply$annotations
if (length(annotations) > 1) {
return(annotations)
} else {
return('No entities found')
}
}
ciao<-dataTxtNex(input = "Quest'anno ci saranno le elezioni del rettore. Speriamo che vinca la lista di Francesca.",
app_id="myappid",
app_key="myappkey",
include="categories")
Error in function (type, msg, asError = TRUE) :
SSL certificate problem: self signed certificate in certificate chain.
I used myappid and myappkey as shown in my dashboard