Superface

Analyze plain text sentiment

language/analyze-plain-text-sentiment@1.0.1
2 providers

Analyze plain text sentiment

Determines writer's attitude in the text as positive, negative, or neutral.

Input
Text
Language code
Result
Sentiment
Score

1.Choose a provider

2.Use AnalyzePlainTextSentiment with mock in your code

Below instructions are for our Node.js SDK. Use OneService for other languages.
npm i @superfaceai/one-sdk
const { SuperfaceClient } = require('@superfaceai/one-sdk');

// You can manage tokens here: https://superface.ai/insights
const sdk = new SuperfaceClient({ sdkAuthToken: '<< Login to get your token >>' });

async function run() {
  // Load the profile
  const profile = await sdk.getProfile('language/analyze-plain-text-sentiment@1.0.1');

  // Use the profile
  const result = await profile
    .getUseCase('AnalyzePlainTextSentiment')
    .perform({
      text: 'Enjoy your stay.',
      languageCode: 'en'
    }, {
      provider: 'mock'
    });

  // Handle the result
  try {
    const data = result.unwrap();
    console.log(data);
  } catch (error) {
    console.error(error);
  }
}

run();

Structure details

Input (object)

text
The text to be analyzed.
languageCode
The language of the text expressed as a ISO 639‑1 language code, e.g. 'en'.

Example

{
  "text": "Enjoy your stay.",
  "languageCode": "en"
}

Result (object)

sentiment
The overal writer's attitude in the analyzed text.
score
Score of the sentiment ranges between -1.0 (negative) and 1.0 (positive) and corresponds to the overall emotional leaning of the text.

Example

{
  "sentiment": "positive",
  "score": 0.9
}

Implementation details

Provider
mock
Use case
AnalyzePlainTextSentiment
Author
@superface
Source
Verified