Skip to content

henomis/meaningcloud-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MeaningCloud SDK for Go

Build Status GoDoc Go Report Card GitHub release

This is MeaningCloud's unofficial Go client, designed to enable you to use MeaningCloud's services easily from your own applications.

MeaningCloud

MeaningCloud is a cloud-based text analytics service that through APIs allows you extract meaning from all kind of unstructured content: social conversation, articles, documents.

SDK versions

v1.1
Deep Categorization deepcategorization-1.0
Topics Extraction topics-2.0
Text Classification class-2.0
Sentiment Analysis sentiment-2.1
Language Identification lang-4.0
Parser parser-2.0
Corporate Reputation reputation-2.0
Text Clustering clustering-1.1
Summarization summarization-1.0
Document Structure documentstructure-1.0

Getting started

Installation

You can load meaningcloud-go into your project by using:

go get github.com/henomis/meaningcloud-go

Configuration

The only thing you need to start using MeaningCloud's APIs is the developer license key. Copy it and paste it in the corresponding place in the code, select the API you want to use and the parameters you want to use, and that's it.

Usage

Please refer to the examples folder to see how to use the SDK.

Here below a simple usage example:

package main

import (
	"encoding/json"
	"fmt"
	"log"

	meaningcloudgo "github.com/henomis/meaningcloud-go"
	"github.com/henomis/meaningcloud-go/pkg/request"
)

const Key = "YOUR_API_KEY"

func main() {

	meaningCloudClient := meaningcloudgo.New(
		meaningcloudgo.MeaningCloudEndpoint,
		Key,
		10 * time.Second,
	)

	// Text analysis
	request := &request.Sentiment{}
	request.Key = Key
	request.InputLanguage = "en"
	request.Text = "Main dishes were quite good, but desserts were too sweet for me."
	response, err := meaningCloudClient.SentimentAnalysis(request)
	if err != nil {
		log.Fatalf("error while performing analysis: %v", err)
	}

	if !response.Status.IsSuccess() {
		log.Fatalf("error: %s", response.Status.Error())
	}

	bytes, _ := json.MarshalIndent(response, "", "  ")
	fmt.Println(string(bytes))

}