Guida introduttiva: Usare Java per chiamare il servizio cognitivo Analisi del testo di AzureQuickstart: Use Java to call the Azure Text Analytics Cognitive Service

Questo articolo illustra come rilevare la lingua, analizzare il sentiment, estrarre frasi chiave e identificare le entità collegate usando le  API Analisi del testo  con Java.This article shows you how to detect language, analyze sentiment, extract key phrases, and identify linked entities using the Text Analytics APIs with Java.

Per la documentazione tecnica delle API, vedere le definizioni delle API.Refer to the API definitions for technical documentation for the APIs.

PrerequisitiPrerequisites

Una chiave e un endpoint per una risorsa di Analisi del testo.A key and endpoint for a Text Analytics resource. I Servizi cognitivi di Azure sono rappresentati dalle risorse di Azure a cui si effettua la sottoscrizione.Azure Cognitive Services are represented by Azure resources that you subscribe to. Creare una risorsa per Analisi del testo usando il portale di Azure o l'interfaccia della riga di comando di Azure nel computer locale.Create a resource for Text Analytics using the Azure portal or Azure CLI on your local machine. È anche possibile:You can also:

È inoltre necessario avere la chiave di accesso e l'endpoint generati automaticamente durante l'iscrizione.You must also have the endpoint and access key that was generated for you during sign-up.

Rileva linguaDetect language

L'API Rilevamento lingua rileva la lingua di un documento di testo usando il  metodo per il rilevamento della lingua.The Language Detection API detects the language of a text document, using the Detect Language method.

  1. Creare le variabili di ambiente TEXT_ANALYTICS_SUBSCRIPTION_KEY e TEXT_ANALYTICS_ENDPOINT per l'endpoint e la chiave della sottoscrizione di Azure della risorsa.Create environment variables TEXT_ANALYTICS_SUBSCRIPTION_KEY and TEXT_ANALYTICS_ENDPOINT for your resource's Azure endpoint and subscription key. Se queste variabili di ambiente sono state create dopo aver iniziato a modificare l'applicazione, per accedervi sarà necessario chiudere e riaprire l'editor, l'IDE o la shell in uso.If you created these environment variables after you began editing the application, you will need to close and reopen the editor, IDE, or shell you are using to access the environment variables.
  2. Creare un nuovo progetto Java nell'IDE preferito o in una nuova cartella sul desktop.Create a new Java project in your favorite IDE (or new folder on your desktop). Creare una classe denominata DetectLanguage.java.Create a class named DetectLanguage.java.
  3. Aggiungere il codice fornito di seguito alla classe.Add the code provided below to your class.
  4. Assicurarsi che la libreria Gson sia installata.Make sure you have the Gson library installed.
  5. Eseguire il programma nell'IDE oppure usare la riga di comando per l'esecuzione (le istruzioni sono incluse nei commenti del codice).Run the program in your IDE or use the command line to run (instructions in the code comments).
import java.io.*;
import java.net.*;
import java.util.*;
import javax.net.ssl.HttpsURLConnection;

/*
 * Gson: https://github.com/google/gson
 * Maven info:
 *     groupId: com.google.code.gson
 *     artifactId: gson
 *     version: 2.8.1
 *
 * Once you have compiled or downloaded gson-2.8.1.jar, assuming you have placed it in the
 * same folder as this file (DetectLanguage.java), you can compile and run this program at
 * the command line as follows.
 *
 * Execute the following two commands to build and run (change gson version if needed):
 * javac DetectLanguage.java -classpath .;gson-2.8.1.jar -encoding UTF-8
 * java -cp .;gson-2.8.1.jar DetectLanguage
 */
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;

class Document {
    public String id, text;

    public Document(String id, String text){
        this.id = id;
        this.text = text;
    }
}

class Documents {
    public List<Document> documents;

    public Documents() {
        this.documents = new ArrayList<Document>();
    }
    public void add(String id, String text) {
        this.documents.add (new Document (id, text));
    }
}

public class DetectLanguage {
    static String subscription_key_var;
    static String subscription_key;
    static String endpoint_var;
    static String endpoint;

    public static void Initialize () throws Exception {
        subscription_key_var = "TEXT_ANALYTICS_SUBSCRIPTION_KEY";
        subscription_key = System.getenv(subscription_key_var);
        if (null == subscription_key) {
            throw new Exception ("Please set/export an environment variable named " + subscription_key_var);
        }

        endpoint_var = "TEXT_ANALYTICS_ENDPOINT";
        endpoint = System.getenv(endpoint_var);
        if (null == endpoint) {
            throw new Exception ("Please set/export an environment variable named " + endpoint_var);
        }
    }

    static String path = "/text/analytics/v2.1/languages";
    
    public static String GetLanguage (Documents documents) throws Exception {
        String text = new Gson().toJson(documents);
        byte[] encoded_text = text.getBytes("UTF-8");

        URL url = new URL(endpoint+path);
        HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty("Content-Type", "text/json");
        connection.setRequestProperty("Ocp-Apim-Subscription-Key", subscription_key);
        connection.setDoOutput(true);

        DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
        wr.write(encoded_text, 0, encoded_text.length);
        wr.flush();
        wr.close();

        StringBuilder response = new StringBuilder ();
        BufferedReader in = new BufferedReader(
        new InputStreamReader(connection.getInputStream()));
        String line;
        while ((line = in.readLine()) != null) {
            response.append(line);
        }
        in.close();

        return response.toString();
    }

    public static String prettify(String json_text) {
        JsonParser parser = new JsonParser();
        JsonObject json = parser.parse(json_text).getAsJsonObject();
        Gson gson = new GsonBuilder().setPrettyPrinting().create();
        return gson.toJson(json);
    }

    public static void main (String[] args) {
        try {
            Initialize();

            Documents documents = new Documents ();
            documents.add ("1", "This is a document written in English.");
            documents.add ("2", "Este es un document escrito en Español.");
            documents.add ("3", "这是一个用中文写的文件");

            String response = GetLanguage (documents);
            System.out.println (prettify (response));
        }
        catch (Exception e) {
            System.out.println (e);
        }
    }
}

Risposta di Rilevamento linguaLanguage detection response

Viene restituita una risposta con esito positivo in formato JSON, come illustrato nell'esempio seguente:A successful response is returned in JSON, as shown in the following example:


{
   "documents": [
      {
         "id": "1",
         "detectedLanguages": [
            {
               "name": "English",
               "iso6391Name": "en",
               "score": 1.0
            }
         ]
      },
      {
         "id": "2",
         "detectedLanguages": [
            {
               "name": "Spanish",
               "iso6391Name": "es",
               "score": 1.0
            }
         ]
      },
      {
         "id": "3",
         "detectedLanguages": [
            {
               "name": "Chinese_Simplified",
               "iso6391Name": "zh_chs",
               "score": 1.0
            }
         ]
      }
   ],
   "errors": [

   ]
}

Analizzare la valutazioneAnalyze sentiment

L'API Analisi del sentiment rileva il sentiment di un set di record di testo usando il metodo Sentiment.The Sentiment Analysis API detects the sentiment of a set of text records, using the Sentiment method. L'esempio seguente assegna un punteggio a due documenti, uno in inglese e un altro in spagnolo.The following example scores two documents, one in English and another in Spanish.

  1. Creare le variabili di ambiente TEXT_ANALYTICS_SUBSCRIPTION_KEY e TEXT_ANALYTICS_ENDPOINT per l'endpoint e la chiave della sottoscrizione di Azure della risorsa.Create environment variables TEXT_ANALYTICS_SUBSCRIPTION_KEY and TEXT_ANALYTICS_ENDPOINT for your resource's Azure endpoint and subscription key. Se queste variabili di ambiente sono state create dopo aver iniziato a modificare l'applicazione, per accedervi sarà necessario chiudere e riaprire l'editor, l'IDE o la shell in uso.If you created these environment variables after you began editing the application, you will need to close and reopen the editor, IDE, or shell you are using to access the environment variables.
  2. Creare un nuovo progetto Java nell'IDE preferito o in una nuova cartella sul desktop.Create a new Java project in your favorite IDE (or new folder on your desktop). Creare una classe denominata GetSentiment.java.Create a class in it named GetSentiment.java.
  3. Aggiungere il codice fornito di seguito alla classe.Add the code provided below to your class.
  4. Assicurarsi che la libreria Gson sia installata.Make sure you have the Gson library installed.
  5. Eseguire il programma nell'IDE oppure usare la riga di comando per l'esecuzione (le istruzioni sono incluse nei commenti del codice).Run the program in your IDE or use the command line to run (instructions in the code comments).
import java.io.*;
import java.net.*;
import java.util.*;
import javax.net.ssl.HttpsURLConnection;

/*
 * Gson: https://github.com/google/gson
 * Maven info:
 *     groupId: com.google.code.gson
 *     artifactId: gson
 *     version: 2.8.1
 *
 * Once you have compiled or downloaded gson-2.8.1.jar, assuming you have placed it in the
 * same folder as this file (GetSentiment.java), you can compile and run this program at
 * the command line as follows.
 *
 * Execute the following two commands to build and run (change gson version if needed):
 * javac GetSentiment.java -classpath .;gson-2.8.1.jar -encoding UTF-8
 * java -cp .;gson-2.8.1.jar GetSentiment
 */
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;

class Document {
    public String id, language, text;

    public Document(String id, String language, String text){
        this.id = id;
        this.language = language;
        this.text = text;
    }
}

class Documents {
    public List<Document> documents;

    public Documents() {
        this.documents = new ArrayList<Document>();
    }
    public void add(String id, String language, String text) {
        this.documents.add (new Document (id, language, text));
    }
}

public class GetSentiment {
    static String subscription_key_var;
    static String subscription_key;
    static String endpoint_var;
    static String endpoint;

    public static void Initialize () throws Exception {
        subscription_key_var = "TEXT_ANALYTICS_SUBSCRIPTION_KEY";
        subscription_key = System.getenv(subscription_key_var);
        if (null == subscription_key) {
            throw new Exception ("Please set/export an environment variable named " + subscription_key_var);
        }

        endpoint_var = "TEXT_ANALYTICS_ENDPOINT";
        endpoint = System.getenv(endpoint_var);
        if (null == endpoint) {
            throw new Exception ("Please set/export an environment variable named " + endpoint_var);
        }
    }

    static String path = "/text/analytics/v2.1/sentiment";
    
    public static String getTheSentiment (Documents documents) throws Exception {
        String text = new Gson().toJson(documents);
        byte[] encoded_text = text.getBytes("UTF-8");

        URL url = new URL(endpoint+path);
        HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty("Content-Type", "text/json");
        connection.setRequestProperty("Ocp-Apim-Subscription-Key", subscription_key);
        connection.setDoOutput(true);

        DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
        wr.write(encoded_text, 0, encoded_text.length);
        wr.flush();
        wr.close();

        StringBuilder response = new StringBuilder ();
        BufferedReader in = new BufferedReader(
        new InputStreamReader(connection.getInputStream()));
        String line;
        while ((line = in.readLine()) != null) {
            response.append(line);
        }
        in.close();

        return response.toString();
    }

    public static String prettify(String json_text) {
        JsonParser parser = new JsonParser();
        JsonObject json = parser.parse(json_text).getAsJsonObject();
        Gson gson = new GsonBuilder().setPrettyPrinting().create();
        return gson.toJson(json);
    }

    public static void main (String[] args) {
        try {
            Initialize();

            Documents documents = new Documents ();
            documents.add ("1", "en", "I really enjoy the new XBox One S. It has a clean look, it has 4K/HDR resolution and it is affordable.");
            documents.add ("2", "es", "Este ha sido un dia terrible, llegué tarde al trabajo debido a un accidente automobilistico.");

            String response = getTheSentiment (documents);
            System.out.println (prettify (response));
        }
        catch (Exception e) {
            System.out.println (e);
        }
    }
}

Risposta di Analisi del sentimentSentiment analysis response

Il risultato viene considerato positivo se il punteggio assegnato è più vicino a 1.0 e negativo se il punteggio assegnato è più vicino a 0.0.The result is measured as positive if it's scored closer to 1.0 and negative if it's scored closer to 0.0. Viene restituita una risposta con esito positivo in formato JSON, come illustrato nell'esempio seguente:A successful response is returned in JSON, as shown in the following example:

{
   "documents": [
      {
         "score": 0.99984133243560791,
         "id": "1"
      },
      {
         "score": 0.024017512798309326,
         "id": "2"
      },
   ],
   "errors": [   ]
}

Estrarre le frasi chiaveExtract key phrases

L'API Estrazione frasi chiave consente di estrarre le frasi chiave da un documento di testo usando il metodo per le frasi chiave.The Key Phrase Extraction API extracts key-phrases from a text document, using the Key Phrases method. L'esempio seguente estrae le frasi chiave per i documenti in inglese e in spagnolo.The following example extracts Key phrases for both English and Spanish documents.

  1. Creare le variabili di ambiente TEXT_ANALYTICS_SUBSCRIPTION_KEY e TEXT_ANALYTICS_ENDPOINT per l'endpoint e la chiave della sottoscrizione di Azure della risorsa.Create environment variables TEXT_ANALYTICS_SUBSCRIPTION_KEY and TEXT_ANALYTICS_ENDPOINT for your resource's Azure endpoint and subscription key. Se queste variabili di ambiente sono state create dopo aver iniziato a modificare l'applicazione, per accedervi sarà necessario chiudere e riaprire l'editor, l'IDE o la shell in uso.If you created these environment variables after you began editing the application, you will need to close and reopen the editor, IDE, or shell you are using to access the environment variables.
  2. Creare un nuovo progetto Java nell'IDE preferito o in una nuova cartella sul desktop.Create a new Java project in your favorite IDE (or new folder on your desktop). Creare una classe denominata GetKeyPhrases.java.Create a class in it called GetKeyPhrases.java.
  3. Aggiungere il codice fornito di seguito alla classe.Add the code provided below to your class.
  4. Assicurarsi che la libreria Gson sia installata.Make sure you have the Gson library installed.
  5. Eseguire il programma nell'IDE oppure usare la riga di comando per l'esecuzione (le istruzioni sono incluse nei commenti del codice).Run the program in your IDE or use the command line to run (instructions in the code comments).
import java.io.*;
import java.net.*;
import java.util.*;
import javax.net.ssl.HttpsURLConnection;

/*
 * Gson: https://github.com/google/gson
 * Maven info:
 *     groupId: com.google.code.gson
 *     artifactId: gson
 *     version: 2.8.1
 *
 * Once you have compiled or downloaded gson-2.8.1.jar, assuming you have placed it in the
 * same folder as this file (GetKeyPhrases.java), you can compile and run this program at
 * the command line as follows.
 *
 * Execute the following two commands to build and run (change gson version if needed):
 * javac GetKeyPhrases.java -classpath .;gson-2.8.1.jar -encoding UTF-8
 * java -cp .;gson-2.8.1.jar GetKeyPhrases
 */
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;

class Document {
    public String id, language, text;

    public Document(String id, String language, String text){
        this.id = id;
        this.language = language;
        this.text = text;
    }
}

class Documents {
    public List<Document> documents;

    public Documents() {
        this.documents = new ArrayList<Document>();
    }
    public void add(String id, String language, String text) {
        this.documents.add (new Document (id, language, text));
    }
}

public class GetKeyPhrases {
    static String subscription_key_var;
    static String subscription_key;
    static String endpoint_var;
    static String endpoint;

    public static void Initialize () throws Exception {
        subscription_key_var = "TEXT_ANALYTICS_SUBSCRIPTION_KEY";
        subscription_key = System.getenv(subscription_key_var);
        if (null == subscription_key) {
            throw new Exception ("Please set/export an environment variable named " + subscription_key_var);
        }

        endpoint_var = "TEXT_ANALYTICS_ENDPOINT";
        endpoint = System.getenv(endpoint_var);
        if (null == endpoint) {
            throw new Exception ("Please set/export an environment variable named " + endpoint_var);
        }
    }

    static String path = "/text/analytics/v2.1/keyPhrases";
    
    public static String GetKeyPhrases (Documents documents) throws Exception {
        String text = new Gson().toJson(documents);
        byte[] encoded_text = text.getBytes("UTF-8");

        URL url = new URL(endpoint+path);
        HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty("Content-Type", "text/json");
        connection.setRequestProperty("Ocp-Apim-Subscription-Key", subscription_key);
        connection.setDoOutput(true);

        DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
        wr.write(encoded_text, 0, encoded_text.length);
        wr.flush();
        wr.close();

        StringBuilder response = new StringBuilder ();
        BufferedReader in = new BufferedReader(
        new InputStreamReader(connection.getInputStream()));
        String line;
        while ((line = in.readLine()) != null) {
            response.append(line);
        }
        in.close();

        return response.toString();
    }

    public static String prettify(String json_text) {
        JsonParser parser = new JsonParser();
        JsonObject json = parser.parse(json_text).getAsJsonObject();
        Gson gson = new GsonBuilder().setPrettyPrinting().create();
        return gson.toJson(json);
    }

    public static void main (String[] args) {
        try {
            Initialize();

            Documents documents = new Documents ();
            documents.add ("1", "en", "I really enjoy the new XBox One S. It has a clean look, it has 4K/HDR resolution and it is affordable.");
            documents.add ("2", "es", "Si usted quiere comunicarse con Carlos, usted debe de llamarlo a su telefono movil. Carlos es muy responsable, pero necesita recibir una notificacion si hay algun problema.");
            documents.add ("3", "en", "The Grand Hotel is a new hotel in the center of Seattle. It earned 5 stars in my review, and has the classiest decor I've ever seen.");

            String response = GetKeyPhrases (documents);
            System.out.println (prettify (response));
        }
        catch (Exception e) {
            System.out.println (e);
        }
    }
}

Risposta di Estrazione frasi chiaveKey phrase extraction response

Viene restituita una risposta con esito positivo in formato JSON, come illustrato nell'esempio seguente:A successful response is returned in JSON, as shown in the following example:

{
   "documents": [
      {
         "keyPhrases": [
            "HDR resolution",
            "new XBox",
            "clean look"
         ],
         "id": "1"
      },
      {
         "keyPhrases": [
            "Carlos",
            "notificacion",
            "algun problema",
            "telefono movil"
         ],
         "id": "2"
      },
      {
         "keyPhrases": [
            "new hotel",
            "Grand Hotel",
            "review",
            "center of Seattle",
            "classiest decor",
            "stars"
         ],
         "id": "3"
      }
   ],
   "errors": [  ]
}

Identificare le entitàIdentify entities

L'API Entità identifica le entità note in un documento di testo usando il metodo Entities.The Entities API identifies well-known entities in a text document, using the Entities method. Le entità estraggono parole dal testo, ad esempio "United States" e quindi forniscono il tipo e/o il collegamento a Wikipedia relativo alla parola.Entities extract words from text, like "United States", then give you the type and/or Wikipedia link for this word(s). Il tipo di "United States" è location, mentre il collegamento a Wikipedia è https://en.wikipedia.org/wiki/United_States.The type for "United States" is location, while the link to Wikipedia is https://en.wikipedia.org/wiki/United_States. L'esempio seguente identifica le entità per i documenti in inglese.The following example identifies entities for English documents.

  1. Creare le variabili di ambiente TEXT_ANALYTICS_SUBSCRIPTION_KEY e TEXT_ANALYTICS_ENDPOINT per l'endpoint e la chiave della sottoscrizione di Azure della risorsa.Create environment variables TEXT_ANALYTICS_SUBSCRIPTION_KEY and TEXT_ANALYTICS_ENDPOINT for your resource's Azure endpoint and subscription key. Se queste variabili di ambiente sono state create dopo aver iniziato a modificare l'applicazione, per accedervi sarà necessario chiudere e riaprire l'editor, l'IDE o la shell in uso.If you created these environment variables after you began editing the application, you will need to close and reopen the editor, IDE, or shell you are using to access the environment variables.
  2. Creare un nuovo progetto Java nell'IDE preferito o in una nuova cartella sul desktop.Create a new Java project in your favorite IDE (or new folder on your desktop). Creare una classe denominata GetEntities.java.Create a class in it named GetEntities.java.
  3. Aggiungere il codice fornito di seguito alla classe.Add the code provided below to your class.
  4. Assicurarsi che la libreria Gson sia installata.Make sure you have the Gson library installed.
  5. Eseguire il programma nell'IDE oppure usare la riga di comando per l'esecuzione (le istruzioni sono incluse nei commenti del codice).Run the program in your IDE or use the command line to run (instructions in the code comments).
import java.io.*;
import java.net.*;
import java.util.*;
import javax.net.ssl.HttpsURLConnection;

/*
 * Gson: https://github.com/google/gson
 * Maven info:
 *     groupId: com.google.code.gson
 *     artifactId: gson
 *     version: 2.8.1
 *
 * Once you have compiled or downloaded gson-2.8.1.jar, assuming you have placed it in the
 * same folder as this file (GetEntities.java), you can compile and run this program at
 * the command line as follows.
 *
 * Execute the following two commands to build and run (change gson version if needed):
 * javac GetEntities.java -classpath .;gson-2.8.1.jar -encoding UTF-8
 * java -cp .;gson-2.8.1.jar GetEntities
 */
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;

class Document {
    public String id, language, text;

    public Document(String id, String language, String text){
        this.id = id;
        this.language = language;
        this.text = text;
    }
}

class Documents {
    public List<Document> documents;

    public Documents() {
        this.documents = new ArrayList<Document>();
    }
    public void add(String id, String language, String text) {
        this.documents.add (new Document (id, language, text));
    }
}

public class GetEntities {
    static String subscription_key_var;
    static String subscription_key;
    static String endpoint_var;
    static String endpoint;

    public static void Initialize () throws Exception {
        subscription_key_var = "TEXT_ANALYTICS_SUBSCRIPTION_KEY";
        subscription_key = System.getenv(subscription_key_var);
        if (null == subscription_key) {
            throw new Exception ("Please set/export an environment variable named " + subscription_key_var);
        }

        endpoint_var = "TEXT_ANALYTICS_ENDPOINT";
        endpoint = System.getenv(endpoint_var);
        if (null == endpoint) {
            throw new Exception ("Please set/export an environment variable named " + endpoint_var);
        }
    }

    static String path = "/text/analytics/v2.1/entities";
    
    public static String GetEntities (Documents documents) throws Exception {
        String text = new Gson().toJson(documents);
        byte[] encoded_text = text.getBytes("UTF-8");

        URL url = new URL(endpoint+path);
        HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty("Content-Type", "text/json");
        connection.setRequestProperty("Ocp-Apim-Subscription-Key", subscription_key);
        connection.setDoOutput(true);

        DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
        wr.write(encoded_text, 0, encoded_text.length);
        wr.flush();
        wr.close();

        StringBuilder response = new StringBuilder ();
        BufferedReader in = new BufferedReader(
        new InputStreamReader(connection.getInputStream()));
        String line;
        while ((line = in.readLine()) != null) {
            response.append(line);
        }
        in.close();

        return response.toString();
    }

    public static String prettify(String json_text) {
        JsonParser parser = new JsonParser();
        JsonObject json = parser.parse(json_text).getAsJsonObject();
        Gson gson = new GsonBuilder().setPrettyPrinting().create();
        return gson.toJson(json);
    }

    public static void main (String[] args) {
        try {
            Initialize();

            Documents documents = new Documents ();
            documents.add ("1", "en", "Microsoft is an It company.");

            String response = GetEntities (documents);
            System.out.println (prettify (response));
        }
        catch (Exception e) {
            System.out.println (e);
        }
    }
}

Risposta di estrazione di entitàEntity extraction response

Viene restituita una risposta con esito positivo in formato JSON, come illustrato nell'esempio seguente:A successful response is returned in JSON, as shown in the following example:

{  
   "documents":[  
      {  
         "id":"1",
         "entities":[  
            {  
               "name":"Microsoft",
               "matches":[  
                  {  
                     "wikipediaScore":0.20872054383103444,
                     "entityTypeScore":0.99996185302734375,
                     "text":"Microsoft",
                     "offset":0,
                     "length":9
                  }
               ],
               "wikipediaLanguage":"en",
               "wikipediaId":"Microsoft",
               "wikipediaUrl":"https://en.wikipedia.org/wiki/Microsoft",
               "bingId":"a093e9b9-90f5-a3d5-c4b8-5855e1b01f85",
               "type":"Organization"
            },
            {  
               "name":"Technology company",
               "matches":[  
                  {  
                     "wikipediaScore":0.82123868042800585,
                     "text":"It company",
                     "offset":16,
                     "length":10
                  }
               ],
               "wikipediaLanguage":"en",
               "wikipediaId":"Technology company",
               "wikipediaUrl":"https://en.wikipedia.org/wiki/Technology_company",
               "bingId":"bc30426e-22ae-7a35-f24b-454722a47d8f"
            }
         ]
      }
   ],
    "errors":[]
}

Passaggi successiviNext steps

Vedere ancheSee also

Panoramica di Analisi del testoText Analytics overview
Domande frequentiFrequently asked questions (FAQ)