Documentation example fix : token.head needs '==' rather than 'is'

(similar change to #1689, it seems).
This commit is contained in:
Martin Andrews 2017-12-18 18:12:10 +08:00 committed by GitHub
parent c2159c77c5
commit e4355dade2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -143,10 +143,10 @@ p
+code. +code.
doc = nlp(u'Credit and mortgage account holders must submit their requests') 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] subject = list(root.lefts)[0]
for descendant in subject.subtree: 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, print(descendant.text, descendant.dep_, descendant.n_lefts, descendant.n_rights,
[ancestor.text for ancestor in descendant.ancestors]) [ancestor.text for ancestor in descendant.ancestors])