@euirim/microsoft-cognitiveservices-speech-sdk
Version:
Microsoft Cognitive Services Speech SDK for JavaScript
1 lines • 5.23 kB
Source Map (JSON)
{"version":3,"sources":["src/sdk/LanguageUnderstandingModel.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,qBAAa,0BAA0B;IACnC;;;OAGG;IACH,SAAS;IAGT;;;;;;;OAOG;WACW,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,0BAA0B;IAmChE;;;;;;;OAOG;WACW,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,0BAA0B;IAQlE;;;;;;;;;;;;;OAaG;WACW,gBAAgB,CAAC,eAAe,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,0BAA0B;CAWrH;AAED;;;GAGG;AAEH,qBAAa,8BAA+B,SAAQ,0BAA0B;IACnE,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;CAClC","file":"LanguageUnderstandingModel.d.ts","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nimport { Contracts } from \"./Contracts\";\n\n/**\n * Language understanding model\n * @class LanguageUnderstandingModel\n */\nexport class LanguageUnderstandingModel {\n /**\n * Creates and initializes a new instance\n * @constructor\n */\n protected constructor() {\n }\n\n /**\n * Creates an language understanding model using the specified endpoint.\n * @member LanguageUnderstandingModel.fromEndpoint\n * @function\n * @public\n * @param {URL} uri - A String that represents the endpoint of the language understanding model.\n * @returns {LanguageUnderstandingModel} The language understanding model being created.\n */\n public static fromEndpoint(uri: URL): LanguageUnderstandingModel {\n Contracts.throwIfNull(uri, \"uri\");\n Contracts.throwIfNullOrWhitespace(uri.hostname, \"uri\");\n\n const langModelImp: LanguageUnderstandingModelImpl = new LanguageUnderstandingModelImpl();\n // Need to extract the app ID from the URL.\n // URL is in the format: https://<region>.api.cognitive.microsoft.com/luis/v2.0/apps/<Guid>?subscription-key=<key>&timezoneOffset=-360\n\n // Start tearing the string apart.\n\n // region can be extracted from the host name.\n const firstDot: number = uri.host.indexOf(\".\");\n if (-1 === firstDot) {\n throw new Error(\"Could not determine region from endpoint\");\n }\n langModelImp.region = uri.host.substr(0, firstDot);\n\n // Now the app ID.\n\n const lastSegment: number = uri.pathname.lastIndexOf(\"/\") + 1;\n if (-1 === lastSegment) {\n throw new Error(\"Could not determine appId from endpoint\");\n }\n\n langModelImp.appId = uri.pathname.substr(lastSegment);\n\n // And finally the key.\n langModelImp.subscriptionKey = uri.searchParams.get(\"subscription-key\");\n if (undefined === langModelImp.subscriptionKey) {\n throw new Error(\"Could not determine subscription key from endpoint\");\n }\n\n return langModelImp;\n }\n\n /**\n * Creates an language understanding model using the application id of Language Understanding service.\n * @member LanguageUnderstandingModel.fromAppId\n * @function\n * @public\n * @param {string} appId - A String that represents the application id of Language Understanding service.\n * @returns {LanguageUnderstandingModel} The language understanding model being created.\n */\n public static fromAppId(appId: string): LanguageUnderstandingModel {\n Contracts.throwIfNullOrWhitespace(appId, \"appId\");\n\n const langModelImp: LanguageUnderstandingModelImpl = new LanguageUnderstandingModelImpl();\n langModelImp.appId = appId;\n return langModelImp;\n }\n\n /**\n * Creates a language understanding model using hostname, subscription key and application\n * id of Language Understanding service.\n * @member LanguageUnderstandingModel.fromSubscription\n * @function\n * @public\n * @param {string} subscriptionKey - A String that represents the subscription key of\n * Language Understanding service.\n * @param {string} appId - A String that represents the application id of Language\n * Understanding service.\n * @param {LanguageUnderstandingModel} region - A String that represents the region\n * of the Language Understanding service (see the <a href=\"https://aka.ms/csspeech/region\">region page</a>).\n * @returns {LanguageUnderstandingModel} The language understanding model being created.\n */\n public static fromSubscription(subscriptionKey: string, appId: string, region: string): LanguageUnderstandingModel {\n Contracts.throwIfNullOrWhitespace(subscriptionKey, \"subscriptionKey\");\n Contracts.throwIfNullOrWhitespace(appId, \"appId\");\n Contracts.throwIfNullOrWhitespace(region, \"region\");\n\n const langModelImp: LanguageUnderstandingModelImpl = new LanguageUnderstandingModelImpl();\n langModelImp.appId = appId;\n langModelImp.region = region;\n langModelImp.subscriptionKey = subscriptionKey;\n return langModelImp;\n }\n}\n\n/**\n * @private\n * @class LanguageUnderstandingModelImpl\n */\n// tslint:disable-next-line:max-classes-per-file\nexport class LanguageUnderstandingModelImpl extends LanguageUnderstandingModel {\n public appId: string;\n public region: string;\n public subscriptionKey: string;\n}\n"]}