cognixir v0.4.0 Cognixir.TextAnalytics

Provides functions for text analytics, including language and topic detection.

Summary

Functions

Tries to extract the key phrases for given text. You need to submit the language of the text, too

Tries to detect the language for the given string

Tries to detect the sentiment for given text. Returns a score between 0 and 1. Scores close to 1 indicate positive sentiment, closer to 0 negative sentiment. You need to submit the language of the text, too

Tries to detect the topics for the given documents. You must provide at least 100 documents. This function returns an url where you can fetch your results with a get request after some delay

Functions

detect_key_phrases(text, language)

Tries to extract the key phrases for given text. You need to submit the language of the text, too.

Parameters

  • text: String that will be analyzed
  • language: language of the text (en, ja, de, es)

Examples

iex> Cognixir.TextAnalytics.detect_key_phrases(“I’am looking for bananas. Do you have bananas?”, “en”)

{ :ok, [“I’am”, “bananas”] }

detect_language(text)

Tries to detect the language for the given string

Parameters

  • text: String that will be analyzed

Examples

iex> Cognixir.TextAnalytics.detect_language(“my english text”)

{ :ok, %{“iso6391Name” => “en”, “name” => “English”, “score” => 1.0} }

detect_sentiment(text, language)

Tries to detect the sentiment for given text. Returns a score between 0 and 1. Scores close to 1 indicate positive sentiment, closer to 0 negative sentiment. You need to submit the language of the text, too.

Parameters

  • text: String that will be analyzed
  • language: language of the text (en, ja, de, es)

Examples

iex> Cognixir.TextAnalytics.detect_sentiment(“I’am a happy person”, “en”)

{ :ok, 0.9599599 }

detect_topics(documents, stop_words \\ [])

Tries to detect the topics for the given documents. You must provide at least 100 documents. This function returns an url where you can fetch your results with a get request after some delay.

Parameters

  • documents: A string list containing your documents
  • stop_words: A list containing stop words

Examples

iex> Cognixir.TextAnalytics.detect_topics([“text1”, “text2”, “text3”, …], [“the”])

{ :ok, “https://westus.api.cognitive.microsoft.com/text/analytics/v2.0/operations/token” }