Skip to content
This repository was archived by the owner on Aug 12, 2022. It is now read-only.

Analyse text

Jerome Houdan edited this page Oct 5, 2016 · 21 revisions

You can use the Recast.AI API to analyse your text or your audio file, and extract useful informations from it.

Usage

Start by instantiating a Client instance, as showed on this page.

ES5

var recastai = require('recastai')

var client = new recastai.Client(YOUR_TEXT, YOUR_LANGUAGE)

ES6

import { Client } from 'recastai'

const client = new Client(YOUR_TEXT, YOUR_LANGUAGE)

Text analyse

Use the textRequest method of the client, and after a call to our API, we will return to you a Response object containing the enriched entities extracted from your text, the intents detected and some more useful informations (a comprehensive list can be found here).

Please note that the length of the text is limited to 256 chars by call.

client.textRequest(YOUR_TEXT)
  .then(function(res) {
    // get the intent detected
    var intent = res.intent()
   
    // get all the location entities extracted from your text
    var locations = res.all('location')

    // Do your code
  }).catch(function(err) {
    // Handle error
  })

Audio analyse

Use the fileRequest method of the client, and after a call to our API, we will return to you a Response object containing the enriched entities extracted from your audio file, the intents detected and some more useful informations (a comprehensive list can be found here).

Please note that the length of the audio is limited to 10 seconds by call.

client.fileRequest(YOUR_FILE_REQUEST)
  .then(function(res) {
    // get the intent detected
    var intent = res.intent()
   
    // get all the location entities extracted from your text
    var locations = res.all('location')

    // Do your code
  }).catch(function(err) {
    // Handle error
  })

More

For more information, do not hesitate to dive deeper in the documentation, you'll find the full specs of each classes with attributes and methods detailed. You can also look at the code as it is commented ;-)

Clone this wiki locally