repo_name string | dataset string | owner string | lang string | func_name string | code string | docstring string | url string | sha string |
|---|---|---|---|---|---|---|---|---|
project-lakechain | github_2023 | awslabs | typescript | KeybertTextProcessorBuilder.withDiversity | public withDiversity(diversity: number) {
this.middlewareProps.diversity = diversity;
return (this);
} | /**
* Sets the diversity of the results between 0 and 1.
* @param diversity the diversity of the results between 0 and 1.
* @default 0.5
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/keybert-text-processor/src/index.ts#L92-L95 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | KeybertTextProcessorBuilder.withCandidates | public withCandidates(candidates: number) {
this.middlewareProps.candidates = candidates;
return (this);
} | /**
* Sets the number of candidates to consider if `useMaxSum` is
* set to `true`.
* @param candidates the number of candidates to consider.
* @default 20
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/keybert-text-processor/src/index.ts#L103-L106 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | KeybertTextProcessorBuilder.withEmbeddingModel | public withEmbeddingModel(embeddingModel: KeybertEmbeddingModel) {
this.middlewareProps.embeddingModel = embeddingModel;
return (this);
} | /**
* Sets the embedding model to be used by KeyBERT.
* @param embeddingModel name of the model.
* @default ALL_MINI_LM_L6_V2
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/keybert-text-processor/src/index.ts#L113-L116 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | KeybertTextProcessorBuilder.build | public build(): KeybertTextProcessor {
return (new KeybertTextProcessor(
this.scope,
this.identifier, {
...this.middlewareProps as KeybertTextProcessorProps,
...this.props
}
));
} | /**
* @returns a new instance of the `KeybertTextProcessor`
* service constructed with the given parameters.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/keybert-text-processor/src/index.ts#L122-L130 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | KeybertTextProcessor.constructor | constructor(scope: Construct, id: string, private props: KeybertTextProcessorProps) {
super(scope, id, description, {
...props,
queueVisibilityTimeout: cdk.Duration.seconds(
3 * PROCESSING_TIMEOUT.toSeconds()
)
});
// Validate the properties.
this.props = this.parse(KeybertTextProcessorPropsSchema, props);
///////////////////////////////////////////
////// Middleware Event Handler ////
///////////////////////////////////////////
// The file system used to cache the KeyBERT model.
const fileSystem = new efs.FileSystem(this, 'Filesystem', {
removalPolicy: cdk.RemovalPolicy.DESTROY,
vpc: this.props.vpc,
throughputMode: efs.ThroughputMode.ELASTIC,
vpcSubnets: {
subnetType: ec2.SubnetType.PRIVATE_ISOLATED
},
encrypted: true,
kmsKey: this.props.kmsKey
});
// Allow services in the VPC to access the EFS.
fileSystem.connections.allowFrom(
ec2.Peer.ipv4(this.props.vpc.vpcCidrBlock),
ec2.Port.tcp(2049),
'Provides access to the EFS from the VPC.'
);
// Create an EFS access point to allow the lambda
// function to access the EFS.
const accessPoint = new efs.AccessPoint(this, 'AccessPoint', {
fileSystem,
path: '/cache',
createAcl: {
ownerGid: '1001',
ownerUid: '1001',
permissions: '750'
},
posixUser: {
uid: '1001',
gid: '1001'
}
});
this.processor = new lambda.DockerImageFunction(this, 'Compute', {
description: 'A function extracting the main keywords of a text.',
code: lambda.DockerImageCode.fromImageAsset(
path.resolve(__dirname, 'lambdas', 'processor')
),
memorySize: props.maxMemorySize ?? DEFAULT_MEMORY_SIZE,
vpc: this.props.vpc,
timeout: PROCESSING_TIMEOUT,
architecture: lambda.Architecture.X86_64,
tracing: lambda.Tracing.ACTIVE,
environmentEncryption: this.props.kmsKey,
logGroup: this.logGroup,
filesystem: lambda.FileSystem.fromEfsAccessPoint(accessPoint, '/mnt/efs'),
insightsVersion: this.props.cloudWatchInsights ?
LAMBDA_INSIGHTS_VERSION :
undefined,
environment: {
POWERTOOLS_SERVICE_NAME: description.name,
POWERTOOLS_METRICS_NAMESPACE: NAMESPACE,
SNS_TARGET_TOPIC: this.eventBus.topicArn,
TOP_N: `${this.props.topN}`,
USE_MAX_SUM: `${this.props.useMaxSum}`,
DIVERSITY: `${this.props.diversity}`,
CANDIDATES: `${this.props.candidates}`,
EMBEDDING_MODEL: this.props.embeddingModel.name,
CACHE_DIR: '/mnt/efs',
HF_HOME: '/mnt/efs'
}
});
// Allows this construct to act as a `IGrantable`
// for other middlewares to grant the processing
// lambda permissions to access their resources.
this.grantPrincipal = this.processor.grantPrincipal;
// Plug the SQS queue into the lambda function.
this.processor.addEventSource(new sources.SqsEventSource(this.eventQueue, {
batchSize: this.props.batchSize ?? 1,
reportBatchItemFailures: true
}));
// Grant the compute type permissions to
// publish to the SNS topic.
this.eventBus.grantPublish(this.grantPrincipal);
super.bind();
} | /**
* Construct constructor.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/keybert-text-processor/src/index.ts#L154-L250 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | KeybertTextProcessor.grantReadProcessedDocuments | grantReadProcessedDocuments(grantee: iam.IGrantable): iam.Grant {
// Since this middleware simply passes through the data
// from the previous middleware, we grant any subsequent
// middlewares in the pipeline to have read access to the
// data of all source middlewares.
for (const source of this.sources) {
source.grantReadProcessedDocuments(grantee);
}
return ({} as iam.Grant);
} | /**
* Allows a grantee to read from the processed documents
* generated by this middleware.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/keybert-text-processor/src/index.ts#L256-L265 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | KeybertTextProcessor.supportedInputTypes | supportedInputTypes(): string[] {
return ([
'text/plain'
]);
} | /**
* @returns an array of mime-types supported as input
* type by this middleware.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/keybert-text-processor/src/index.ts#L271-L275 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | KeybertTextProcessor.supportedOutputTypes | supportedOutputTypes(): string[] {
return ([
'text/plain'
]);
} | /**
* @returns an array of mime-types supported as output
* type by the data producer.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/keybert-text-processor/src/index.ts#L281-L285 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | KeybertTextProcessor.supportedComputeTypes | supportedComputeTypes(): ComputeType[] {
return ([
ComputeType.CPU
]);
} | /**
* @returns the supported compute types by a given
* middleware.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/keybert-text-processor/src/index.ts#L291-L295 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | KeybertTextProcessor.conditional | conditional() {
return (super
.conditional()
.and(when('type').equals('document-created'))
);
} | /**
* @returns the middleware conditional statement defining
* in which conditions this middleware should be executed.
* In this case, we want the middleware to only be invoked
* when the document mime-type is supported, and the event
* type is `document-created`.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/keybert-text-processor/src/index.ts#L304-L309 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | KeybertEmbeddingModel.of | public static of(name: string) {
return (new KeybertEmbeddingModel(name));
} | /**
* Create a new instance of the `KeybertEmbeddingModel`
* by name.
* @param name the name of the model.
* @returns a new instance of the `KeybertEmbeddingModel`.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/keybert-text-processor/src/definitions/embedding-model.ts#L53-L55 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | Newspaper3kParserBuilder.build | public build(): Newspaper3kParser {
return (new Newspaper3kParser(
this.scope,
this.identifier, {
...this.props
}));
} | /**
* @returns a new instance of the `Newspaper3kParser`
* service constructed with the given parameters.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/newspaper3k/src/index.ts#L69-L75 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | Newspaper3kParser.constructor | constructor(scope: Construct, id: string, props: MiddlewareProps) {
super(scope, id, description, {
...props,
queueVisibilityTimeout: cdk.Duration.seconds(
3 * PROCESSING_TIMEOUT.toSeconds()
)
});
// Validate the properties.
props = this.parse(MiddlewarePropsSchema, props);
///////////////////////////////////////////
//////// Processing Storage ///////
///////////////////////////////////////////
this.storage = new CacheStorage(this, 'Storage', {
encryptionKey: props.kmsKey
});
///////////////////////////////////////////
/////// Processing Function ///////
///////////////////////////////////////////
this.eventProcessor = new lambda.DockerImageFunction(this, 'TextConverter', {
description: 'A function that converts HTML documents into plain text and extracts their metadata.',
code: lambda.DockerImageCode.fromImageAsset(
path.resolve(__dirname, 'lambdas', 'parser')
),
vpc: props.vpc,
memorySize: props.maxMemorySize ?? DEFAULT_MEMORY_SIZE,
timeout: PROCESSING_TIMEOUT,
architecture: lambda.Architecture.X86_64,
tracing: lambda.Tracing.ACTIVE,
environmentEncryption: props.kmsKey,
logGroup: this.logGroup,
insightsVersion: props.cloudWatchInsights ?
LAMBDA_INSIGHTS_VERSION :
undefined,
environment: {
POWERTOOLS_SERVICE_NAME: description.name,
POWERTOOLS_METRICS_NAMESPACE: NAMESPACE,
SNS_TARGET_TOPIC: this.eventBus.topicArn,
PROCESSED_FILES_BUCKET: this.storage.id(),
CACHE_DIR: '/tmp'
}
});
// Allows this construct to act as a `IGrantable`
// for other middlewares to grant the processing
// lambda permissions to access their resources.
this.grantPrincipal = this.eventProcessor.grantPrincipal;
// Plug the SQS queue into the lambda function.
this.eventProcessor.addEventSource(new sources.SqsEventSource(this.eventQueue, {
batchSize: props.batchSize ?? 10,
maxBatchingWindow: props.batchingWindow,
reportBatchItemFailures: true
}));
// Function permissions.
this.storage.grantWrite(this.eventProcessor);
this.eventBus.grantPublish(this.eventProcessor);
super.bind();
} | /**
* Construct constructor.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/newspaper3k/src/index.ts#L105-L169 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | Newspaper3kParser.grantReadProcessedDocuments | grantReadProcessedDocuments(grantee: iam.IGrantable): iam.Grant {
return (this.storage.grantRead(grantee));
} | /**
* Allows a grantee to read from the processed documents
* generated by this middleware.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/newspaper3k/src/index.ts#L175-L177 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | Newspaper3kParser.supportedInputTypes | supportedInputTypes(): string[] {
return ([
'text/html'
]);
} | /**
* @returns an array of mime-types supported as input
* type by this middleware.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/newspaper3k/src/index.ts#L183-L187 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | Newspaper3kParser.supportedOutputTypes | supportedOutputTypes(): string[] {
return ([
'text/plain'
]);
} | /**
* @returns an array of mime-types supported as output
* type by the data producer.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/newspaper3k/src/index.ts#L193-L197 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | Newspaper3kParser.supportedComputeTypes | supportedComputeTypes(): ComputeType[] {
return ([
ComputeType.CPU
]);
} | /**
* @returns the supported compute types by a given
* middleware.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/newspaper3k/src/index.ts#L203-L207 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | Newspaper3kParser.conditional | conditional() {
return (super
.conditional()
.and(when('type').equals('document-created'))
);
} | /**
* @returns the middleware conditional statement defining
* in which conditions this middleware should be executed.
* In this case, we want the middleware to only be invoked
* when the document mime-type is supported, and the event
* type is `document-created`.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/newspaper3k/src/index.ts#L216-L221 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | NlpTextProcessorBuilder.withIntent | public withIntent(intent: Intent) {
this.providerProps.intent = intent;
return (this);
} | /**
* @param intent the NLP intent to apply.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/nlp-text-processor/src/index.ts#L68-L71 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | NlpTextProcessorBuilder.build | public build(): NlpTextProcessor {
return (new NlpTextProcessor(
this.scope,
this.identifier, {
...this.providerProps as NlpTextProcessorProps,
...this.props
}
));
} | /**
* @returns a new instance of the `NlpTextProcessor`
* service constructed with the given parameters.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/nlp-text-processor/src/index.ts#L77-L85 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | NlpTextProcessor.constructor | constructor(scope: Construct, id: string, private props: NlpTextProcessorProps) {
super(scope, id, description, {
...props,
queueVisibilityTimeout: cdk.Duration.seconds(
6 * PROCESSING_TIMEOUT.toSeconds()
)
});
// Validate the properties.
this.props = this.parse(NlpTextProcessorPropsSchema, props);
///////////////////////////////////////////
/////// Processing Function ///////
///////////////////////////////////////////
this.eventProcessor = new node.NodejsFunction(this, 'Compute', {
description: 'Applies NLP operations on text documents.',
entry: path.resolve(__dirname, 'lambdas', 'nlp-processor', 'index.js'),
vpc: this.props.vpc,
memorySize: this.props.maxMemorySize ?? DEFAULT_MEMORY_SIZE,
timeout: PROCESSING_TIMEOUT,
runtime: EXECUTION_RUNTIME,
architecture: lambda.Architecture.ARM_64,
tracing: lambda.Tracing.ACTIVE,
environmentEncryption: this.props.kmsKey,
logGroup: this.logGroup,
insightsVersion: this.props.cloudWatchInsights ?
LAMBDA_INSIGHTS_VERSION :
undefined,
environment: {
POWERTOOLS_SERVICE_NAME: description.name,
POWERTOOLS_METRICS_NAMESPACE: NAMESPACE,
SNS_TARGET_TOPIC: this.eventBus.topicArn,
LAKECHAIN_CACHE_STORAGE: this.props.cacheStorage.id(),
NLP_OPS: this.props.intent.compile()
},
bundling: {
minify: true,
externalModules: [
'@aws-sdk/client-s3',
'@aws-sdk/client-sns',
'@aws-sdk/client-comprehend'
]
}
});
// Allows this construct to act as a `IGrantable`
// for other middlewares to grant the processing
// lambda permissions to access their resources.
this.grantPrincipal = this.eventProcessor.grantPrincipal;
// Plug the SQS queue into the lambda function.
this.eventProcessor.addEventSource(new sources.SqsEventSource(this.eventQueue, {
batchSize: this.props.batchSize ?? 2,
maxConcurrency: 5,
reportBatchItemFailures: true
}));
// Allowing the function to call Amazon Comprehend.
this.eventProcessor.addToRolePolicy(new iam.PolicyStatement({
actions: [
'comprehend:DetectDominantLanguage',
'comprehend:DetectEntities',
'comprehend:DetectSentiment',
'comprehend:DetectSyntax',
'comprehend:DetectPiiEntities'
],
resources: ['*']
}));
// Function permissions.
this.eventBus.grantPublish(this.eventProcessor);
super.bind();
} | /**
* Construct constructor.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/nlp-text-processor/src/index.ts#L108-L182 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | NlpTextProcessor.grantReadProcessedDocuments | grantReadProcessedDocuments(grantee: iam.IGrantable): iam.Grant {
// Since this middleware simply passes through the data
// from the previous middleware, we grant any subsequent
// middlewares in the pipeline read access to the
// data of all source middlewares.
for (const source of this.sources) {
source.grantReadProcessedDocuments(grantee);
}
return ({} as iam.Grant);
} | /**
* Allows a grantee to read from the processed documents
* generated by this middleware.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/nlp-text-processor/src/index.ts#L188-L197 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | NlpTextProcessor.supportedInputTypes | supportedInputTypes(): string[] {
return ([
'text/plain',
'text/html',
'text/markdown',
'text/csv',
'text/xml',
'application/json'
]);
} | /**
* @returns an array of mime-types supported as input
* type by this middleware.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/nlp-text-processor/src/index.ts#L203-L212 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | NlpTextProcessor.supportedOutputTypes | supportedOutputTypes(): string[] {
return (this.supportedInputTypes());
} | /**
* @returns an array of mime-types supported as output
* type by the data producer.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/nlp-text-processor/src/index.ts#L218-L220 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | NlpTextProcessor.supportedComputeTypes | supportedComputeTypes(): ComputeType[] {
return ([
ComputeType.CPU
]);
} | /**
* @returns the supported compute types by a given
* middleware.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/nlp-text-processor/src/index.ts#L226-L230 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | NlpTextProcessor.conditional | conditional() {
return (super
.conditional()
.and(when('type').equals('document-created'))
);
} | /**
* @returns the middleware conditional statement defining
* in which conditions this middleware should be executed.
* In this case, we want the middleware to only be invoked
* when the document mime-type is supported, and the event
* type is `document-created`.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/nlp-text-processor/src/index.ts#L239-L244 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | def | const def = (v: any) => typeof v !== 'undefined'; | /**
* @param v the value to check.
* @returns true if the value is defined.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/nlp-text-processor/src/definitions/index.ts#L24-L24 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | NlpOperations.language | language(language?: string): LanguageDependentOperations {
this.ops.set('language', { args: [def(language) ? { language } : {}], priority: 1 });
return (new LanguageDependentOperations(this.ops));
} | /**
* Specifies that language detection should be performed.
* If no language is specified, the language will be
* detected automatically. If a language is specified,
* the language will be used and no detection will be
* performed.
* @param language an optional language to use.
* @returns the current instance.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/nlp-text-processor/src/definitions/index.ts#L66-L69 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | NlpOperations.readingTime | readingTime(opts?: Wpm): NlpOperations {
this.ops.set('readingTime', { args: [def(opts) ? opts : {}], priority: 0 });
return (this);
} | /**
* Specifies that reading time detection should be performed.
* @returns the current instance.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/nlp-text-processor/src/definitions/index.ts#L75-L78 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | NlpOperations.stats | stats(): NlpOperations {
this.ops.set('stats', { args: [], priority: 0 });
return (this);
} | /**
* Enriches the document metadata with statistics about
* the processed text, such as the number of words and
* sentences in the text.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/nlp-text-processor/src/definitions/index.ts#L85-L88 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | NlpOperations.getOps | getOps(): Map<string, OperationDescriptor> {
return (this.ops);
} | /**
* @returns the list of operations captured.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/nlp-text-processor/src/definitions/index.ts#L93-L95 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | NlpOperations.compile | compile(): string {
const ops = this.getOps();
// Verify whether the operations are valid.
if (!ops.size) {
throw new Error('At least one operation must be specified');
}
// Convert the map to an array.
const array = Array.from(ops, (entry) => {
return { op: entry[0], args: entry[1].args, priority: entry[1].priority };
});
// Sort by priority.
return (JSON.stringify(array.sort((a, b) => b.priority - a.priority)));
} | /**
* Compiles the intent into a string
* representation.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/nlp-text-processor/src/definitions/index.ts#L101-L116 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | LanguageDependentOperations.sentiment | sentiment(): LanguageDependentOperations {
this.ops.set('sentiment', { args: [{}], priority: 0 });
return (this);
} | /**
* Specifies that sentiment detection should be performed.
* @returns the current instance.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/nlp-text-processor/src/definitions/index.ts#L135-L138 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | LanguageDependentOperations.pii | pii(...args: Array<MinConfidence | Filter<string>>): LanguageDependentOperations {
const opts = {};
args.forEach((arg: any) => Object.assign(opts, arg));
this.ops.set('pii', { args: [opts], priority: 0 });
return (this);
} | /**
* Specifies that PII detection should be performed.
* @returns the current instance.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/nlp-text-processor/src/definitions/index.ts#L144-L149 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | LanguageDependentOperations.entities | entities(...args: Array<MinConfidence | Filter<string>>): LanguageDependentOperations {
const opts = {};
args.forEach((arg: any) => Object.assign(opts, arg));
this.ops.set('entities', { args: [opts], priority: 0 });
return (this);
} | /**
* Specifies that text entity detection should be performed.
* @returns the current instance.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/nlp-text-processor/src/definitions/index.ts#L155-L160 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | LanguageDependentOperations.pos | pos(...args: Array<MinConfidence | Filter<string>>): LanguageDependentOperations {
const opts = {};
args.forEach((arg: any) => Object.assign(opts, arg));
this.ops.set('pos', { args: [opts], priority: 0 });
return (this);
} | /**
* Enables part-of-speech extraction for the detected language.
* Part-of-speech analysis will extract tags from each token
* in a given text, such as 'NOUN' or 'VERB'.
* @see https://universaldependencies.org/u/pos/
* @returns the current instance.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/nlp-text-processor/src/definitions/index.ts#L169-L174 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | Lambda.handler | async handler(event: SQSEvent, _: Context): Promise<SQSBatchResponse> {
return (await processPartialResponse(
event,
(record: SQSRecord) => this.processEvent(
CloudEvent.from(JSON.parse(record.body))
),
processor
));
} | // eslint-disable-next-line @typescript-eslint/no-unused-vars | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/nlp-text-processor/src/lambdas/nlp-processor/index.ts#L82-L90 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OllamaProcessorBuilder.withModel | public withModel(model: OllamaModel) {
this.providerProps.model = model;
return (this);
} | /**
* Sets the Ollama model to use.
* @param model the identifier of the Ollama model to use.
* @see https://ollama.com/library
* @returns the builder instance.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/ollama-processor/src/index.ts#L61-L64 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OllamaProcessorBuilder.withPrompt | public withPrompt(prompt: string) {
this.providerProps.prompt = prompt;
return (this);
} | /**
* Sets the prompt to apply to input documents.
* @param prompt the prompt to use.
* @returns the builder instance.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/ollama-processor/src/index.ts#L71-L74 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OllamaProcessorBuilder.withInfrastructure | public withInfrastructure(infrastructure: InfrastructureDefinition) {
this.providerProps.infrastructure = infrastructure;
return (this);
} | /**
* Sets the infrastructure to use to run the ollama model.
* @param instanceType the instance type to use.
* @returns the builder instance.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/ollama-processor/src/index.ts#L81-L84 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OllamaProcessorBuilder.withMaxInstances | public withMaxInstances(maxInstances: number) {
this.providerProps.maxInstances = maxInstances;
return (this);
} | /**
* The maximum amount of instances the
* cluster can have. Keep this number to
* a reasonable value to avoid over-provisioning
* the cluster.
* @param maxInstances the maximum amount of instances.
* @default 5
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/ollama-processor/src/index.ts#L94-L97 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OllamaProcessorBuilder.build | public build(): OllamaProcessor {
return (new OllamaProcessor(
this.scope,
this.identifier, {
...this.providerProps as OllamaProcessorProps,
...this.props
}
));
} | /**
* @returns a new instance of the `OllamaProcessor`
* service constructed with the given parameters.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/ollama-processor/src/index.ts#L103-L111 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OllamaProcessor.constructor | constructor(scope: Construct, id: string, private props: OllamaProcessorProps) {
super(scope, id, description, {
...props,
queueVisibilityTimeout: cdk.Duration.minutes(30)
});
// Validate the properties.
this.props = this.parse(OllamaProcessorPropsSchema, props);
///////////////////////////////////////////
///////// Processing Storage //////
///////////////////////////////////////////
this.storage = new CacheStorage(this, 'Storage', {
encryptionKey: this.props.kmsKey
});
///////////////////////////////////////////
///////// ECS Container /////////
///////////////////////////////////////////
// The configuration to use for the specified compute type.
const configuration = getConfiguration(this.props.infrastructure);
// The container image to provision the ECS tasks with.
const image = ecs.ContainerImage.fromDockerImageAsset(
new assets.DockerImageAsset(this, 'OllamaImage', {
directory: path.resolve(__dirname, 'container'),
platform: configuration.container.platform
})
);
// Use the ECS container middleware pattern to create an
// auto-scaled ECS cluster, an EFS mounted on the cluster's tasks
// and all the components required to manage the cluster.
// This cluster supports both CPU and GPU instances.
const cluster = new EcsCluster(this, 'Cluster', {
vpc: this.props.vpc,
eventQueue: this.eventQueue,
eventBus: this.eventBus,
kmsKey: this.props.kmsKey,
logGroup: this.logGroup,
containerProps: {
image,
containerName: 'ollama-processor',
memoryLimitMiB: configuration.memoryLimitMiB,
gpuCount: configuration.gpuCount,
environment: {
POWERTOOLS_SERVICE_NAME: description.name,
PROCESSED_FILES_BUCKET: this.storage.id(),
OLLAMA_PROMPT: this.props.prompt,
OLLAMA_MODEL: `${this.props.model.name}:${this.props.model.definition.tag}`,
OLLAMA_MODELS: '/cache'
}
},
autoScaling: {
minInstanceCapacity: 0,
maxInstanceCapacity: this.props.maxInstances,
maxTaskCapacity: this.props.maxInstances,
maxMessagesPerTask: 2
},
launchTemplateProps: {
instanceType: configuration.instanceType,
machineImage: configuration.machineImage,
ebsOptimized: true,
blockDevices: [{
deviceName: '/dev/xvda',
volume: ec2.BlockDeviceVolume.ebs(80)
}],
userData: ec2.UserData.forLinux()
},
fileSystem: {
throughputMode: efs.ThroughputMode.ELASTIC,
readonly: false,
containerPath: '/cache',
accessPoint: {
uid: 1000,
gid: 1000,
permission: 750
}
},
containerInsights: this.props.cloudWatchInsights
});
// Allows this construct to act as a `IGrantable`
// for other middlewares to grant the processing
// lambda permissions to access their resources.
this.grantPrincipal = cluster.taskRole.grantPrincipal;
// Cluster permissions.
this.storage.grantWrite(cluster.taskRole);
super.bind();
} | /**
* Construct constructor.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/ollama-processor/src/index.ts#L138-L231 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OllamaProcessor.grantReadProcessedDocuments | grantReadProcessedDocuments(grantee: iam.IGrantable): iam.Grant {
return (this.storage.grantRead(grantee));
} | /**
* Allows a grantee to read from the processed documents
* generated by this middleware.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/ollama-processor/src/index.ts#L237-L239 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OllamaProcessor.supportedInputTypes | supportedInputTypes(): string[] {
return (this.props.model.definition.inputs);
} | /**
* @returns an array of mime-types supported as input
* type by this middleware.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/ollama-processor/src/index.ts#L245-L247 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OllamaProcessor.supportedOutputTypes | supportedOutputTypes(): string[] {
return (this.props.model.definition.outputs);
} | /**
* @returns an array of mime-types supported as output
* type by the data producer.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/ollama-processor/src/index.ts#L253-L255 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OllamaProcessor.supportedComputeTypes | supportedComputeTypes(): ComputeType[] {
return ([
ComputeType.CPU,
ComputeType.GPU
]);
} | /**
* @returns the supported compute types by a given
* middleware.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/ollama-processor/src/index.ts#L261-L266 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OllamaProcessor.conditional | conditional() {
return (super
.conditional()
.and(when('type').equals('document-created'))
);
} | /**
* @returns the middleware conditional statement defining
* in which conditions this middleware should be executed.
* In this case, we want the middleware to only be invoked
* when the document mime-type is supported, and the event
* type is `document-created`.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/ollama-processor/src/index.ts#L275-L280 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | getPlatform | const getPlatform = (instanceType: ec2.InstanceType) => {
if (instanceType.architecture === ec2.InstanceArchitecture.ARM_64) {
return assets.Platform.LINUX_ARM64;
} else {
return assets.Platform.LINUX_AMD64;
}
}; | /**
* A helper function returning the platform (AMD64 or ARM64)
* to use given an instance type.
* @param instanceType the instance type to evaluate.
* @returns the platform to use.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/ollama-processor/src/definitions/ecs-configuration.ts#L28-L34 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | InfrastructureDefinitionBuilder.withInstanceType | public withInstanceType(instanceType: ec2.InstanceType) {
this.props.instanceType = instanceType;
return (this);
} | /**
* Sets the instance type to use.
* @param instanceType the instance type to use.
* @returns the builder instance.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/ollama-processor/src/definitions/infrastructure.ts#L43-L46 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | InfrastructureDefinitionBuilder.withMaxMemory | public withMaxMemory(maxMemory: number) {
this.props.maxMemory = maxMemory;
return (this);
} | /**
* Sets the maximum memory to use.
* @param maxMemory the maximum memory to use.
* @returns the builder instance.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/ollama-processor/src/definitions/infrastructure.ts#L53-L56 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | InfrastructureDefinitionBuilder.withGpus | public withGpus(gpus: number) {
this.props.gpus = gpus;
return (this);
} | /**
* Sets the number of GPUs to use.
* @param gpus the number of GPUs to use.
* @returns the builder instance.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/ollama-processor/src/definitions/infrastructure.ts#L63-L66 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | InfrastructureDefinitionBuilder.build | public build(): InfrastructureDefinition {
return (InfrastructureDefinition.from(this.props));
} | /**
* Builds the infrastructure definition.
* @returns the infrastructure definition.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/ollama-processor/src/definitions/infrastructure.ts#L72-L74 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | InfrastructureDefinition.constructor | constructor(public props: InfrastructureDefinitionProps) {} | /**
* Creates a new instance of the `InfrastructureDefinition` class.
* @param props the infrastructure definition properties.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/ollama-processor/src/definitions/infrastructure.ts#L92-L92 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | InfrastructureDefinition.instanceType | public instanceType() {
return (this.props.instanceType);
} | /**
* @returns the instance type to use.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/ollama-processor/src/definitions/infrastructure.ts#L97-L99 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | InfrastructureDefinition.maxMemory | public maxMemory() {
return (this.props.maxMemory);
} | /**
* @returns the maximum memory to use.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/ollama-processor/src/definitions/infrastructure.ts#L104-L106 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | InfrastructureDefinition.gpus | public gpus() {
return (this.props.gpus);
} | /**
* @returns the number of GPUs to use.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/ollama-processor/src/definitions/infrastructure.ts#L111-L113 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | InfrastructureDefinition.from | public static from(props: any) {
return (new InfrastructureDefinition(InfrastructureDefinitionPropsSchema.parse(props)));
} | /**
* Creates a new instance of the `InfrastructureDefinition` class.
* @param props the infrastructure definition properties.
* @returns a new instance of the `InfrastructureDefinition` class.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/ollama-processor/src/definitions/infrastructure.ts#L120-L122 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | InfrastructureDefinition.toJSON | public toJSON() {
return (this.props);
} | /**
* @returns the JSON representation of the
* infrastructure definition.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/ollama-processor/src/definitions/infrastructure.ts#L128-L130 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OllamaModel.of | public static of(
name: string,
definition: OllamaModelDefinition
) {
return (new OllamaModel(name, definition));
} | /**
* Create a new instance of the `OllamaModel`
* by name.
* @param name the name of the model.
* @returns a new instance of the `OllamaModel`.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/ollama-processor/src/definitions/model.ts#L796-L801 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OllamaModel.constructor | constructor(
public name: string,
public definition: OllamaModelDefinition
) {} | /**
* Creates a new instance of the `OllamaModel` class.
* @param name the name of the model.
* @param definition the model definition.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/ollama-processor/src/definitions/model.ts#L808-L811 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OllamaModel.tag | public tag(tag: string) {
this.definition.tag = tag;
return (this);
} | /**
* Sets the tag of the model.
* @param tag the tag of the model.
* @returns the model instance.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/ollama-processor/src/definitions/model.ts#L818-L821 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | PandocTextConverterBuilder.withConversions | public withConversions(...ops: Array<PandocConversionOps>) {
for (const op of ops) {
this.providerProps.mapping![op.from] = {
to: op.to,
options: op.options
};
}
return (this);
} | /**
* Specifies the list of conversion mappings to apply
* when converting documents.
* @param ops the conversion operations.
* @returns the builder itself.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pandoc-text-converter/src/index.ts#L74-L82 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | PandocTextConverterBuilder.build | public build(): PandocTextConverter {
return (new PandocTextConverter(
this.scope,
this.identifier, {
...this.providerProps as PandocTextConverterProps,
...this.props
}
));
} | /**
* @returns a new instance of the `TextConverter`
* service constructed with the given parameters.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pandoc-text-converter/src/index.ts#L88-L96 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | PandocTextConverter.constructor | constructor(scope: Construct, id: string, private props: PandocTextConverterProps) {
super(scope, id, description, {
...props,
queueVisibilityTimeout: cdk.Duration.seconds(
6 * PROCESSING_TIMEOUT.toSeconds()
)
});
// Validate the properties.
this.props = PandocTextConverterPropsSchema.parse(props);
///////////////////////////////////////////
//////// Processing Storage ///////
///////////////////////////////////////////
this.storage = new CacheStorage(this, 'Storage', {
encryptionKey: props.kmsKey
});
///////////////////////////////////////////
/////// Processing Function ///////
///////////////////////////////////////////
this.eventProcessor = new lambda.DockerImageFunction(this, 'TextConverter', {
description: 'Middleware converting text documents using pandoc.',
code: lambda.DockerImageCode.fromImageAsset(
path.resolve(__dirname, 'lambdas', 'text-converter')
),
vpc: this.props.vpc,
memorySize: this.props.maxMemorySize ?? DEFAULT_MEMORY_SIZE,
timeout: PROCESSING_TIMEOUT,
architecture: lambda.Architecture.X86_64,
tracing: lambda.Tracing.ACTIVE,
environmentEncryption: this.props.kmsKey,
logGroup: this.logGroup,
insightsVersion: this.props.cloudWatchInsights ?
LAMBDA_INSIGHTS_VERSION :
undefined,
ephemeralStorageSize: cdk.Size.gibibytes(5),
environment: {
POWERTOOLS_SERVICE_NAME: description.name,
POWERTOOLS_METRICS_NAMESPACE: NAMESPACE,
SNS_TARGET_TOPIC: this.eventBus.topicArn,
PROCESSED_FILES_BUCKET: this.storage.id(),
CONVERSION_MAPPING: JSON.stringify(this.props.mapping ?? {})
}
});
// Allows this construct to act as a `IGrantable`
// for other middlewares to grant the processing
// lambda permissions to access their resources.
this.grantPrincipal = this.eventProcessor.grantPrincipal;
// Plug the SQS queue into the lambda function.
this.eventProcessor.addEventSource(new sources.SqsEventSource(this.eventQueue, {
batchSize: this.props.batchSize ?? 5,
reportBatchItemFailures: true
}));
// Function permissions.
this.storage.grantWrite(this.eventProcessor);
this.eventBus.grantPublish(this.eventProcessor);
super.bind();
} | /**
* Construct constructor.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pandoc-text-converter/src/index.ts#L122-L186 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | PandocTextConverter.grantReadProcessedDocuments | grantReadProcessedDocuments(grantee: iam.IGrantable): iam.Grant {
return (this.storage.grantRead(grantee));
} | /**
* Allows a grantee to read from the processed documents
* generated by this middleware.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pandoc-text-converter/src/index.ts#L192-L194 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | PandocTextConverter.supportedInputTypes | supportedInputTypes(): string[] {
return ([
// Books files.
'application/epub+zip',
// CSV files.
'text/csv',
// TSV files.
'text/tab-separated-values',
// Word files.
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
// Markdown files.
'text/markdown',
// HTML files.
'text/html',
// OpenOffice files.
'application/vnd.oasis.opendocument.text',
// RTF files.
'application/rtf',
// LaTeX files.
'application/x-tex',
// RST files.
'text/x-rst',
// Textile files.
'text/x-textile',
// Jupyter Notebook files.
'application/x-ipynb+json',
// Man files.
'text/troff',
// JSON files.
'application/json',
// BibTex files.
'application/x-bibtex',
// Docbook files.
'application/docbook+xml',
// FictionBook files.
'application/x-fictionbook+xml',
// OPML files.
'text/x-opml',
// Texinfo files.
'application/x-texinfo'
]);
} | /**
* @returns an array of mime-types supported as input
* type by this middleware.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pandoc-text-converter/src/index.ts#L200-L241 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | PandocTextConverter.supportedOutputTypes | supportedOutputTypes(): string[] {
return ([
// Asciidoc files.
'text/x-asciidoc',
// BibTex files.
'application/x-bibtex',
// Docbook files.
'application/docbook+xml',
// Docx files.
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
// Epub files.
'application/epub+zip',
// FictionBook files.
'application/x-fictionbook+xml',
// Haskell files.
'text/x-haskell',
// HTML files.
'text/html',
// XML files.
'application/xml',
// Jupyter Notebook files.
'application/x-ipynb+json',
// JSON files.
'application/json',
// Tex files.
'application/x-tex',
// Troff files.
'text/troff',
// Markdown files.
'text/markdown',
// Plain text files.
'text/plain',
// OpenOffice files.
'application/vnd.oasis.opendocument.text',
// OPML files.
'text/x-opml',
// PDF files.
'application/pdf',
// PowerPoint files.
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
// RST files.
'text/x-rst',
// RTF files.
'application/rtf',
// Texinfo files.
'application/x-texinfo',
// Textile files.
'text/x-textile'
]);
} | /**
* @returns an array of mime-types supported as output
* type by the data producer.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pandoc-text-converter/src/index.ts#L247-L296 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | PandocTextConverter.supportedComputeTypes | supportedComputeTypes(): ComputeType[] {
return ([
ComputeType.CPU
]);
} | /**
* @returns the supported compute types by a given
* middleware.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pandoc-text-converter/src/index.ts#L302-L306 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | PandocTextConverter.conditional | conditional() {
return (super
.conditional()
.and(when('type').equals('document-created'))
);
} | /**
* @returns the middleware conditional statement defining
* in which conditions this middleware should be executed.
* In this case, we want the middleware to only be invoked
* when the document mime-type is supported, and the event
* type is `document-created`.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pandoc-text-converter/src/index.ts#L315-L320 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | PdfTextConverterBuilder.withTask | public withTask(task: ExtractPagesTask | ExtractDocumentTask) {
this.providerProps.task = task;
return (this);
} | /**
* Specifies the task to perform.
* @param task an instance of the task to perform.
* @returns the builder instance.
* @default extracts the entire document as text.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pdf-text-converter/src/index.ts#L75-L78 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | PdfTextConverterBuilder.build | public build(): PdfTextConverter {
return (new PdfTextConverter(
this.scope,
this.identifier, {
...this.providerProps as PdfProcessorProps,
...this.props
}
));
} | /**
* @returns a new instance of the `PdfTextConverter`
* service constructed with the given parameters.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pdf-text-converter/src/index.ts#L84-L92 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | PdfTextConverter.constructor | constructor(scope: Construct, id: string, private props: PdfProcessorProps) {
super(scope, id, description, {
...props,
queueVisibilityTimeout: cdk.Duration.seconds(
3 * PROCESSING_TIMEOUT.toSeconds()
)
});
// Validate the properties.
this.props = this.parse(PdfProcessorPropsSchema, props);
///////////////////////////////////////////
//////// Processing Storage ///////
///////////////////////////////////////////
this.storage = new CacheStorage(this, 'Storage', {
encryptionKey: props.kmsKey
});
///////////////////////////////////////////
/////// Processing Function ///////
///////////////////////////////////////////
this.eventProcessor = new lambda.DockerImageFunction(this, 'TextConverter', {
description: 'Middleware converting PDF documents into different formats.',
code: lambda.DockerImageCode.fromImageAsset(
path.resolve(__dirname, 'lambdas', 'processor')
),
vpc: this.props.vpc,
memorySize: this.props.maxMemorySize ?? DEFAULT_MEMORY_SIZE,
timeout: PROCESSING_TIMEOUT,
architecture: lambda.Architecture.X86_64,
tracing: lambda.Tracing.ACTIVE,
environmentEncryption: this.props.kmsKey,
logGroup: this.logGroup,
insightsVersion: this.props.cloudWatchInsights ?
LAMBDA_INSIGHTS_VERSION :
undefined,
environment: {
POWERTOOLS_SERVICE_NAME: description.name,
POWERTOOLS_METRICS_NAMESPACE: NAMESPACE,
SNS_TARGET_TOPIC: this.eventBus.topicArn,
PROCESSED_FILES_BUCKET: this.storage.id(),
TASK: JSON.stringify(this.props.task)
}
});
// Allows this construct to act as a `IGrantable`
// for other middlewares to grant the processing
// lambda permissions to access their resources.
this.grantPrincipal = this.eventProcessor.grantPrincipal;
// Plug the SQS queue into the lambda function.
this.eventProcessor.addEventSource(new sources.SqsEventSource(this.eventQueue, {
batchSize: this.props.batchSize ?? 1,
reportBatchItemFailures: true
}));
// Function permissions.
this.storage.grantWrite(this.eventProcessor);
this.eventBus.grantPublish(this.eventProcessor);
super.bind();
} | /**
* Construct constructor.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pdf-text-converter/src/index.ts#L118-L181 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | PdfTextConverter.grantReadProcessedDocuments | grantReadProcessedDocuments(grantee: iam.IGrantable): iam.Grant {
return (this.storage.grantRead(grantee));
} | /**
* Allows a grantee to read from the processed documents
* generated by this middleware.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pdf-text-converter/src/index.ts#L187-L189 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | PdfTextConverter.supportedInputTypes | supportedInputTypes(): string[] {
return ([
'application/pdf'
]);
} | /**
* @returns an array of mime-types supported as input
* type by this middleware.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pdf-text-converter/src/index.ts#L195-L199 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | PdfTextConverter.supportedOutputTypes | supportedOutputTypes(): string[] {
const task = this.props.task;
if (task.props.outputType === 'text') {
return (['text/plain']);
} else if (task.props.outputType === 'image') {
return (['image/jpeg']);
} else if (task.props.outputType === 'pdf') {
return (['application/pdf'])
} else {
throw new Error(`Invalid output type ${task.props.outputType}`);
}
} | /**
* @returns an array of mime-types supported as output
* type by the data producer.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pdf-text-converter/src/index.ts#L205-L217 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | PdfTextConverter.supportedComputeTypes | supportedComputeTypes(): ComputeType[] {
return ([
ComputeType.CPU
]);
} | /**
* @returns the supported compute types by a given
* middleware.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pdf-text-converter/src/index.ts#L223-L227 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | PdfTextConverter.conditional | conditional() {
return (super
.conditional()
.and(when('type').equals('document-created'))
);
} | /**
* @returns the middleware conditional statement defining
* in which conditions this middleware should be executed.
* In this case, we want the middleware to only be invoked
* when the document mime-type is supported, and the event
* type is `document-created`.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pdf-text-converter/src/index.ts#L236-L241 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | ExtractDocumentTaskBuilder.withOutputType | public withOutputType(outputType: 'text' | 'image') {
this.props.outputType = outputType;
return (this);
} | /**
* @param outputType the output to create.
* @returns the current builder instance.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pdf-text-converter/src/definitions/tasks/extract-document-task.ts#L72-L75 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | ExtractDocumentTaskBuilder.withLayoutExtraction | public withLayoutExtraction(layoutExtraction: boolean) {
this.props.layoutExtraction = layoutExtraction;
return (this);
} | /**
* @param layoutExtraction whether to extract the layout of the pages.
* @returns the current builder instance.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pdf-text-converter/src/definitions/tasks/extract-document-task.ts#L81-L84 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | ExtractDocumentTaskBuilder.build | public build(): ExtractDocumentTask {
return (ExtractDocumentTask.from(this.props));
} | /**
* @returns a new instance of the `ExtractDocumentTask`
* service constructed with the given parameters.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pdf-text-converter/src/definitions/tasks/extract-document-task.ts#L90-L92 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | ExtractDocumentTask.constructor | constructor(public props: ExtractDocumentTaskProps) {} | /**
* Creates a new instance of the `ExtractDocumentTask` class.
* @param props the task properties.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pdf-text-converter/src/definitions/tasks/extract-document-task.ts#L109-L109 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | ExtractDocumentTask.taskType | public taskType() {
return (this.props.taskType);
} | /**
* @returns the task type.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pdf-text-converter/src/definitions/tasks/extract-document-task.ts#L114-L116 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | ExtractDocumentTask.segmentationType | public segmentationType() {
return (this.props.segmentationType);
} | /**
* @returns the segmentation type.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pdf-text-converter/src/definitions/tasks/extract-document-task.ts#L121-L123 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | ExtractDocumentTask.outputType | public outputType() {
return (this.props.outputType);
} | /**
* @returns the output type.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pdf-text-converter/src/definitions/tasks/extract-document-task.ts#L128-L130 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | ExtractDocumentTask.layoutExtraction | public layoutExtraction() {
return (this.props.layoutExtraction);
} | /**
* @returns whether to extract the layout of the pages.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pdf-text-converter/src/definitions/tasks/extract-document-task.ts#L135-L137 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | ExtractDocumentTask.from | public static from(props: any) {
return (new ExtractDocumentTask(ExtractDocumentTaskPropsSchema.parse(props)));
} | /**
* Creates a new instance of the `ExtractDocumentTask` class.
* @param props the task properties.
* @returns a new instance of the `ExtractDocumentTask` class.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pdf-text-converter/src/definitions/tasks/extract-document-task.ts#L144-L146 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | ExtractDocumentTask.toJSON | public toJSON() {
return (this.props);
} | /**
* @returns the JSON representation of the task.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pdf-text-converter/src/definitions/tasks/extract-document-task.ts#L151-L153 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | ExtractPagesTaskBuilder.withFirstPage | public withFirstPage(page: number) {
this.props.firstPage = page;
return (this);
} | /**
* @param page the first page to extract.
* @returns the current builder instance.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pdf-text-converter/src/definitions/tasks/extract-pages-task.ts#L87-L90 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | ExtractPagesTaskBuilder.withLastPage | public withLastPage(page: number) {
this.props.lastPage = page;
return (this);
} | /**
* @param page the last page to extract.
* @returns the current builder instance.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pdf-text-converter/src/definitions/tasks/extract-pages-task.ts#L96-L99 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | ExtractPagesTaskBuilder.withLayoutExtraction | public withLayoutExtraction(layoutExtraction: boolean) {
this.props.layoutExtraction = layoutExtraction;
return (this);
} | /**
* @param layoutExtraction whether to extract the layout of the pages.
* @returns the current builder instance.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pdf-text-converter/src/definitions/tasks/extract-pages-task.ts#L105-L108 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | ExtractPagesTaskBuilder.withOutputType | public withOutputType(outputType: 'text' | 'image' | 'pdf') {
this.props.outputType = outputType;
return (this);
} | /**
* @param outputType the output to create.
* @returns the current builder instance.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pdf-text-converter/src/definitions/tasks/extract-pages-task.ts#L114-L117 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | ExtractPagesTaskBuilder.build | public build(): ExtractPagesTask {
return (ExtractPagesTask.from(this.props));
} | /**
* @returns a new instance of the `ExtractPagesTask`
* service constructed with the given parameters.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pdf-text-converter/src/definitions/tasks/extract-pages-task.ts#L123-L125 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | ExtractPagesTask.constructor | constructor(public props: ExtractPagesTaskProps) {} | /**
* Creates a new instance of the `ExtractPagesTask` class.
* @param props the task properties.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pdf-text-converter/src/definitions/tasks/extract-pages-task.ts#L142-L142 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | ExtractPagesTask.taskType | public taskType() {
return (this.props.taskType);
} | /**
* @returns the task type.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pdf-text-converter/src/definitions/tasks/extract-pages-task.ts#L147-L149 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | ExtractPagesTask.segmentationType | public segmentationType() {
return (this.props.segmentationType);
} | /**
* @returns the segmentation type.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pdf-text-converter/src/definitions/tasks/extract-pages-task.ts#L154-L156 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | ExtractPagesTask.firstPage | public firstPage() {
return (this.props.firstPage);
} | /**
* @returns the first page to extract.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pdf-text-converter/src/definitions/tasks/extract-pages-task.ts#L161-L163 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | ExtractPagesTask.lastPage | public lastPage() {
return (this.props.lastPage);
} | /**
* @returns the last page to extract.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pdf-text-converter/src/definitions/tasks/extract-pages-task.ts#L168-L170 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | ExtractPagesTask.layoutExtraction | public layoutExtraction() {
return (this.props.layoutExtraction);
} | /**
* @returns whether to extract the layout of the pages.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pdf-text-converter/src/definitions/tasks/extract-pages-task.ts#L175-L177 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | ExtractPagesTask.from | public static from(props: any) {
return (new ExtractPagesTask(ExtractPagesTaskPropsSchema.parse(props)));
} | /**
* Creates a new instance of the `ExtractPagesTask` class.
* @param props the task properties.
* @returns a new instance of the `ExtractPagesTask` class.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/text-processors/pdf-text-converter/src/definitions/tasks/extract-pages-task.ts#L184-L186 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.