Comparing version 1.0.6 to 1.0.7
62
index.js
@@ -14,25 +14,63 @@ const axios = require('axios') | ||
_apiPost(endpoint, userInput) { | ||
entities(text) { | ||
const payload = { | ||
'text': userInput | ||
'text': text | ||
}; | ||
return axios.post(this.rootURL + '/' + endpoint, payload, { headers: this.headers }) | ||
return axios.post(this.rootURL + '/' + 'entities', payload, { headers: this.headers }) | ||
} | ||
_apiGet(endpoint) { | ||
return axios.get(this.rootURL + '/' + endpoint, { headers: this.headers }) | ||
classification(text, labels, multiClass) { | ||
const payload = { | ||
'text': text, | ||
'labels': labels, | ||
'multiClass': multiClass | ||
}; | ||
return axios.post(this.rootURL + '/' + 'classification', payload, { headers: this.headers }) | ||
} | ||
entities(userInput) { | ||
return this._apiPost('entities', userInput) | ||
sentiment(text) { | ||
const payload = { | ||
'text': text | ||
}; | ||
return axios.post(this.rootURL + '/' + 'sentiment', payload, { headers: this.headers }) | ||
} | ||
dependencies(userInput) { | ||
return this._apiPost('dependencies', userInput) | ||
question(context, question) { | ||
const payload = { | ||
'context': context, | ||
'question': question | ||
}; | ||
return axios.post(this.rootURL + '/' + 'question', payload, { headers: this.headers }) | ||
} | ||
sentenceDependencies(userInput) { | ||
return this._apiPost('sentence-dependencies', userInput) | ||
summarization(text) { | ||
const payload = { | ||
'text': text | ||
}; | ||
return axios.post(this.rootURL + '/' + 'summarization', payload, { headers: this.headers }) | ||
} | ||
dependencies(text) { | ||
const payload = { | ||
'text': text | ||
}; | ||
return axios.post(this.rootURL + '/' + 'dependencies', payload, { headers: this.headers }) | ||
} | ||
sentenceDependencies(text) { | ||
const payload = { | ||
'text': text | ||
}; | ||
return axios.post(this.rootURL + '/' + 'sentence-dependencies', payload, { headers: this.headers }) | ||
} | ||
libVersions() { | ||
return this._apiGet('version') | ||
return axios.get(this.rootURL + '/' + 'versions', { headers: this.headers }) | ||
} | ||
@@ -39,0 +77,0 @@ } |
{ | ||
"name": "nlpcloud", | ||
"version": "1.0.6", | ||
"description": "Node.js client for the NLP Cloud API. NLP Cloud serves all the spaCy pre-trained models, and your own custom models, through a RESTful API ready for production.\n\nMore details here: https://nlpcloud.io\n\nDocumentation: https://docs.nlpcloud.io", | ||
"version": "1.0.7", | ||
"description": "Node.js client for the NLP Cloud API. NLP Cloud serves high performance pre-trained models for NER, sentiment-analysis, classification, summarization, question answering, and POS tagging, ready for production, served through a REST API.\n\nMore details here: https://nlpcloud.io\n\nDocumentation: https://docs.nlpcloud.io", | ||
"main": "index.js", | ||
@@ -17,6 +17,6 @@ "scripts": { | ||
"spacy", | ||
"machine", | ||
"learning", | ||
"data", | ||
"science", | ||
"Hugging Face", | ||
"deep learning", | ||
"machine learning", | ||
"data science", | ||
"nlpcloud" | ||
@@ -23,0 +23,0 @@ ], |
@@ -5,4 +5,6 @@ # Node.js Client For NLP Cloud | ||
NLP Cloud serves all the spaCy pre-trained models, and your own custom models, through a RESTful API, so it's easy for you to use them in production. | ||
NLP Cloud serves high performance pre-trained models for NER, sentiment-analysis, classification, summarization, question answering, and POS tagging, ready for production, served through a REST API. | ||
Pre-trained models are the spaCy models and some transformers-based models from Hugging Face. You can also deploy your own spaCy models. | ||
If you face an issue, don't hesitate to raise it as a Github issue. Thanks! | ||
@@ -26,3 +28,3 @@ | ||
Here is a full example that uses the `en_core_web_sm` model, with a fake token: | ||
Here is a full example that performs Named Entity Recognition (NER) using spaCy's `en_core_web_lg` model, with a fake token: | ||
@@ -32,3 +34,3 @@ ```js | ||
const client = new NLPCloudClient('en_core_web_sm','4eC39HqLyjWDarjtT1zdp7dc') | ||
const client = new NLPCloudClient('en_core_web_lg','4eC39HqLyjWDarjtT1zdp7dc') | ||
@@ -50,3 +52,3 @@ client.entities("John Doe is a Go Developer at Google") | ||
const client = new NLPCloudClient('en_core_web_sm','4eC39HqLyjWDarjtT1zdp7dc') | ||
const client = new NLPCloudClient('custom_model/7894','4eC39HqLyjWDarjtT1zdp7dc') | ||
@@ -92,5 +94,5 @@ client.entities("John Doe is a Go Developer at Google") | ||
Pass the spaCy model you want to use and the NLP Cloud token to the client during initialization. | ||
Pass the model you want to use and the NLP Cloud token to the client during initialization. | ||
The spaCy model can either be a spaCy pretrained model like `en_core_web_sm`, `fr_core_news_lg`... but also one of your custom spaCy models using `custom_model/<model id>` (e.g. `custom_model/2568`). | ||
The model can either be a pretrained model like `en_core_web_lg`, `bart-large-mnli`... but also one of your custom spaCy models using `custom_model/<model id>` (e.g. `custom_model/2568`). | ||
@@ -113,2 +115,43 @@ Your token can be retrieved from your [NLP Cloud dashboard](https://nlpcloud.io/home/token). | ||
### Classification Endpoint | ||
Call the `classification()` method and pass 3 arguments: | ||
1. The text you want to classify, as a string | ||
1. The candidate labels for your text, as an array of strings | ||
1. Whether the classification should be multi-class or not, as a boolean | ||
```js | ||
client.classification("<Your block of text>", ["label 1", "label 2", "..."], true|false) | ||
``` | ||
### Sentiment Analysis Endpoint | ||
Call the `sentiment()` method and pass the text you want to analyze the sentiment of: | ||
```js | ||
client.sentiment("<Your block of text>") | ||
``` | ||
### Question Answering Endpoint | ||
Call the `question()` method and pass the following: | ||
1. A context that the model will use to try to answer your question | ||
1. Your question | ||
```js | ||
client.question("<Your context>", "<Your question>") | ||
``` | ||
### Summarization Endpoint | ||
Call the `summarization()` method and pass the text you want to summarize. | ||
**Note that your block of text should not exceed 1024 words, otherwise you will get an error. Also note that this model works best for blocks of text between 56 and 142 words.** | ||
```js | ||
client.summarization("<Your text to summarize>") | ||
``` | ||
### Dependencies Endpoint | ||
@@ -124,6 +167,6 @@ | ||
Call the `sentence_dependencies()` method and pass a block of text made up of several sentencies you want to perform POS + arcs on. | ||
Call the `sentenceDependencies()` method and pass a block of text made up of several sentencies you want to perform POS + arcs on. | ||
```js | ||
client.sentence_dependencies("<Your block of text>") | ||
client.sentenceDependencies("<Your block of text>") | ||
``` | ||
@@ -133,7 +176,7 @@ | ||
Call the `lib_versions()` method to know the versions of the libraries used behind the hood with the model (for example the spaCy version used). | ||
Call the `libVersions()` method to know the versions of the libraries used behind the hood with the model (for example the spaCy version used). | ||
```js | ||
client.lib_versions() | ||
client.libVersions() | ||
``` | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10274
83
175