spaCy/website/usage
mpuels e3af19a076
doc: Replace 'is not' with '!=' in code example
The function `dependency_labels_to_root(token)` defined in section *Get syntactic dependencies* does not terminate. Here is a complete example:

    import spacy
    
    nlp = spacy.load('en')
    doc = nlp("Apple and banana are similar. Pasta and hippo aren't.")
    
    def dependency_labels_to_root(token):
        """Walk up the syntactic tree, collecting the arc labels."""
        dep_labels = []
        while token.head is not token:
            dep_labels.append(token.dep)
            token = token.head
        return dep_labels
    
    dep_labels = dependency_labels_to_root(doc[1])
    dep_labels

Replacing `is not` with `!=` solves the issue:

    import spacy
    
    nlp = spacy.load('en')
    doc = nlp("Apple and banana are similar. Pasta and hippo aren't.")
    
    def dependency_labels_to_root(token):
        """Walk up the syntactic tree, collecting the arc labels."""
        dep_labels = []
        while token.head != token:
            dep_labels.append(token.dep)
            token = token.head
        return dep_labels
    
    dep_labels = dependency_labels_to_root(doc[1])
    dep_labels

The output is

    ['cc', 'nsubj']
2017-12-06 20:08:42 +01:00
..
_adding-languages Fix typo 2017-11-13 17:00:03 +01:00
_deep-learning Update usage documentation 2017-10-03 14:26:20 +02:00
_facts-figures Update v2 docs and model info 2017-11-08 11:43:00 +01:00
_install Add "Unknown locale" issue to troubleshooting guide (see #1684, #1641, #1517) 2017-12-05 13:17:55 +01:00
_linguistic-features Corrected char index instead of token index 2017-11-26 23:55:25 +01:00
_models Add Russian to list of languages 2017-12-06 13:40:32 +01:00
_processing-pipelines Another small fix to component docs 2017-11-23 11:47:20 +01:00
_spacy-101 doc: Replace 'is not' with '!=' in code example 2017-12-06 20:08:42 +01:00
_training Document offsets_from_biluo_tags 2017-12-06 13:40:51 +01:00
_v2 Fix broken links 2017-11-10 13:06:38 +01:00
_vectors-similarity Fix typo 2017-11-17 17:57:55 +01:00
_visualizers Re-add python -m to commands, too brittle :( (see #1536) 2017-11-10 02:30:55 +01:00
_data.json Add videos section to resources 2017-11-13 08:29:57 +01:00
_deep-learning.jade Update website for v2.0 2017-11-07 14:48:17 +01:00
adding-languages.jade Remove old link 2017-11-09 15:34:12 +01:00
examples.jade Update examples 2017-11-07 01:22:30 +01:00
facts-figures.jade Update usage documentation 2017-10-03 14:26:20 +02:00
index.jade Update website 2017-11-08 01:06:30 +01:00
linguistic-features.jade Update usage documentation 2017-10-03 14:26:20 +02:00
models.jade Update v2 details 2017-11-06 21:15:36 +01:00
processing-pipelines.jade Update pipeline component usage docs 2017-10-10 04:24:39 +02:00
resources.jade Update resources 2017-12-02 04:16:03 +01:00
spacy-101.jade Re-add python -m to commands, too brittle :( (see #1536) 2017-11-10 02:30:55 +01:00
training.jade Update training docs 2017-11-07 01:06:31 +01:00
v2.jade Get docs ready for v2.0.0 2017-11-07 12:00:43 +01:00
vectors-similarity.jade Update vectors and similarity usage guide 2017-11-01 01:25:17 +01:00
visualizers.jade Update visualizers docs and add submenu 2017-10-03 19:40:39 +02:00