A powerful text analytics library that provides easy integration with AWS Comprehend and Azure Text Analytics for language detection, sentiment analysis, entity recognition, and key phrase extraction.
A powerful text analytics library that provides easy integration with AWS Comprehend and Azure Text Analytics for language detection, sentiment analysis, entity recognition, and key phrase extraction.
``javascript
AWS_DEFAULT_REGION; //AWS Region for SQS service
AWS_ACCESS_KEY_ID; //AWS Access key for Event Bridge service
AWS_SECRET_ACCESS_KEY; //AWS Secret key for Event Bridge service
PLATFORM_TYPE; //Platform type (possible value CONTAINER)
CLOUD_PROVIDER; // Cloud service. Possible values azure, aws
`
- Installation
- Usage
- API Reference
- TextAnalyticsService
- detectLanguage
- detectEntities
- detectSentiment
- detectKeyPhrases
- textAnalysisComplete
- detectLanguageBatch
- detectEntitiesBatch
- detectSentimentBatch
- detectKeyPhrasesBatch
- textAnalysisCompleteBatch
- Examples
You can install the @qrvey/text-analytics package via npm. Run the following command in your terminal:
`bash`
npm install @qrvey/text-analytics
javascript
import TextAnalyticsServiceFactory from '@qrvey/text-analytics';async function main() {
const textAnalyticsService = await TextAnalyticsServiceFactory.createTextAnalyticsService();
const language = await textAnalyticsService.detectLanguage('This is a sample text.');
console.log(language);
}
`API Documentation
textAnalyticsService
The TextAnalyticsService provides methods for text analysis.detectLanguage
Detects the dominant language of the provided text.
$3
text: A string containing the text to analyze.$3
A promise that resolves to an object implementing IDetectDominantLanguageOutput.`javascript
detectLanguage(text: string): Promiseinterface IDetectDominantLanguageOutput {
code: string;
score: number;
}
`detectEntities
Detects entities in the provided text.$3
text: A string containing the text to analyze.
$3
A promise that resolves to an object implementing IDetectEntityOutput.
`javascript
detectEntities(text: string): Promise;interface IDetectEntityOutput {
entities: Entity[];
}
`
detectSentiment
Analyzes the sentiment of the provided text.$3
text: A string containing the text to analyze.
$3
A promise that resolves to an object implementing IDetectSentimentOutput.`javascript
detectSentiment(text: string): Promise;interface IDetectSentimentOutput {
sentiment: string;
score: {
negative: number;
positive: number;
neutral: number;
mixed: number;
};
}
`detectKeyPhrases
Detects key phrases in the provided text.$3
text: A string containing the text to analyze.
$3
A promise that resolves to an object implementing IKeyPhraseOutput.`javascript
detectKeyPhrases(text: string): Promise;interface IDetectKeyPhraseOutput {
keyPhrases: {
text: string;
score: number;
}[]
}
`textAnalysisComplete
Completes a full analysis of the provided text, including language detection, entity detection, sentiment analysis, and key phrase extraction.
$3
text: A string containing the text to analyze.
$3
A promise that resolves to an object implementing ICompleteTextAnalysisOutput.
`javascript
textAnalysisComplete(text: string): Promise;interface ICompleteTextAnalysisOutput {
language: IDetectDominantLanguageOutput;
entities: IDetectEntityOutput;
sentiment: IDetectSentimentOutput;
keyPhrases: IKeyPhrase[];
}
``