mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-11-04 01:48:04 +03:00 
			
		
		
		
	Merge pull request #604 from SultanMirza/patch-1
Fix typos and mistakes in Dependency Parse usage workflow
This commit is contained in:
		
						commit
						586206c7b8
					
				| 
						 | 
					@ -43,7 +43,7 @@ p
 | 
				
			||||||
    |  #[code token.dep_].
 | 
					    |  #[code token.dep_].
 | 
				
			||||||
 | 
					
 | 
				
			||||||
+aside-code("Example").
 | 
					+aside-code("Example").
 | 
				
			||||||
    from spacy.symbols import DET
 | 
					    from spacy.symbols import det
 | 
				
			||||||
    the, dog = nlp(u'the dog')
 | 
					    the, dog = nlp(u'the dog')
 | 
				
			||||||
    assert the.dep == det
 | 
					    assert the.dep == det
 | 
				
			||||||
    assert the.dep_ == 'det'
 | 
					    assert the.dep_ == 'det'
 | 
				
			||||||
| 
						 | 
					@ -96,14 +96,14 @@ p
 | 
				
			||||||
    print([w.text for w in apples.rights])
 | 
					    print([w.text for w in apples.rights])
 | 
				
			||||||
    # ['on']
 | 
					    # ['on']
 | 
				
			||||||
    assert apples.n_lefts == 2
 | 
					    assert apples.n_lefts == 2
 | 
				
			||||||
    assert apples.n_rights == 3
 | 
					    assert apples.n_rights == 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    from spacy.symbols import nsubj
 | 
					    from spacy.symbols import nsubj
 | 
				
			||||||
    doc = nlp(u'Credit and mortgage account holders must submit their requests within 30 days.')
 | 
					    doc = nlp(u'Credit and mortgage account holders must submit their requests within 30 days.')
 | 
				
			||||||
    root = [w for w in doc if w.head is w][0]
 | 
					    root = [w for w in doc if w.head is w][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_ancestor_of(descendant)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    from spacy.symbols import nsubj
 | 
					    from spacy.symbols import nsubj
 | 
				
			||||||
    doc = nlp(u'Credit and mortgage account holders must submit their requests.')
 | 
					    doc = nlp(u'Credit and mortgage account holders must submit their requests.')
 | 
				
			||||||
| 
						 | 
					@ -131,7 +131,7 @@ p
 | 
				
			||||||
 | 
					
 | 
				
			||||||
p
 | 
					p
 | 
				
			||||||
    |  Finally, I often find the #[code .left_edge] and #[code right_edge]
 | 
					    |  Finally, I often find the #[code .left_edge] and #[code right_edge]
 | 
				
			||||||
    |  attributes especially useful. They give you the first and right tokens
 | 
					    |  attributes especially useful. They give you the first and last token
 | 
				
			||||||
    |  of the subtree. This is the easiest way to create a #[code Span] object
 | 
					    |  of the subtree. This is the easiest way to create a #[code Span] object
 | 
				
			||||||
    |  for a syntactic phrase — a useful operation.
 | 
					    |  for a syntactic phrase — a useful operation.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -160,4 +160,4 @@ p
 | 
				
			||||||
+code.
 | 
					+code.
 | 
				
			||||||
    nlp = spacy.load('en')
 | 
					    nlp = spacy.load('en')
 | 
				
			||||||
    doc1 = nlp(u'Text I do want parsed.')
 | 
					    doc1 = nlp(u'Text I do want parsed.')
 | 
				
			||||||
    doc2 = nlp(u'Text I don't want parsed', parser=False)
 | 
					    doc2 = nlp(u"Text I don't want parsed", parse=False)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user