From e4355dade20efe2528eee65d6c3651a91ac11800 Mon Sep 17 00:00:00 2001 From: Martin Andrews Date: Mon, 18 Dec 2017 18:12:10 +0800 Subject: [PATCH] Documentation example fix : token.head needs '==' rather than 'is' (similar change to #1689, it seems). --- website/usage/_linguistic-features/_dependency-parse.jade | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/usage/_linguistic-features/_dependency-parse.jade b/website/usage/_linguistic-features/_dependency-parse.jade index 0b6cc53ba..188b7b8f3 100644 --- a/website/usage/_linguistic-features/_dependency-parse.jade +++ b/website/usage/_linguistic-features/_dependency-parse.jade @@ -143,10 +143,10 @@ p +code. doc = nlp(u'Credit and mortgage account holders must submit their requests') - root = [token for token in doc if token.head is token][0] + root = [token for token in doc if token.head == token][0] subject = list(root.lefts)[0] for descendant in subject.subtree: - assert subject.is_ancestor(descendant) + assert subject is descendant or subject.is_ancestor(descendant) print(descendant.text, descendant.dep_, descendant.n_lefts, descendant.n_rights, [ancestor.text for ancestor in descendant.ancestors])