Skip to content
This repository has been archived by the owner on May 5, 2023. It is now read-only.

Commit

Permalink
added cognitive services entity search sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony Jin committed Oct 26, 2017
1 parent d640187 commit c33d650
Show file tree
Hide file tree
Showing 44 changed files with 5,732 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .jshintrc
Expand Up @@ -25,5 +25,6 @@
"trailing": true,
"undef": true,
"unused": false,
"shadow": true
"shadow": true,
"loopfunc": true
}
21 changes: 21 additions & 0 deletions lib/services/cognitiveServices.Search/LICENSE.txt
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2017 Microsoft

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
40 changes: 40 additions & 0 deletions lib/services/cognitiveServices.Search/README.md
@@ -0,0 +1,40 @@
# Microsoft Azure SDK for Node.js - Cognitive Services Entity Search API

This project provides a Node.js package that makes it easy to work with Microsoft Azure Cognitive Services Entity Search API. Right now it supports:
- **Node.js version: 7.10.0 or higher**


## How to Install

```bash
npm install azure-cognitiveservices-search
```

## How to use

### Create credentials

```javascript
var msRestAzure = require('ms-rest-azure');
var credentials = msRestAzure.ApiSubscriptionKeyCredentials('<YourSubscriptionKey>');
```

### Query the Entity Search API

```javascript
var search = require('azure-cognitiveservices-search');

var entitySearchApi = new search.EntitySearchAPI(credentials);
var query = 'seahawks';
var options = {'market': 'en-us'};
var response = entitySearchApi.entitiesOperations.search(query, options, function(err, result, request, response){
console.log(err);
console.log(result);
console.log(request);
console.log(response);
});
```

## More Detailed Information

https://azure.microsoft.com/en-us/try/cognitive-services/ under "Search"
@@ -0,0 +1,10 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*/

import EntitySearchAPI = require('./entitySearch/entitySearchAPI');
import * as EntitySearchModels from './entitySearch/models';

export { EntitySearchAPI, EntitySearchModels };
@@ -0,0 +1,9 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*/
'use strict';

exports.EntitySearchAPI = require('./entitySearch/entitySearchAPI');
exports = module.exports;
@@ -0,0 +1,42 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is
* regenerated.
*/

import { ServiceClient, ServiceClientOptions, ServiceClientCredentials } from 'ms-rest';
import * as operations from "./operations";

declare class EntitySearchAPI extends ServiceClient {
/**
* @class
* Initializes a new instance of the EntitySearchAPI class.
* @constructor
*
* @param {credentials} credentials - Subscription credentials which uniquely identify client subscription.
*
* @param {string} [baseUri] - The base URI of the service.
*
* @param {object} [options] - The parameter options
*
* @param {Array} [options.filters] - Filters to be added to the request pipeline
*
* @param {object} [options.requestOptions] - Options for the underlying request object
* {@link https://github.com/request/request#requestoptions-callback Options doc}
*
* @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy
*
*/
constructor(credentials: ServiceClientCredentials, baseUri?: string, options?: ServiceClientOptions);

credentials: ServiceClientCredentials;

// Operation groups
entitiesOperations: operations.EntitiesOperations;
}

export = EntitySearchAPI;
@@ -0,0 +1,60 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is
* regenerated.
*/

/* jshint latedef:false */
/* jshint forin:false */
/* jshint noempty:false */

'use strict';

const msRest = require('ms-rest');
const ServiceClient = msRest.ServiceClient;

const models = require('./models');
const operations = require('./operations');


/** Class representing a EntitySearchAPI. */
class EntitySearchAPI extends ServiceClient {
/**
* Create a EntitySearchAPI.
* @param {credentials} credentials - Subscription credentials which uniquely identify client subscription.
* @param {string} [baseUri] - The base URI of the service.
* @param {object} [options] - The parameter options
* @param {Array} [options.filters] - Filters to be added to the request pipeline
* @param {object} [options.requestOptions] - Options for the underlying request object
* {@link https://github.com/request/request#requestoptions-callback Options doc}
* @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy
*/
constructor(credentials, baseUri, options) {
if (credentials === null || credentials === undefined) {
throw new Error('\'credentials\' cannot be null.');
}

if (!options) options = {};

super(credentials, options);

this.baseUri = baseUri;
if (!this.baseUri) {
this.baseUri = 'https://api.cognitive.microsoft.com/bing/v7.0';
}
this.credentials = credentials;

let packageInfo = this.getPackageJsonInfo(__dirname);
this.addUserAgentInfo(`${packageInfo.name}/${packageInfo.version}`);
this.entitiesOperations = new operations.EntitiesOperations(this);
this.models = models;
msRest.addSerializationMixin(this);
}

}

module.exports = EntitySearchAPI;
@@ -0,0 +1,91 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is
* regenerated.
*/

'use strict';

const models = require('./index');

/**
* Class representing a Answer.
* @extends models['Response']
*/
class Answer extends models['Response'] {
/**
* Create a Answer.
*/
constructor() {
super();
}

/**
* Defines the metadata of Answer
*
* @returns {object} metadata of Answer
*
*/
mapper() {
return {
required: false,
serializedName: 'Answer',
type: {
name: 'Composite',
className: 'Answer',
modelProperties: {
_type: {
required: true,
serializedName: '_type',
type: {
name: 'String'
}
},
id: {
required: false,
readOnly: true,
serializedName: 'id',
type: {
name: 'String'
}
},
contractualRules: {
required: false,
readOnly: true,
serializedName: 'contractualRules',
type: {
name: 'Sequence',
element: {
required: false,
serializedName: 'ContractualRulesContractualRuleElementType',
type: {
name: 'Composite',
polymorphicDiscriminator: {
serializedName: '_type',
clientName: '_type'
},
uberParent: 'ContractualRulesContractualRule',
className: 'ContractualRulesContractualRule'
}
}
}
},
webSearchUrl: {
required: false,
readOnly: true,
serializedName: 'webSearchUrl',
type: {
name: 'String'
}
}
}
}
};
}
}

module.exports = Answer;
@@ -0,0 +1,75 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is
* regenerated.
*/

'use strict';

const models = require('./index');

/**
* Class representing a ContractualRulesAttribution.
* @extends models['ContractualRulesContractualRule']
*/
class ContractualRulesAttribution extends models['ContractualRulesContractualRule'] {
/**
* Create a ContractualRulesAttribution.
* @member {boolean} [mustBeCloseToContent] A Boolean value that determines
* whether the contents of the rule must be placed in close proximity to the
* field that the rule applies to. If true, the contents must be placed in
* close proximity. If false, or this field does not exist, the contents may
* be placed at the caller's discretion.
*/
constructor() {
super();
}

/**
* Defines the metadata of ContractualRulesAttribution
*
* @returns {object} metadata of ContractualRulesAttribution
*
*/
mapper() {
return {
required: false,
serializedName: 'ContractualRules/Attribution',
type: {
name: 'Composite',
className: 'ContractualRulesAttribution',
modelProperties: {
targetPropertyName: {
required: false,
readOnly: true,
serializedName: 'targetPropertyName',
type: {
name: 'String'
}
},
_type: {
required: true,
serializedName: '_type',
type: {
name: 'String'
}
},
mustBeCloseToContent: {
required: false,
readOnly: true,
serializedName: 'mustBeCloseToContent',
type: {
name: 'Boolean'
}
}
}
}
};
}
}

module.exports = ContractualRulesAttribution;

0 comments on commit c33d650

Please sign in to comment.