νμ΄μ¬μΌλ‘ μλ¨μ΄ λλ€νκ² 500κ° μμ±νκΈ°
νμΈνλ λ°μ΄ν°λ₯Ό λ§λ€λ μ€ μλμ²λΌ μλ¨μ΄μ λ»μΌλ‘ ꡬμ±λ jsonνμΌμ΄ νμνλ€. λλ΅ 500κ°μ λ μμΌλ©΄ μΆ©λΆν κ±° κ°μλ€.
{
"plain": "μμ§ν",
"parallel": "ννν",
"crack": "κΈμ΄ κ°λ€",
"Red": "λΉ¨κ°μ",
"deal": "κ±°λ",
"size": "ν¬κΈ°",
}
νΉμλν΄μ chatgptμκ² λ¬Όμ΄λ³΄λ λ°λ‘ λ§λ€μ΄μ€¬λ€. κ·Έλ°λ° λ¨μ§ κ²°κ³Όλ§ μλ €μ€κ² μλλΌ νμ΄μ¬ μ½λλ ν¨κ» μλ €μ€¬λ€.
λλ μ½λλ₯Ό μꡬνμ λ μμλλ° λ§μ΄λ€. (μλ§λ μ΄μ λνκΈ°λ‘μ λ°νμΌλ‘ μΆλ‘ νμκ²μ΄λ€)
λꡬλ λλ μ½λλ‘ μ΄λ°κ±Έ λ§λ€μ΄λ΄λμκ° μμκ±°λΌ μκ°νμ λ μμλ€.
μ½λλ₯Ό 보λ ntlkλΌλ λΌμ΄λΈλ¬λ¦¬ μμ μμ΄μ¬μ μ΄ μκ³ μ΄κ²μ κ°μ Έμ κ΅¬κΈ λ²μ apiλ‘ λ²μμ νλ κ² κ°λ€.
λ§μ μ½λλ₯Ό λλ €λ³΄λ μ¬λλ€μ΄ κ±°μ μ¬μ©νμ§ μλ λ¨μ΄λ€μ 무μμλ‘ 500κ° κ°μ Έμ€κΈ°μ
νλ² λ chatgptμ νμ λΉλ € μ½λλ₯Ό 보κ°νλ€.
κΈ°λ₯μ μλμ κ°λ€.
1. μμ±νκ³ μ νλ μλ¨μ΄ μλ₯Ό μ λ ₯νλ©΄(μλ μ£ΌμλΆλΆμ μμ )
2. μμλΉλ 5000κ°μ λ¨μ΄λ₯Ό λ¨Όμ κ°μ Έμ(λ¬Όλ‘ μ΄κ²λ μλ μ½λμμ 5000μ μνλ κ°μΌλ‘ μμ νλ©΄λλ€)
3. κ·Έ μ€ λͺ μ¬μ λμ¬λ§ μΆλ €λΈ ν
4. λλ€νκ² 500κ°λ§ jsonνμμΌλ‘ νμΌλ‘ μ μ₯νλ κ²μ΄λ€.
* μ΄μ λλ €λ³΄μ
1. λ¨Όμ μ€μΉν κ² νλμλ€
pip install nltk googletrans==4.0.0-rc1
2. λ€μ μλ μ½λλ₯Ό κ·Έλ₯ λΆμ¬λ£κΈ°νκ³ λ리면 λλ€.
- μ²μμλ μ¬μ μ λ€μ΄λ‘λ νλλ° μκ°μ΄ μ’ κ±Έλ¦°λ€
import random, time
import nltk
from nltk.corpus import words, brown
from collections import Counter
from googletrans import Translator
import json
# NLTK λ°μ΄ν° λ€μ΄λ‘λ (νλ²λ§ μ€ννλ©΄ λ©λλ€)
nltk.download('words')
nltk.download('brown')
nltk.download('averaged_perceptron_tagger')
# μμ±νκ³ μ νλ μλ¨μ΄ κ°μλ₯Ό μ
λ ₯
word_count = 500
# λͺ¨λ μμ΄ λ¨μ΄ λͺ©λ‘
word_list = words.words()
# Brown μ½νΌμ€μ λ¨μ΄ λͺ©λ‘κ³Ό λΉλ κ³μ°
brown_words = brown.words()
word_freq = Counter(brown_words)
# λΉλκ° λμ μμ λ¨μ΄ 5000κ° μ ν
common_words = {word for word, freq in word_freq.most_common(5000)}
# word_listμμ μμ λΉλ λ¨μ΄λ§ μ ν
filtered_word_list = [word for word in word_list if word.lower() in common_words]
# νμ¬ νκΉ
νμ¬ λͺ
μ¬μ λμ¬λ§ νν°λ§
tagged_words = nltk.pos_tag(filtered_word_list)
# λͺ
μ¬μ λμ¬ νμ¬ νκ·Έ λͺ©λ‘
noun_tags = {'NN', 'NNS', 'NNP', 'NNPS'}
verb_tags = {'VB', 'VBD', 'VBG', 'VBN', 'VBP', 'VBZ'}
# λͺ
μ¬μ λμ¬λ§ νν°λ§
filtered_nouns_and_verbs = [word for word, tag in tagged_words if tag in noun_tags or tag in verb_tags]
# κ·Έ μ€ λλ€νκ² 500κ°μ λ¨μ΄λ₯Ό μ νν©λλ€.
random_words = random.sample(filtered_nouns_and_verbs, word_count)
# Google Translate APIλ₯Ό μ¬μ©νμ¬ λ²μν©λλ€.
translator = Translator()
translated_dict = {}
def save():
with open('translated_words.json', 'w', encoding='utf-8') as f:
json.dump(translated_dict, f, ensure_ascii=False, indent=4)
for idx, word in enumerate(random_words):
try:
translated_word = translator.translate(word, src='en', dest='ko').text
print(idx+1, word, translated_word)
translated_dict[word] = translated_word
time.sleep(1)
except:
print('μ€κ°μ μ€λ₯λ°μ. μ§κΈκΉμ§ μμ
ν κ²λ€ μ μ₯ν¨')
save()
# JSON νμΌλ‘ μ μ₯ν©λλ€.
save()
print(f"{len(random_words)}κ°μ λ¨μ΄κ° λ²μλκ³ JSON νμΌλ‘ μ μ₯λμμ΅λλ€.")
μ μ½λλ₯Ό λ리면 μλ νμΌκ³Ό κ°μ κ²°κ³Όλ₯Ό μ»μ μ μλ€.
κ±°μ 100% chatgptκ° μ½λ©ν κ²°κ³Όμ΄κ³ λλ νΈμλ₯Ό μν μ¬μν μμ κ³Ό μ½λ μ‘°ν©λ§ νλ€.
μ΄μͺ½ λΆμΌμ μμΌλ©΄μλ μμΌ λλΌμ΄ μΈμμμ λλ ν루μλ€.