Cloud Natural Language API: Qwik Start | Google Cloud Skills Boost
Cloud Natural Language API를 사용하면 텍스트에서 항목을 추출하고 감정 및 구문 분석을 수행할 수 있습니다. 간단한 동영상 <A HREF="https://youtu.be/3iOtK0sRNMI">Cloud Natural Language를 통해 텍스트에서 유용한
www.cloudskillsboost.google
자연어 처리는 정말 방대한 범위의 주제이다. 이번 실습에서는 Cloud Natural Language API를 통해서 정보를 뽑아낼 것이다.
- Syntax Analysis : 각 문장들의 dependency parse tree를 만든다.
- Entity Recognition: 각 entity가 어떤 타입인지(사람, 기관, 장소 등등) labeling 한다.
- Sentiment Analysis: 문장의 전반적인 의미를 이해한다.
- Content Classification: 미리 정의된 700개 이상의 범주로 문서를 분류한다.
- Multi-Language: 다언어로 text를 쉽게 분석하도록 한다.
- Integrated REST API: REST API를 통해 접근할 수 있다.
신기한게 이 API는 한국어도 지원한다.
Cloud Shell을 켜서 다음 명령어들을 입력하자.
(프로젝트 이름을 변수로 설정해주고, NLP API를 사용하기 위해 새로운 service account를 만들어주고, 만든 service account에 접속하기 위한 credential을 생성해서 ~/key.json에 넣어주고, key.json 위치를 변수로 설정해준다.)
export GOOGLE_CLOUD_PROJECT=$(gcloud config get-value core/project)
gcloud iam service-accounts create my-natlang-sa \
--display-name "my natural language service account"
gcloud iam service-accounts keys create ~/key.json \
--iam-account my-natlang-sa@${GOOGLE_CLOUD_PROJECT}.iam.gserviceaccount.com
export GOOGLE_APPLICATION_CREDENTIALS="/home/USER/key.json"
Navigation menu -> Compute Engine
이번에도 실습을 진행하는 당신을 위한 vm instance가 미리 생성되어 있다.
SSH로 접속해서 다음 명령어로 request의 결과를 result.json에 저장하자.
gcloud ml language analyze-entities --content="Michelangelo Caravaggio, \
Italian painter, is known for 'The Calling of Saint Matthew'." > result.json
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_St_Matthew"
},
"name": "The Calling of Saint Matthew",
"salience": 0.031136045,
"type": "EVENT"
}
],
"language": "en"
}
'Cloud > Google Cloud Study Jam' 카테고리의 다른 글
Speech to Text Transcription with the Cloud Speech API (0) | 2022.03.28 |
---|---|
Entity and Sentiment Analysis with the Natural Language API (0) | 2022.03.28 |
Google Cloud Speech API: Qwik Start (0) | 2022.03.28 |
AI Platform: Qwik Start (0) | 2022.03.28 |
Perform Foundational Infrastructure Tasks in Google Cloud: Challenge Lab (0) | 2022.03.23 |
댓글