Small improvements to Google Cloud Natural Language

This commit is contained in:
Jan Oberhauser 2020-11-19 09:06:03 +01:00
parent cbc1b7f2a3
commit 8aa50df457
2 changed files with 47 additions and 66 deletions

View file

@ -22,7 +22,7 @@ export class GoogleCloudNaturalLanguage implements INodeType {
description: INodeTypeDescription = { description: INodeTypeDescription = {
displayName: 'Google Cloud Natural Language', displayName: 'Google Cloud Natural Language',
name: 'googleCloudNaturalLanguage', name: 'googleCloudNaturalLanguage',
icon: 'file:googleCloudnaturallanguage.png', icon: 'file:googlecloudnaturallanguage.png',
group: ['input', 'output'], group: ['input', 'output'],
version: 1, version: 1,
description: 'Consume Google Cloud Natural Language API', description: 'Consume Google Cloud Natural Language API',
@ -77,35 +77,6 @@ export class GoogleCloudNaturalLanguage implements INodeType {
// ---------------------------------- // ----------------------------------
// All // All
// ---------------------------------- // ----------------------------------
{
displayName: 'Document Type',
name: 'documentType',
type: 'options',
options: [
{
name: 'Unspecified',
value: 'TYPE_UNSPECIFIED',
},
{
name: 'Plain Text',
value: 'PLAIN_TEXT',
},
{
name: 'HTML',
value: 'HTML',
},
],
default: '',
description: 'The type of input document.',
required: true,
displayOptions: {
show: {
operation: [
'analyzeSentiment',
],
},
},
},
{ {
displayName: 'Source', displayName: 'Source',
name: 'source', name: 'source',
@ -167,6 +138,39 @@ export class GoogleCloudNaturalLanguage implements INodeType {
}, },
}, },
}, },
{
displayName: 'Options',
name: 'options',
type: 'collection',
displayOptions: {
show: {
operation: [
'analyzeSentiment',
],
},
},
default: {},
description: '',
placeholder: 'Add Option',
options: [
{
displayName: 'Document Type',
name: 'documentType',
type: 'options',
options: [
{
name: 'HTML',
value: 'HTML',
},
{
name: 'Plain Text',
value: 'PLAIN_TEXT',
},
],
default: 'PLAIN_TEXT',
description: 'The type of input document.',
required: true,
},
{ {
displayName: 'Encoding Type', displayName: 'Encoding Type',
name: 'encodingType', name: 'encodingType',
@ -189,32 +193,9 @@ export class GoogleCloudNaturalLanguage implements INodeType {
value: 'UTF32', value: 'UTF32',
}, },
], ],
default: '', default: 'UTF16',
description: 'The encoding type used by the API to calculate sentence offsets.', description: 'The encoding type used by the API to calculate sentence offsets.',
required: true,
displayOptions: {
show: {
operation: [
'analyzeSentiment',
],
}, },
},
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
displayOptions: {
show: {
operation: [
'analyzeSentiment',
],
},
},
default: {},
description: '',
placeholder: 'Add Option',
options: [
{ {
displayName: 'Language', displayName: 'Language',
name: 'language', name: 'language',
@ -304,9 +285,9 @@ export class GoogleCloudNaturalLanguage implements INodeType {
if (resource === 'document') { if (resource === 'document') {
if (operation === 'analyzeSentiment') { if (operation === 'analyzeSentiment') {
const source = this.getNodeParameter('source', i) as string; const source = this.getNodeParameter('source', i) as string;
const documentType = this.getNodeParameter('documentType', i) as string;
const encodingType = this.getNodeParameter('encodingType', i) as string;
const options = this.getNodeParameter('options', i) as IDataObject; const options = this.getNodeParameter('options', i) as IDataObject;
const encodingType = (options.encodingType as string | undefined) || 'UTF16';
const documentType = (options.documentType as string | undefined) || 'PLAIN_TEXT';
const body: IData = { const body: IData = {
document: { document: {