Minor improvements to AWS Comprehend

This commit is contained in:
Jan Oberhauser 2021-05-07 22:31:27 -05:00
parent 71ec72493c
commit 1fd0fcc729
2 changed files with 29 additions and 19 deletions

View file

@ -145,14 +145,14 @@ export class AwsLambda implements INodeType {
let marker: string = data.NextMarker;
while (true) {
const dataLoop = await awsApiRequestREST.call(this, 'lambda', 'GET', `/2015-03-31/functions/?MaxItems=50&Marker=${encodeURIComponent(marker)}`);
for (const func of dataLoop.Functions!) {
returnData.push({
name: func.FunctionName as string,
value: func.FunctionArn as string,
});
}
if (dataLoop.NextMarker) {
marker = dataLoop.NextMarker;
} else {
@ -160,7 +160,7 @@ export class AwsLambda implements INodeType {
}
}
}
return returnData;
},
},

View file

@ -58,16 +58,16 @@ export class AwsComprehend implements INodeType {
value: 'detectDominantLanguage',
description: 'Identify the dominant language',
},
{
name: 'Detect Sentiment',
value: 'detectSentiment',
description: 'Analyse the sentiment of the text',
},
{
name: 'Detect Entities',
value: 'detectEntities',
description: 'Inspects text for named entities, and returns information about them',
},
{
name: 'Detect Sentiment',
value: 'detectSentiment',
description: 'Analyse the sentiment of the text',
},
],
default: 'detectDominantLanguage',
description: 'The operation to perform.',
@ -175,13 +175,10 @@ export class AwsComprehend implements INodeType {
description: 'When set to true a simplify version of the response will be used else the raw data.',
},
{
displayName: 'Endpoint Arn',
name: 'endpointArn',
type: 'string',
typeOptions: {
alwaysOpenEditWindow: true,
},
default: '',
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
displayOptions: {
show: {
resource: [
@ -192,7 +189,19 @@ export class AwsComprehend implements INodeType {
],
},
},
description: 'The Amazon Resource Name of an endpoint that is associated with a custom entity recognition model.',
default: {},
options: [
{
displayName: 'Endpoint Arn',
name: 'endpointArn',
type: 'string',
typeOptions: {
alwaysOpenEditWindow: true,
},
default: '',
description: 'The Amazon Resource Name of an endpoint that is associated with a custom entity recognition model.',
},
],
},
],
};
@ -241,18 +250,19 @@ export class AwsComprehend implements INodeType {
const action = 'Comprehend_20171127.DetectEntities';
const text = this.getNodeParameter('text', i) as string;
const languageCode = this.getNodeParameter('languageCode', i) as string;
const endpointArn = this.getNodeParameter('endpointArn', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
const body: IDataObject = {
Text: text,
LanguageCode: languageCode,
};
if (endpointArn && endpointArn !== '') {
body.EndpointArn = endpointArn;
if (additionalFields.endpointArn) {
body.EndpointArn = additionalFields.endpointArn;
}
responseData = await awsApiRequestREST.call(this, 'comprehend', 'POST', '', JSON.stringify(body), { 'x-amz-target': action, 'Content-Type': 'application/x-amz-json-1.1' });
responseData = responseData.Entities;
}
}