AveragedPerceptronPython icon indicating copy to clipboard operation
AveragedPerceptronPython copied to clipboard

这里的`train`是更新条件遗漏了吗?

Open flystarhe opened this issue 8 years ago • 2 comments

你好,我想请教一下200行Python代码实现感知机词性标注器中【搜索】哪一节中train函数的一个问题:

文中前端说的是,当guess != true_tag时就更新权重(犯错时),第一个train出现的时候。可是【搜索】这一段中却总是在更新,是遗漏了吗?

                guess = self.tagdict.get(word)
                if not guess:
                    feats = self._get_features(
                                i, word, context, prev, prev2)
                    guess = self.model.predict(feats)
                    self.model.update(tags[i], guess, feats)
                # Set the history features from the guesses, not the
                # true tags

flystarhe avatar Jan 05 '17 03:01 flystarhe

update内部有判断

    if truth == guess:
        return None

hankcs avatar Jan 05 '17 03:01 hankcs

@hankcs thanks

flystarhe avatar Jan 05 '17 06:01 flystarhe