본문 바로가기

카테고리 없음

python 패키지의 GoogleCloudTranslation와 Googletrans 차이점

 

GoogleCloudTranslation

발자가 Python을 사용하여

Google Cloud Translation API에 액세스할 수 있도록

Google Cloud에서 제공하는 패키지입니다.

 

ClientAPI를 사용하여 텍스트를 번역하고

다른 작업을 수행하는 데 사용할 수 있는

클라이언트 클래스를 제공합니다 .

 

GoogleTrans

Google에서 제공하는 무료 웹 기반 번역 서비스인

Google 번역 서비스와 유사한 인터페이스를

제공하는 타사 Python 패키지입니다.

비공식 Google Translate API를 사용하며

Google과 제휴하거나 지원하지 않습니다.

 

이 두 패키지 사이에는 몇 가지 주요 차이점이 있습니다.

  • GoogleCloudTranslation은 Google Cloud에서 제공하는 공식 패키지이며 GoogleTranslation은 타사 패키지입니다.
  • GoogleCloudTranslation을 사용하면 무료 Google 번역 서비스보다 더 높은 품질의 번역과 더 많은 기능을 제공하는 유료 서비스인 Google Cloud Translation API에 액세스할 수 있습니다. GoogleTrans를 사용하면 무료 Google 번역 서비스에 액세스할 수 있습니다.
  • GoogleCloudTranslation을 사용하려면 Google Cloud 계정과 API 키가 필요하지만 GoogleTranslation은 특별한 자격 증명이 필요하지 않습니다.
  • GoogleCloudTranslation은 번역 프로세스를 사용자 정의하고 언어 감지 및 용어집 지원과 같은 고급 기능을 사용하는 기능을 포함하여 GoogleTrans보다 더 포괄적인 기능 세트를 제공합니다.

 

google-cloud-translate 패키지 사용

패키지를 사용하려면

Google Cloud Console 을 사용하여

google-cloud-translate패키지를 설치하고

API 키를 가져와야 합니다.

pip다음 Client은 패키지의 클래스를 사용하여

google-cloud-translate텍스트 문자열을 영어에서

프랑스어로 번역하는 방법의 예입니다.

 

# Import the package
from google.cloud import translate_v2 as translate

# Create a client object
client = translate.Client()

# Set the target language
target = 'fr'

# Translate the text
translation = client.translate(text='Hello, world!', target_language=target)

# Print the translated text
print(translation['translatedText'])

 

 

이 예는 "Bonjour, le monde!"를 인쇄합니다.

콘솔에. google-cloud-translate패키지 및 Google Cloud Translation API 사용에

대한 자세한 내용은 다음 문서를 참조하세요.

https://cloud.google.com/translate/docs/quickstarts/quickstart-client-libraries?hl=en

 

googletrans 패키지 사용

패키지 를 사용하려면 를 사용하여

googletrans패키지를 설치해야 합니다

다음 Translator은 패키지의 클래스를 사용하여

googletrans텍스트 문자열을 영어에서

프랑스어로 번역하는 방법의 예입니다.

 

# Import the package
from googletrans import Translator

# Create a translator object
translator = Translator()

# Translate the text
translation = translator.translate('Hello, world!', dest='fr')

# Print the translated text
print(translation.text)

 

이 예제는 "Bonjour, le monde!"도 인쇄합니다. 콘솔에.

googletrans패키지 및 Google 번역 서비스 사용에 대한 자세한 내용은 다음 문서를 참조하십시오.

https://py-googletrans.readthedocs.io/en/latest/

 

Googletrans: Free and Unlimited Google translate API for Python — Googletrans 3.0.0 documentation

Googletrans: Free and Unlimited Google translate API for Python Googletrans is a free and unlimited python library that implemented Google Translate API. This uses the Google Translate Ajax API to make calls to such methods as detect and translate. Feature

py-googletrans.readthedocs.io

 

 

google-cloud-translate 설치 및  api키 발급 밥는 방법

 

pip install google-cloud-translate

 

Google Cloud Console에서 API 키를 얻으려면

Google Cloud 계정이 있어야 하고 프로젝트를 만들어야 합니다.

다음 안내에 따라 Google Cloud 계정에 가입하고

새 프로젝트를 만들 수 있습니다.

 

https://cloud.google.com/docs/getting-started?hl=ko

프로젝트를 만든 후에는 다음 단계에 따라 프로젝트에

Google Cloud Translation API를 사용 설정할 수 있습니다.

  1. 클라우드 콘솔로 이동: https://console.cloud.google.com/
  2. 프로젝트 드롭다운을 클릭하고 API를 활성화하려는 프로젝트를 선택합니다.
  3. 햄버거 메뉴를 클릭하고 API 및 서비스 > 라이브러리를 선택합니다.
  4. "Cloud Translation API"를 검색하고 결과를 클릭합니다.
  5. 활성화 버튼을 클릭합니다.

API가 활성화되면 다음 단계에 따라 API 키를 생성할 수 있습니다.

  1. 클라우드 콘솔로 이동: https://console.cloud.google.com/
  2. 프로젝트 드롭다운을 클릭하고 API 키를 생성하려는 프로젝트를 선택합니다.
  3. 햄버거 메뉴를 클릭하고 API 및 서비스 > 자격 증명을 선택합니다.
  4. 자격 증명 만들기 버튼을 클릭하고 API 키를 선택합니다.
  5. 팝업 창에 API 키가 표시됩니다. 닫기 버튼을 클릭하여 팝업을 닫습니다.

google-cloud-translatePython 코드에서 패키지 를 사용할 때

이 API 키를 사용해야 합니다 .

Client다음과 같이 새 Client객체를 생성할 때 생

성자 에 API 키를 전달할 수 있습니다 .

 
from google.cloud import translate_v2 as translate

client = translate.Client(api_key='YOUR_API_KEY')

Google Cloud Translation API 사용에 대한 자세한 내용은 다음 문서를 참조하세요.

https://cloud.google.com/translate/docs/quickstarts/quickstart-client-libraries?hl=en