python 3 是否有西班牙语到英语的词典?
Is there a Spanish to English dictionary for use with python 3?
我正在尝试通过翻译在 nltk 3.0 中找到的整个西班牙语语料库来为 python 3 创建我自己的数字西班牙语到英语数据库。我正在使用 Google 工具包来完成翻译和证明是一个非常缓慢的过程。我想知道是否存在我可以在 python 中导入和使用的西班牙语到英语词典(最好是模块形式) 3. 下面是我必须手动进行翻译的代码。到目前为止,每 5000 次翻译大约需要 12.5 分钟。
import goslate
import nltk
import pickle
x = pickle.load(open( "espcorpus.pickle", "rb" ))
gs = goslate.Goslate()
y = len(x)
y = y-1
print(y)
z = 0
b = []
n = 0
error = 0
import pickle
while z < 192683:
n = n + 1
while -1 < z < (4481*n):
try:
c = gs.translate(x[z], 'en', 'es')
word=nltk.word_tokenize(c)
c = nltk.pos_tag(word)
b.append(c[0])
print(z)
z += 1
except:
continue
error += 1
pickle.dump(b, (open('filename%s.pickle' % n, 'wb')))
print(n)
b = []
print('errors: %i' % error)
idealist = []
n = 1
while n<27:
print(n)
target = 'filename%s.pickle' % n
with open(target, "rb") as file:
unpickler = pickle.Unpickler(file)
poop = unpickler.load()
x = len(poop)
z = 0
while z<x:
idealist.append(poop[z])
z= z +1
n = n + 1
print(len(idealist))
pickle.dump(idealist, (open('master.pickle', 'wb')))
我希望如何设置最终的数据库:
[西班牙语单词,英语单词,英语词性标记]
如果我遗漏了什么,请告诉我。
提前感谢您的专业知识。
您不需要任何专门为 python 格式化的字典,只需要一种您可以用 python 消化的格式,这几乎意味着任何众所周知的文本格式。只需尝试找到一个易于理解格式的开源词典,然后用 python 解析它。
我正在尝试通过翻译在 nltk 3.0 中找到的整个西班牙语语料库来为 python 3 创建我自己的数字西班牙语到英语数据库。我正在使用 Google 工具包来完成翻译和证明是一个非常缓慢的过程。我想知道是否存在我可以在 python 中导入和使用的西班牙语到英语词典(最好是模块形式) 3. 下面是我必须手动进行翻译的代码。到目前为止,每 5000 次翻译大约需要 12.5 分钟。
import goslate
import nltk
import pickle
x = pickle.load(open( "espcorpus.pickle", "rb" ))
gs = goslate.Goslate()
y = len(x)
y = y-1
print(y)
z = 0
b = []
n = 0
error = 0
import pickle
while z < 192683:
n = n + 1
while -1 < z < (4481*n):
try:
c = gs.translate(x[z], 'en', 'es')
word=nltk.word_tokenize(c)
c = nltk.pos_tag(word)
b.append(c[0])
print(z)
z += 1
except:
continue
error += 1
pickle.dump(b, (open('filename%s.pickle' % n, 'wb')))
print(n)
b = []
print('errors: %i' % error)
idealist = []
n = 1
while n<27:
print(n)
target = 'filename%s.pickle' % n
with open(target, "rb") as file:
unpickler = pickle.Unpickler(file)
poop = unpickler.load()
x = len(poop)
z = 0
while z<x:
idealist.append(poop[z])
z= z +1
n = n + 1
print(len(idealist))
pickle.dump(idealist, (open('master.pickle', 'wb')))
我希望如何设置最终的数据库: [西班牙语单词,英语单词,英语词性标记]
如果我遗漏了什么,请告诉我。
提前感谢您的专业知识。
您不需要任何专门为 python 格式化的字典,只需要一种您可以用 python 消化的格式,这几乎意味着任何众所周知的文本格式。只需尝试找到一个易于理解格式的开源词典,然后用 python 解析它。