Skip to content

Commit d8b5d2a

Browse files
author
Chris Park
committed
Merge branch 'develop'
2 parents ae2795b + 6ac835a commit d8b5d2a

24 files changed

+128
-167
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ node_js:
44
- "0.12.7"
55
- "1.0.4"
66
- "4.2.4"
7+
- "4.4.7"
8+
- "6.3.0"
79
before_install:
810
- npm install -g npm
911
before_script:

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ api.rosette(endpoint, function(err, res){
4444
| targetScheme | name translation | No |
4545
| options | relationships | No |
4646
| accuracyMode | relationships | Yes |
47-
| linked | entities | No |
47+
| linked (deprecated) | entities | No |
48+
| linkEntities | entities | No |
4849
| explain | sentiment | No |
4950
| morphology | morphology | Yes |
5051

docker/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ MAINTAINER Sam Hausmann
44
#install necessary packages
55
RUN apt-get -y update && apt-get install -y git && apt-get install -y vim && apt-get install -y curl
66

7+
RUN npm install -g grunt-cli && npm install -g eslint
8+
79
ENV API_KEY api_key
810

911
RUN mkdir /nodejs-dev
@@ -13,5 +15,5 @@ RUN chmod 0755 /nodejs-dev/runAll.sh
1315
#set the working directory
1416
WORKDIR /nodejs-dev
1517

16-
CMD ./runAll.sh $API_KEY $FILENAME $ALT_URL $GIT_USERNAME $GIT_EMAIL $VERSION
18+
CMD ./runAll.sh
1719
VOLUME ["/source"]

docker/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ Build the docker image, e.g. `docker build -t basistech/nodejs:1.1 .`
99

1010
Run an example as `docker run -e API_KEY=api-key -v "path-to-local-nodejs-dir:/source" basistech/nodejs:1.1`
1111

12-
To test against a specific source file, add `-e FILENAME=filename` before the `-v`, to test against an alternate url, add `-e ALT_URL=alternate_url`, and optionally if you would like to regenerate gh-pages from the changes made to the development source you can add `-e GIT_USERNAME=git-username -e VERSION=version` before the `-v`. In order to push the gh-pages to git remember to mount .ssh and .gitconfig to the root dir `-v path-to-.ssh-dir:/root/.ssh -v path-to-.gitconfig:/root/.gitconfig`.
12+
To test against a specific source file, add `-e FILENAME=filename` before the `-v`, to test against an alternate url, add `-e ALT_URL=alternate_url`.

docker/runAll.sh

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
ping_url="https://api.rosette.com/rest/v1/"
44
retcode=0
5+
errors=( "Exception" "processingFailure" "badRequest" "ParseError" "ValueError" "SyntaxError" "AttributeError" "ImportError" )
56

67
#------------------- Functions -------------------------------------
78

@@ -11,12 +12,14 @@ function HELP {
1112
echo " API_KEY - Rosette API key (required)"
1213
echo " FILENAME - Python source file (optional)"
1314
echo " ALT_URL - Alternate service URL (optional)"
14-
echo " GIT_USERNAME - Git username where you would like to push regenerated gh-pages (optional)"
15-
echo " VERSION - Build version (optional)"
1615
echo "Compiles and runs the source file(s) using the local development source."
1716
exit 1
1817
}
1918

19+
if [ ! -z ${ALT_URL} ]; then
20+
ping_url=${ALT_URL}
21+
fi
22+
2023
#Checks if Rosette API key is valid
2124
function checkAPI() {
2225
match=$(curl "${ping_url}ping" -H "X-RosetteAPI-Key: ${API_KEY}" | grep -o "forbidden")
@@ -56,38 +59,27 @@ function runExample() {
5659
fi
5760
echo "${result}"
5861
echo -e "\n---------- ${1} end -------------"
59-
if [[ $result == *"Exception"* ]]; then
60-
retcode=1
61-
elif [[ $result == *"processingFailure"* ]]; then
62-
retcode=1
63-
fi
62+
for err in "${errors[@]}"; do
63+
if [[ ${result} == *"${err}"* ]]; then
64+
retcode=1
65+
fi
66+
done
6467
}
6568

6669

6770
#------------------- Functions End ----------------------------------
6871

6972
#Gets API_KEY, FILENAME and ALT_URL if present
70-
while getopts ":API_KEY:FILENAME:ALT_URL:GIT_USERNAME:VERSION" arg; do
73+
while getopts ":API_KEY:FILENAME:ALT_URL" arg; do
7174
case "${arg}" in
7275
API_KEY)
7376
API_KEY=${OPTARG}
74-
usage
7577
;;
7678
ALT_URL)
7779
ALT_URL=${OPTARG}
78-
usage
7980
;;
8081
FILENAME)
8182
FILENAME=${OPTARG}
82-
usage
83-
;;
84-
GIT_USERNAME)
85-
GIT_USERNAME=${OPTARG}
86-
usage
87-
;;
88-
VERSION)
89-
VERSION={OPTARG}
90-
usage
9183
;;
9284
esac
9385
done
@@ -100,15 +92,11 @@ validateURL
10092
cp -r -n /source/. .
10193

10294
#Run unit tests
103-
npm install -g grunt-cli
104-
npm install -g eslint
10595
npm install
10696
grunt test
10797
#run eslint
10898
eslint lib/*.js
10999

110-
111-
112100
#Run the examples
113101
if [ ! -z ${API_KEY} ]; then
114102
checkAPI
@@ -117,8 +105,10 @@ if [ ! -z ${API_KEY} ]; then
117105
npm install argparse
118106
npm install temporary
119107
if [ ! -z ${FILENAME} ]; then
108+
echo -e "\nRunning example against: ${ping_url}\n"
120109
runExample ${FILENAME}
121110
else
111+
echo -e "\nRunning examples against: ${ping_url}\n"
122112
for file in *.js; do
123113
runExample $file
124114
done
@@ -128,11 +118,5 @@ else
128118
retcode=1
129119
fi
130120

131-
#Generate gh-pages and push them to git account (if git username is provided)
132-
if [ ! -z ${GIT_USERNAME} ]; then
133-
134-
grunt doc
135-
fi
136-
137121
exit ${retcode}
138122

examples/entities.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var api = new Api(args.key, args.url);
1515
var endpoint = "entities";
1616

1717
api.parameters.content = "Bill Murray will appear in new Ghostbusters film: Dr. Peter Venkman was spotted filming a cameo in Boston this… http://dlvr.it/BnsFfS";
18-
18+
api.parameters.genre = "social-media";
1919
api.rosette(endpoint, function(err, res){
2020
if(err){
2121
console.log(err);

examples/entities_linked.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ var api = new Api(args.key, args.url);
1414
var endpoint = "entities";
1515

1616
api.parameters.content = "Last month director Paul Feig announced the movie will have an all-star female cast including Kristen Wiig, Melissa McCarthy, Leslie Jones and Kate McKinnon.";
17+
// this parameter is deprecated
1718
api.parameters.linked = true;
1819
api.parameters.genre = "social-media";
1920

@@ -23,4 +24,4 @@ api.rosette(endpoint, function(err, res){
2324
} else {
2425
console.log(JSON.stringify(res, null, 2));
2526
}
26-
});
27+
});

examples/language.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ api.parameters.customHeaders = [appHeader];
2020
var content = "Por favor Señorita, says the man.";
2121

2222
api.parameters.content = content;
23+
var appHeader = [];
24+
appHeader[0] = "X-RosetteAPI-App"
25+
appHeader[1] = "app";
26+
api.parameters.customHeaders = [appHeader];
2327

2428
api.rosette(endpoint, function(err, res){
2529
if(err){

lib/.Rhistory

Whitespace-only changes.

lib/Api.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,6 @@ var language = require("./language");
3030
var ping = require("./ping");
3131
var info = require("./info");
3232

33-
/**
34-
* Compatible server version.
35-
*
36-
* @type string
37-
*/
38-
var BINDING_VERSION = "1.1";
39-
4033
/**
4134
* @class
4235
*

0 commit comments

Comments
 (0)