Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Park committed Sep 15, 2016
2 parents 1d8c92e + 756203a commit 8517669
Show file tree
Hide file tree
Showing 17 changed files with 82 additions and 19 deletions.
6 changes: 6 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
^.*\.Rproj$
^\.Rproj\.user$
^\.travis\.yml$
current-release$
docker$
examples$
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.Rproj.user
.Rhistory
.RData
.Ruserdata
inst/doc
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ r_packages:
- optparse
after_install:
- cd rosetteApi
before_script:
- cd tests
script: Rscript Tests.R
script: Rscript tests
notifications:
slack:
rooms:
Expand Down
18 changes: 13 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
Package: rosetteApi
Type: Package
Title: Rosette API
Version: 1.2.0
Date: 2016-07-23
Author: Sam Hausmann
Maintainer: Sam Hausmann <[email protected]>
Version: 1.3.0
Date: 2016-08-31
Author: Sam Hausmann [aut, cre],
Chris Park [ctb],
Hannah Gaudet [ctb]
Maintainer: Chris Park <[email protected]>
Description: Rosette is an API for multilingual text analysis and information extraction. More information can be found at <https://developer.rosette.com>.
License: Apache License
License: file LICENSE
Depends:
R (>= 3.1.0),
httr,
rjson
Suggests:
knitr,
rmarkdown,
testthat
URL: https://developer.rosette.com
BugReports: https://developer.rosette.com/support-ticket
RoxygenNote: 5.0.1
VignetteBuilder:
knitr
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by roxygen2: do not edit by hand
import(httr)
import(rjson)
export(api))
export(api)
8 changes: 5 additions & 3 deletions R/Api.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ api <- function(user_key, endpoint, parameters=FALSE, customHeaders=NULL, url="h
} else if (endpoint == "entities/linked"){
.Deprecated(api(user_key, "entities"), NULL, "/entities/linked is deprecated. The endpoint has been merged with /entities")
return(to_json(error_check(check_for_multipart(user_key, check_content_parameters(parameters), "entities/linked", customHeaders, url))))
} else if (endpoint == "text-embedding"){
return(to_json(error_check(check_for_multipart(user_key, check_content_parameters(parameters), "text-embedding", customHeaders, url))))
} else {
stop("Specify a valid Rosette API endpoint")

Expand Down Expand Up @@ -170,7 +172,7 @@ create_multipart <- function(parameters) {
#' @param url - url for Rosette Api
#' @return Returns the response from the Rosette API
mutipart_call <- function(user_key, parameters, endpoint, customHeaders,url) {
BINDING_VERSION <- "1.2.0"
BINDING_VERSION <- "1.3.0"
if(is.null(customHeaders)) {
response <- POST(paste(url, endpoint, sep=""), encode = "multipart", add_headers("X-RosetteAPI-Key" = user_key, "Content-Type" = "multipart/mixed", "X-RosetteAPI-Binding" = "R", "X-RosetteAPI-Binding-Version" = BINDING_VERSION, "user-agent" = "ruseragent"), body = parameters)
} else {
Expand Down Expand Up @@ -238,7 +240,7 @@ serialize_name_parameters <- function(parameters) {
#' @param url - url for Rosette Api
#' @return Returns the response from the Rosette API
post_endpoint <- function(user_key, parameters, endpoint, customHeaders, url) {
BINDING_VERSION <- "1.2.0"
BINDING_VERSION <- "1.3.0"
if(is.null(customHeaders)) {
if(endpoint == "name-translation" || endpoint == "name-similarity"){
response <- POST(paste(url, endpoint, sep=""), add_headers("X-RosetteAPI-Key" = user_key, "Content-Type" = "application/json", "X-RosetteAPI-Binding" = "R", "X-RosetteAPI-Binding-Version" = BINDING_VERSION), body = serialize_name_parameters(parameters))
Expand Down Expand Up @@ -268,7 +270,7 @@ post_endpoint <- function(user_key, parameters, endpoint, customHeaders, url) {
#' @param url - url for Rosette Api
#' @return Returns the response from the Rosette API
get_endpoint <- function(user_key, endpoint, customHeaders, url) {
BINDING_VERSION <- "1.2.0"
BINDING_VERSION <- "1.3.0"
if(is.null(customHeaders)) {
response <- GET(paste(url, endpoint, sep=""), add_headers("X-RosetteAPI-Key" = user_key, "X-RosetteAPI-Binding" = "R", "X-RosetteAPI-Binding-Version" = BINDING_VERSION, "user-agent" = "ruseragent"))
} else {
Expand Down
Binary file removed current-release/rosetteApi_1.2.0.tar.gz
Binary file not shown.
Binary file added current-release/rosetteApi_1.3.0.tar.gz
Binary file not shown.
25 changes: 25 additions & 0 deletions examples/text_embedding.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
source("../R/Api.R")
library(rjson)
library("optparse")

option_list = list( make_option(c("-k", "--key"), action="store", default=NA, type='character',
help="Rosette API key"), make_option(c("-u", "--url"), action="store", default=NA, type='character',
help="Rosette API url"))
opt_parser = OptionParser(option_list=option_list)
opt = parse_args(opt_parser)

embeddings_data <- "Cambridge, Massachusetts"

key <- "content"
value <- entities_linked_text_data

parameters <- list()
parameters[[ key ]] <- value
parameters <- toJSON(parameters)

if(is.na(opt$url)){
result <- api(opt$key, "text-embedding", parameters)
} else {
result <- api(opt$key, "text-embedding", parameters, NULL, opt$url)
}
print(result)
5 changes: 4 additions & 1 deletion man/NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@
- New entities example
- Removed entities linked example
- Deprecated entites linked
- Parameters serialized correctly
- Parameters serialized correctly

# rosetteApi 1.3.0
- New text-embedding example
Binary file removed man/rosetteApi_1.2.0.pdf
Binary file not shown.
Binary file added man/rosetteApi_1.3.0.pdf
Binary file not shown.
17 changes: 17 additions & 0 deletions r-binding.Rproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
5 changes: 0 additions & 5 deletions tests/Tests.R

This file was deleted.

4 changes: 4 additions & 0 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
library(testthat)
library(rosetteApi)

test_check("rosetteApi")
File renamed without changes.
2 changes: 1 addition & 1 deletion vignettes/my-vignette.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ author: "Sam Hausmann"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Vignette Title}
%\VignetteIndexEntry{Rosette API R Binding}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
Expand Down

0 comments on commit 8517669

Please sign in to comment.