【发布时间】:2020-05-05 22:39:48
【问题描述】:
我想在官方documentation之后的记录联动中应用自定义方法。我的代码:
import recordlinkage as rl
from recordlinkage.base import BaseCompareFeature
def compute_wmd( s1, s2):
word2vec_file = "C:\\Users\\users\\Desktop\\GoogleNews-vectors-negative300.bin"
word2vec = gensim.models.KeyedVectors.load_word2vec_format(word2vec_file, binary=True)
word2vec.init_sims(replace=True) # Normalizes the vectors in the word2vec class
score = word2vec.wmdistance(s1, s2)
return score
comparer = rl.Compare()
comparer.add(compute_wmd('Description US', 'Description US', label='Description'))
comparer.compute(pairs, csv)
我收到此错误:
TypeError:compute_wmd() 得到了一个意外的关键字参数“标签”
如果我删除标签,我会收到此错误:
AttributeError: 'float' 对象没有属性 'labels_left'
【问题讨论】:
标签: python function record-linkage