mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
⚡ Minor improvements to AWS Comprehend
This commit is contained in:
parent
71ec72493c
commit
1fd0fcc729
|
@ -145,14 +145,14 @@ export class AwsLambda implements INodeType {
|
||||||
let marker: string = data.NextMarker;
|
let marker: string = data.NextMarker;
|
||||||
while (true) {
|
while (true) {
|
||||||
const dataLoop = await awsApiRequestREST.call(this, 'lambda', 'GET', `/2015-03-31/functions/?MaxItems=50&Marker=${encodeURIComponent(marker)}`);
|
const dataLoop = await awsApiRequestREST.call(this, 'lambda', 'GET', `/2015-03-31/functions/?MaxItems=50&Marker=${encodeURIComponent(marker)}`);
|
||||||
|
|
||||||
for (const func of dataLoop.Functions!) {
|
for (const func of dataLoop.Functions!) {
|
||||||
returnData.push({
|
returnData.push({
|
||||||
name: func.FunctionName as string,
|
name: func.FunctionName as string,
|
||||||
value: func.FunctionArn as string,
|
value: func.FunctionArn as string,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dataLoop.NextMarker) {
|
if (dataLoop.NextMarker) {
|
||||||
marker = dataLoop.NextMarker;
|
marker = dataLoop.NextMarker;
|
||||||
} else {
|
} else {
|
||||||
|
@ -160,7 +160,7 @@ export class AwsLambda implements INodeType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return returnData;
|
return returnData;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -58,16 +58,16 @@ export class AwsComprehend implements INodeType {
|
||||||
value: 'detectDominantLanguage',
|
value: 'detectDominantLanguage',
|
||||||
description: 'Identify the dominant language',
|
description: 'Identify the dominant language',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: 'Detect Sentiment',
|
|
||||||
value: 'detectSentiment',
|
|
||||||
description: 'Analyse the sentiment of the text',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: 'Detect Entities',
|
name: 'Detect Entities',
|
||||||
value: 'detectEntities',
|
value: 'detectEntities',
|
||||||
description: 'Inspects text for named entities, and returns information about them',
|
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',
|
default: 'detectDominantLanguage',
|
||||||
description: 'The operation to perform.',
|
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.',
|
description: 'When set to true a simplify version of the response will be used else the raw data.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Endpoint Arn',
|
displayName: 'Additional Fields',
|
||||||
name: 'endpointArn',
|
name: 'additionalFields',
|
||||||
type: 'string',
|
type: 'collection',
|
||||||
typeOptions: {
|
placeholder: 'Add Field',
|
||||||
alwaysOpenEditWindow: true,
|
|
||||||
},
|
|
||||||
default: '',
|
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
resource: [
|
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 action = 'Comprehend_20171127.DetectEntities';
|
||||||
const text = this.getNodeParameter('text', i) as string;
|
const text = this.getNodeParameter('text', i) as string;
|
||||||
const languageCode = this.getNodeParameter('languageCode', 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 = {
|
const body: IDataObject = {
|
||||||
Text: text,
|
Text: text,
|
||||||
LanguageCode: languageCode,
|
LanguageCode: languageCode,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (endpointArn && endpointArn !== '') {
|
if (additionalFields.endpointArn) {
|
||||||
body.EndpointArn = 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 = await awsApiRequestREST.call(this, 'comprehend', 'POST', '', JSON.stringify(body), { 'x-amz-target': action, 'Content-Type': 'application/x-amz-json-1.1' });
|
||||||
|
responseData = responseData.Entities;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue