본문 바로가기
프로그램

[파이썬] 영어 번역 하기(구글번역 패키지(googletrans))

by 오디세이99 2022. 11. 13.
728x90
반응형

 

from googletrans import Translator

trans = Translator()

txt = trans.translate("hello", src='en', dest='ko')
print(txt.text)

결과

안녕하세요

 

 

from googletrans import Translator

trans = Translator()

ss = 'Herodotus, a 5th-century BC Greek historian, is often considered the "father of history" in the Western tradition,[12] although he has also been criticized as the "father of lies".[13][14] Along with his contemporary Thucydides, he helped form the foundations for the modern study of past events and societies.[15] Their works continue to be read today, and the gap between the culture-focused Herodotus and the military-focused Thucydides remains a point of contention or approach in modern historical writing. In East Asia, a state chronicle, the Spring and Autumn Annals, was reputed to date from as early as 722 BC, although only 2nd-century BC texts have survived.'

txt = trans.translate(ss, src='en', dest='ko')
print(txt.text)

결과

기원전 5 세기 그리스 역사가 인 헤로도투스 (Herodotus)는 종종 서구 전통에서 "역사의 아버지"로 간주되었다.그의 현대적인 Thucydides와 함께, 그는 과거 사건과 사회에 대한 현대 연구의 기초를 형성하는 데 도움을 주었다. [15]그들의 작품은 오늘날에도 계속 읽히고 있으며, 문화 중심의 헤로도투스와 군사 중심의 투키디데스 사이의 격차는 현대의 역사적 글쓰기에서 논쟁이나 접근의 지점으로 남아 있습니다.동아시아에서, 봄과 가을 연대기 인 주 대대는 기원전 722 년 초부터 2 세기의 BC 텍스트 만 살아 남았습니다.

 

 

text 파일 내용 번역하기

from os import linesep

import googletrans

translator = googletrans.Translator ()

file_path = "영어to한글.txt"

with open (file_path, 'r', encoding='utf-8') as f :
    lines = f.readlines ()

# print(ines)

for line in lines:
    # print(line)
    if len(line.strip()) == 0 or line == '\n':
        continue
        
    lst = line.split('.')
    # print('lst=',len(lst))
    for ss in lst:
        if len(ss.strip()) == 0:
            continue
        result = translator.translate (ss.strip(), dest = "ko") #########
        print(ss.strip())
        print (result.text)

결과

History (from Ancient Greek ἱστορία (historía) 'inquiry; knowledge acquired by investigation')[1] is the study and the documentation of the past
역사 (고대 그리스어 ἱστορία (Historía) '질문; 조사에 의해 습득 한 지식'[1]은 과거의 연구와 문서입니다.
[2][3] Events before the invention of writing systems are considered prehistory
[2] [3] 작문 시스템의 발명 전 사건은 선사 시대로 간주됩니다.
"History" is an umbrella term comprising past events as well as the memory, discovery, collection, organization, presentation, and interpretation of these events
"역사"
Historians seek knowledge of the past using historical sources such as written documents, oral accounts, art and material artifacts, and ecological markers
역사가들은 서면 문서, 구두 기록, 예술 및 물질 유물, 생태 학적 마커와 같은 역사적 출처를 사용하여 과거에 대한 지식을 찾습니다.
[4]
[4]
History is also an academic discipline which uses narrative to describe, examine, question, and analyze past events, and investigate their patterns of cause and effect
역사는 또한 이야기를 사용하여 과거 사건을 설명, 조사, 질문 및 분석하고 원인과 결과 패턴을 조사하는 학문적 징계입니다.
[5][6] Historians often debate which narrative best explains an event, as well as the significance of different causes and effects
[5] [6] 역사가들은 종종 어떤 이야기가 사건을 가장 잘 설명하는지에 대해 토론하고, 다른 원인과 효과의 중요성
Historians also debate the nature of history as an end in itself, as well as its usefulness to give perspective on the problems of the present
역사가들은 또한 역사의 본질을 그 자체로 끝으로 삼고 현재의 문제에 대한 관점을 제시하는 유용성에 대해서도 토론합니다.
[5][7][8][9]
[5] [7] [8] [9]
Stories common to a particular culture, but not supported by external sources (such as the tales surrounding King Arthur), are usually classified as cultural heritage or legends
특정 문화에 공통적이지만 외부 출처 (예 : 아서 왕을 둘러싼 이야기)에 의해 뒷받침되지 않는 이야기는 일반적으로 문화 유산 또는 전설로 분류됩니다.
[10][11] History differs from myth in that it is supported by verifiable evidence
[10] [11] 역사는 검증 가능한 증거로 뒷받침된다는 점에서 신화와 다릅니다.
However, ancient cultural influences have helped spawn variant interpretations of the nature of history which have evolved over the centuries and continue to change today
그러나 고대 문화적 영향은 수세기에 걸쳐 진화 한 역사의 본질에 대한 변형 해석을 스폰하는 데 도움이되었으며 오늘날 계속 변화하고 있습니다.
The modern study of history is wide-ranging, and includes the study of specific regions and the study of certain topical or thematic elements of historical investigation
역사에 대한 현대 연구는 광범위하며 특정 지역에 대한 연구와 역사적 조사의 특정 국소 또는 주제 요소에 대한 연구가 포함됩니다.
History is often taught as a part of primary and secondary education, and the academic study of history is a major discipline in university studies
역사는 종종 초등 및 중등 교육의 일부로 가르치고 역사에 대한 학업 연구는 대학 연구의 주요 분야입니다.
Herodotus, a 5th-century BC Greek historian, is often considered the "father of history" in the Western tradition,[12] although he has also been criticized as the "father of lies"
기원전 5 세기 그리스 역사가 인 헤로도투스 (Herodotus)는 종종 서구 전통에서 "역사의 아버지"로 간주되지만 [12] 그는 또한 "거짓말의 아버지"로 비판을 받았다.
[13][14] Along with his contemporary Thucydides, he helped form the foundations for the modern study of past events and societies
[13] [14] 그의 현대 Thucydides와 함께, 그는 과거 사건과 사회에 대한 현대 연구를위한 기초를 형성하는 데 도움을주었습니다.
[15] Their works continue to be read today, and the gap between the culture-focused Herodotus and the military-focused Thucydides remains a point of contention or approach in modern historical writing
[15] 그들의 작품은 오늘날에도 계속 읽히고 있으며, 문화 중심의 헤로도투스와 군사 중심의 투키디데스 사이의 격차는 현대 역사적 글쓰기에서 논쟁이나 접근의 지점으로 남아 있습니다.
In East Asia, a state chronicle, the Spring and Autumn Annals, was reputed to date from as early as 722 BC, although only 2nd-century BC texts have survived
동아시아에서, 봄과 가을 연대기 인 주 크로니클은 기원전 722 년 초부터 2 세기 BC 텍스트 만 살아 남았습니다.

 

영어to한글.txt
0.00MB

728x90
반응형

댓글