CS log

Cloud Natural Language API: Qwik Start 본문

AI/NLP

Cloud Natural Language API: Qwik Start

sj.cath 2024. 9. 23. 19:24

The Cloud Natural Language API is a cloud-based service that provides natural language processing capabilities. It can be used to analyze text, identify entities, extract information, and answer questions.

 

Cloud Natural Language API features

Entity Recognition: Identify entities in text, such as people, places, and things.

Sentiment Analysis: Analyze the sentiment of text, such as whether it is positive, negative, or neutral.

Information Extraction: Extract information from text, such as dates, times, and price.

Question Answering: Answer questions about text.

 

1. entity recognition

student-01-84399fc48df0@linux-instance:~$ gcloud ml language analyze-entities --content="Michelangelo Caravaggio, Italian painter, is known for 'The Calling of Saint Matthew'." > result.json
student-01-84399fc48df0@linux-instance:~$ cat result.json
{
  "entities": [
    {
      "mentions": [
        {
          "text": {
            "beginOffset": 0,
            "content": "Michelangelo Caravaggio"
          },
          "type": "PROPER"
        },
        {
          "text": {
            "beginOffset": 33,
            "content": "painter"
          },
          "type": "COMMON"
        }
      ],
      "metadata": {
        "mid": "/m/020bg",
        "wikipedia_url": "https://en.wikipedia.org/wiki/Caravaggio"
      },
      "name": "Michelangelo Caravaggio",
      "salience": 0.82904786,
      "type": "PERSON"
    },
    {
      "mentions": [
        {
          "text": {
            "beginOffset": 25,
            "content": "Italian"
          },
          "type": "PROPER"
        }
      ],
      "metadata": {},
      "name": "Italian",
      "salience": 0.13981608,
      "type": "LOCATION"
    },
    {
      "mentions": [
        {
          "text": {
            "beginOffset": 56,
            "content": "The Calling of Saint Matthew"
          },
          "type": "PROPER"
        }
      ],
      "metadata": {
        "mid": "/m/085_p7",
        "wikipedia_url": "https://en.wikipedia.org/wiki/The_Calling_of_Saint_Matthew"
      },
      "name": "The Calling of Saint Matthew",
      "salience": 0.031136045,
      "type": "EVENT"
    }
  ],
  "language": "en"
}

Read through your results. For each "entity" in the response, you'll see:

  • The entity name and type, a person, location, event, etc.
  • metadata, an associated Wikipedia URL if there is one.
  • salience, and the indices of where this entity appeared in the text. Salience is a number in the [0,1] range that refers to the centrality of the entity to the text as a whole.
  • mentions, which is the same entity mentioned in different ways.
salience : 전체 텍스트에서 해당 개체가 중요한 정도(max 1.0)

 

 

'AI > NLP' 카테고리의 다른 글

Speech to Text Transcription with the Cloud Speech API  (2) 2024.09.25
Entity and Sentiment Analysis with the Natural Language API  (2) 2024.09.23
Speech-to-text API  (0) 2024.09.23
Intro to ML: Language Processing  (0) 2024.09.23
GPT-1  (1) 2024.09.18