Skip to content
This repository was archived by the owner on Oct 24, 2025. It is now read-only.

Commit a44af8b

Browse files
committed
changed LUIS key, renamed CallByMeaning to cbm-engine, updated some packages
1 parent a470973 commit a44af8b

File tree

13 files changed

+1170
-864
lines changed

13 files changed

+1170
-864
lines changed

.eslintignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
lib/
1+
lib/jsonfn.js

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,6 @@ typings/
6060
.env
6161

6262
## Additional files
63+
.eslintignore
6364
.travis.yml
6465
codecov.yml

README.md

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# cbm-api [![Build Status](https://travis-ci.org/cbmjs/cbm-api.svg?branch=master)](https://travis-ci.org/cbmjs/cbm-api) [![codecov](https://codecov.io/gh/cbmjs/cbm-api/branch/master/graph/badge.svg)](https://codecov.io/gh/cbmjs/cbm-api) [![npm version](https://badge.fury.io/js/%40cbmjs%2Fcbm-api.svg)](https://badge.fury.io/js/%40cbmjs%2Fcbm-api)
22

3-
Node.js interface to the CallByMeaning network server. For further information, consult the website of the server-side project: [CallByMeaning](https://github.com/cbmjs/CallByMeaning).
3+
Node.js interface to the cbmjs network server. For further information, consult the website of the server-side project: [cbm-engine](https://github.com/cbmjs/cbm-engine).
44

55
## Introduction
66

@@ -18,7 +18,7 @@ The module exports a single constructor which can be used to open an API connect
1818
const cbm = new CallByMeaning();
1919
```
2020

21-
In case that you are running your own copy of the CallByMeaning server, the constructor takes the hostname of the server as an optional argument. The default option evaluates to "[https://call-by-meaning.herokuapp.com](https://call-by-meaning.herokuapp.com/)".
21+
In case that you are running your own copy of the cbmjs server, the constructor takes the hostname of the server as an optional argument. The default option evaluates to "[https://call-by-meaning.herokuapp.com](https://call-by-meaning.herokuapp.com/)".
2222

2323
```javascript
2424
CallByMeaning(host);
@@ -30,13 +30,13 @@ Example:
3030
const cbm = new CallByMeaning('http://localhost:3000');
3131
```
3232

33-
We can then use the following six methods to query the CallByMeaning API:
33+
We can then use the following six methods to query the cbmjs API:
3434

3535
## Methods
3636

3737
### `.lookup(uri[, type])`
3838

39-
This method expects a valid CallByMeaning URI as its first argument.
39+
This method expects a valid cbmjs URI as its first argument.
4040
`type` is an (optional) string that specifies the type of the GET request. It can have the keys `c`, `f` or `r`. This method is asynchronous and returns a promise that, when fulfilled, returns an object with two properties.`statusCode` which contains the status code of the request and `body` that holds the result set from the query.
4141

4242
Example code:
@@ -50,7 +50,7 @@ cbm.lookup('time', 'c').then((result) => {
5050

5151
### `.getURI(text)`
5252

53-
This method finds out what the CallByMeaning URI is for a given text, applying steps such as reducing English words to their root form and removing special characters.
53+
This method finds out what the cbmjs URI is for a given text, applying steps such as reducing English words to their root form and removing special characters.
5454

5555
Example code:
5656

@@ -60,7 +60,7 @@ cbm.getURI('a (big) dog!'); //-> big_dog
6060

6161
### `.search(...args)`
6262

63-
This method finds all the functions that correspond to given concepts and returns an array containing them. It can be called with two different ways. Either by providing only an object containing the search parameters or by providing the parameters themselves as arguments. This method is asynchronous and returns a promise that, when fulfilled, returns an object with two properties.`statusCode` which contains the status code of the request and `body` that holds the result set from the query. For a full overview of search parameters, check the [documentation](https://github.com/cbmjs/CallByMeaning/blob/master/docs/GETBYMEANING.md).
63+
This method finds all the functions that correspond to given concepts and returns an array containing them. It can be called with two different ways. Either by providing only an object containing the search parameters or by providing the parameters themselves as arguments. This method is asynchronous and returns a promise that, when fulfilled, returns an object with two properties.`statusCode` which contains the status code of the request and `body` that holds the result set from the query. For a full overview of search parameters, check the [documentation](https://github.com/cbmjs/cbm-engine/blob/master/docs/GETBYMEANING.md).
6464

6565
Example code:
6666

@@ -70,15 +70,15 @@ cbm.search({'inputConcepts': 'date', 'outputConcepts': 'time'}).then((result) =>
7070
// insert code here
7171
}).catch((error) => console.error(error));
7272

73-
cbm.search('date', 'time'}).then((result) => {
73+
cbm.search('date', 'time').then((result) => {
7474
if (result.statusCode === 200) console.log('Success!');
7575
// insert code here
7676
}).catch((error) => console.error(error));
7777
```
7878

7979
### `.call(...args)`
8080

81-
This method takes the search parameters and after finding an appropriate function - a function with the same concepts as inputs and outputs, but (maybe) in different units, that is - executes it and returns the result. If the (optional) argument `returnCode` is set to true, it instead returns the .js file's name and the description of the function. It can be called with two different ways. Either by providing only an object containing the search parameters (and maybe the optional returnCode as a second argument) or by providing the parameters themselves as arguments. This method is asynchronous and returns a promise that, when fulfilled, returns an object with two properties.`statusCode` which contains the status code of the request and `body` that holds the result set from the query. For a full overview of search parameters, check the [documentation](https://github.com/cbmjs/CallByMeaning/blob/master/docs/CALLBYMEANING.md).
81+
This method takes the search parameters and after finding an appropriate function - a function with the same concepts as inputs and outputs, but (maybe) in different units, that is - executes it and returns the result. If the (optional) argument `returnCode` is set to true, it instead returns the .js file's name and the description of the function. It can be called with two different ways. Either by providing only an object containing the search parameters (and maybe the optional returnCode as a second argument) or by providing the parameters themselves as arguments. This method is asynchronous and returns a promise that, when fulfilled, returns an object with two properties.`statusCode` which contains the status code of the request and `body` that holds the result set from the query. For a full overview of search parameters, check the [documentation](https://github.com/cbmjs/cbm-engine/blob/master/docs/CALLBYMEANING.md).
8282

8383
Example code:
8484

@@ -91,7 +91,7 @@ cbm.call({
9191
'inputVars': bday,
9292
'outputConcepts': 'time',
9393
'outputUnits': 'seconds'
94-
}.then((result) => {
94+
}).then((result) => {
9595
if (result.statusCode === 200) console.log('Success!');
9696
// insert code here
9797
}).catch((error) => console.error(error));
@@ -102,19 +102,21 @@ cbm.call('date', null, 'time', 'seconds', true).then(...); // If we want the sou
102102

103103
### `.getCode(fileName)`
104104

105-
This method acts as a small helper to the usage of `.search` and `.call` methods. It takes the `name` of a .js file in the server and returns its code in plain text.
105+
This method acts as a small helper to the usage of `.search` and `.call` methods. It takes the `name` of a .js file in the server and returns its code in plain text.This method is asynchronous and returns a promise that, when fulfilled, returns a string containing the code.
106106

107107
Example code:
108108

109109
```javascript
110-
let code = cbm.getCode('getTime.js');
111-
const getTime = eval(code);
112-
getTime();
110+
cbm.getCode('getTime.js').then(code => {
111+
const getTime = eval(code);
112+
getTime();
113+
});
114+
113115
```
114116

115117
## `.create(params[, type])`
116118

117-
This method creates a document in the server if it doesn't exist or modifies it, if it does. It accepts a [params](https://github.com/cbmjs/CallByMeaning/blob/master/docs/MODELS.md) object with the document parameters as its first argument and a string containing the type of the document. It can be one of `concept`, `function`, `relation`. If it isn't provided, it defaults to `concept`. This method is asynchronous and returns a promise that, when fulfilled, returns a boolean, depending of its success.
119+
This method creates a document in the server if it doesn't exist or modifies it, if it does. It accepts a [params](https://github.com/cbmjs/cbm-engine/blob/master/docs/MODELS.md) object with the document parameters as its first argument and a string containing the type of the document. It can be one of `concept`, `function`, `relation`. If it isn't provided, it defaults to `concept`. This method is asynchronous and returns a promise that, when fulfilled, returns a boolean, depending of its success.
118120

119121
Example code:
120122

lib/luis.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const rp = require('request-promise');
1+
const got = require('got');
22
const util = require('util');
33

44
module.exports = (initData) => {
@@ -10,7 +10,7 @@ module.exports = (initData) => {
1010
return {
1111
predict(txt) {
1212
const uri = 'https://westus.api.cognitive.microsoft.com'.concat(util.format(LUISPredictMask, appId, appKey, encodeURIComponent(txt), LUISVerbose));
13-
return rp({ uri, json: true });
13+
return got(uri, { json: true });
1414
},
1515
};
1616
};

0 commit comments

Comments
 (0)